Skip to content

Instantly share code, notes, and snippets.

@P-Louw
Created September 11, 2022 21:07
Show Gist options
  • Save P-Louw/37b7dd70b688fd290834e3187dec31ac to your computer and use it in GitHub Desktop.
Save P-Louw/37b7dd70b688fd290834e3187dec31ac to your computer and use it in GitHub Desktop.
Set wacom devices drawing surface to single monitor.
#!/usr/bin/bash
<<COMMENT
Setup wacom device:
- Date: 2022-09-11
- Device: 'Wacom one M'
- Requires
- xsetwacom
- xrandr
- xinput
COMMENT
for com in xsetwacom xrandr xinput; do
if ! command -v $com &> /dev/null
then
echo "$com could not be found"
exit
fi
done
# Get device names of all connected monitors.
displays=($(xrandr | grep -Po "\K[^+w]+\b(?=connected)"))
echo "Detected ${#displays[@]} connected monitors."
PS3="Select which monitor the wacom should target:"$'\n'"=> "
select disp in "${displays[@]}"
do
if [[ $disp == "" ]]; then
echo Invalid choice!
else
echo "Selected ${disp}"
break
fi
done
echo "Reading all wacom devices..."
# Get wacom device ids:
wacomIds=$(xsetwacom --list | grep -Eo '[0-9]{1,2}')
for id in $wacomIds; do
xinput map-to-output $id $disp
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment