Skip to content
Snippets Groups Projects
Commit 045a0377 authored by Walmes Marques Zeviani's avatar Walmes Marques Zeviani
Browse files

Adds Huion configuration.

parent 6788e34a
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
#-----------------------------------------------------------------------
# Prof. Dr. Walmes M. Zeviani
# leg.ufpr.br/~walmes · github.com/walmes
# walmes@ufpr.br · @walmeszeviani
# Laboratory of Statistics and Geoinformation (LEG)
# Department of Statistics · Federal University of Paraná
# 2023-jun-26 · Curitiba/PR/Brazil
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# Instruções.
# ATTENTION: fazer a instalação dos drivers que está em
# `huion_h1060p_install_drivers.sh`
# Dar atribuição de execução.
# chmod +x ./huion_h1060p_configure.sh
# Abrir o crontab e colocar a linha.
# @reboot ~/Projects/linux-config/huion_h1060p_configure.sh
#-----------------------------------------------------------------------
# HUION H1060P.
# https://www.huion.com/pt/pen_tablet/Inspiroy/H1060P.html
# https://pt.aliexpress.com/item/1005004520012670.html
# Mostra se tem Wacom plugada em porta USB.
lsusb | grep '256c:006d'
# Dispositivos Wacom conectados.
xsetwacom --list devices
# Nome da mesa digitalizadora.
WACOM=$(xsetwacom --list devices | grep "STYLUS" | awk '{print gensub(/(.+) stylus.*/, "\\1", "g")}')
echo $WACOM
# Monitores disponíveis.
xrandr --listactivemonitors
echo "Qual monitor você quer usar [0 ou 1]?"
# opcao=1
read opcao
if [ $opcao -eq 0 ]
then
echo "Escolheu 0"
MAINMONITOR=$(xrandr | grep ' connected' | awk '{print gensub(/(.+).*connected.*/, "\\1", "g")}' | sed -n '1p')
elif [ $opcao -eq 1 ]
then
echo "Escolheu 1"
MAINMONITOR=$(xrandr | grep ' connected' | awk '{print gensub(/(.+).*connected.*/, "\\1", "g")}' | sed -n '2p')
fi
echo "Monitor escolhido:"
echo $MAINMONITOR
# Mapeia a Wacom para o monitor principal.
if xsetwacom --list devices | grep -q "STYLUS"; then
xsetwacom --set "$WACOM stylus" MapToOutput $MAINMONITOR
fi
if xsetwacom --list devices | grep -q "PAD"; then
xsetwacom --set "$WACOM Pad pad" MapToOutput $MAINMONITOR
fi
# Configura para manter mapeamento isométrico. -------------------------
if xsetwacom --list devices | grep -q "STYLUS"; then
# Determina a área do tablet.
AREALEFT=0
AREATOP=0
$(
xinput list-props "$WACOM stylus" | \
grep 'Wacom Tablet Area' | \
awk '{print gensub(/.*0, 0, ([0-9]+), ([0-9]+)/, "export AREARIGHT=\\1\nexport AREABOTTOM=\\2", "g")}'
)
# echo $AREARIGHT
# echo $AREABOTTOM
AREAWIDTH=$(echo $AREARIGHT-$AREALEFT | bc -l)
AREAHEIGHT=$(echo $AREABOTTOM-$AREATOP | bc -l)
# echo $AREAWIDTH
# echo $AREAHEIGHT
# Determina a área do monitor.
$(
xrandr | \
grep $MAINMONITOR | \
awk '{print gensub(/.*connected.* ([0-9]+)x([0-9]+).*/, "export SCREENWIDTH=\\1\nexport SCREENHEIGHT=\\2", "g")}'
)
# echo $SCREENHEIGHT
# echo $SCREENWIDTH
RESULTWIDTH=$(echo $AREAHEIGHT/$SCREENHEIGHT*$SCREENWIDTH | bc -l)
RESULTHEIGHT=$(echo $AREAWIDTH/$SCREENWIDTH*$SCREENHEIGHT | bc -l)
# echo $RESULTWIDTH
# echo $RESULTHEIGHT
if [ $(echo "$RESULTWIDTH > $AREAWIDTH" | bc -l) ]; then
RESULTHEIGHT=$(echo $AREAWIDTH/$RESULTWIDTH*$AREAHEIGHT | bc -l)
RESULTWIDTH=$AREAWIDTH
else
RESULTWIDTH=$(echo $AREAHEIGHT/$RESULTHEIGHT*$AREAWIDTH | bc -l)
RESULTHEIGHT=$AREAHEIGHT
fi
round () {
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
};
RESULTRIGHT=$(round $(echo $AREALEFT + $RESULTWIDTH | bc) 0)
RESULTBOTTOM=$(round $(echo $AREATOP + $RESULTHEIGHT | bc) 0)
# echo $RESULTRIGHT
# echo $RESULTBOTTOM
# Confina o tablet ao monitor especificado.
# echo "Confina \`$WACOM\` ao monitor \`$MAINMONITOR\`"
# xsetwacom set "$WACOM" MapToOutput $MAINMONITOR
# Define a área de trabalho para ter escala 1:1.
echo "Define área de trabalho para escala isométrica."
xsetwacom set "$WACOM stylus" \
Area $AREALEFT $AREATOP $RESULTRIGHT $RESULTBOTTOM
fi
# Configura botões laterais. -------------------------------------------
# Definições de botões para usar com o Xournal++.
echo "Define mapeamento dos botões do tablet para o Xournal++."
echo " [ F11 ] [ ]" # Full screen |
echo " [ C-S-p ] [ C-S-h ]" # Pencil | Highlighter
echo " [ C-S-e ] [ C-S-g ]" # Erase | Select region
echo " [ C-W ] [ W-k ]" # Compiz | Compiz
echo " [ ] [ ]"
echo " [ C-z ] [ C-y ]" # Undo | Redo
xsetwacom set "$WACOM Pad pad" button 1 key f11
# xsetwacom set "$WACOM Pad pad" button 2 key tab
xsetwacom set "$WACOM Pad pad" button 3 key +Ctrl +Shift +P
xsetwacom set "$WACOM Pad pad" button 8 key +Ctrl +Shift +H
xsetwacom set "$WACOM Pad pad" button 9 key +Ctrl +Shift +E
xsetwacom set "$WACOM Pad pad" button 10 key +Ctrl +Shift +G
xsetwacom set "$WACOM Pad pad" button 11 key +Super +Alt
xsetwacom set "$WACOM Pad pad" button 12 key +Super +K
# xsetwacom set "$WACOM Pad pad" button 13 key v
# xsetwacom set "$WACOM Pad pad" button 14 key b
xsetwacom set "$WACOM Pad pad" button 15 key +Ctrl +Z
xsetwacom set "$WACOM Pad pad" button 16 key +Ctrl +Y
#-----------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment