Organising
This commit is contained in:
40
.local/bin/nixos-todo/initwacom
Executable file
40
.local/bin/nixos-todo/initwacom
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in $(seq 10); do
|
||||
if xsetwacom list devices | grep -q Wacom; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
list=$(xsetwacom list devices)
|
||||
column=$((echo "$list" | grep "\(WL\)" >/dev/null) && echo 9 || echo 8)
|
||||
pad=$(echo "${list}" | awk "/pad/{print \$$column}")
|
||||
stylus=$(echo "${list}" | awk "/stylus/{print \$$column}")
|
||||
eraser=$(echo "${list}" | awk "/eraser/{print \$$column}")
|
||||
|
||||
if [ -z "${pad}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
first_display="$(xrandr | grep -oP "([^\s]+)(?=\sconnected)" | head -1)"
|
||||
|
||||
xsetwacom set "${stylus}" MapToOutput "${first_display}"
|
||||
xsetwacom set "${eraser}" MapToOutput "${first_display}"
|
||||
|
||||
first_resolution="$(xrandr | grep -oP "(\d+x\d+)(?=[^*]+\*)" | head -1)"
|
||||
IFS='x'
|
||||
read -ra resolution <<< "$first_resolution"
|
||||
|
||||
width=31496
|
||||
height="$(bc -l <<< "ratio=${resolution[0]}/${resolution[1]}; scale=0; $width/ratio")"
|
||||
|
||||
xsetwacom set "${stylus}" Area "0 0 $width $height"
|
||||
xsetwacom set "${eraser}" Area "0 0 $width $height"
|
||||
|
||||
xsetwacom set "${pad}" Button 11 "key +ctrl z -ctrl"
|
||||
xsetwacom set "${pad}" Button 10 "key +shift"
|
||||
xsetwacom set "${pad}" Button 9 "key +ctrl"
|
||||
xsetwacom set "${pad}" Button 1 "button +15"
|
||||
#xsetwacom set "${pad}" Button 4 "key 0xffad"
|
||||
#xsetwacom set "${pad}" Button 4 "button +5"
|
||||
Reference in New Issue
Block a user