Skip to content

Instantly share code, notes, and snippets.

@odysseywestra
Last active December 7, 2021 06:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odysseywestra/d7cefd9e9440fb366bd1fe41e1cb4127 to your computer and use it in GitHub Desktop.
Save odysseywestra/d7cefd9e9440fb366bd1fe41e1cb4127 to your computer and use it in GitHub Desktop.
Wacom Tablet automated xsetwacom Config Script. Specificly for Wacom PTH-651
#! /bin/bash
#NOTE: I'm working on getting this to working with xinput instead of xsetwacom
# due to the volidity of it.
# Wacom Tablet automated xsetwacom Config Script. Specificly for Wacom PTH-651.
#:
#: Usage: bash ./wacom-config.sh [Options]
#:
#: Options:
#: --help Show this message and exit.
#: --display-info Show Display info.
#: --tablet-info Displays tablet information.
#: --set-all Sets all the parameters to default. Can be use to reset as well.
#: --set-buttons Set buttons acording to configuration.
#: --switch-display Switch between two displays.
#: --scroll-mode Map AbsScrollWheel to 4 button modes.
#: --percision-switch Switch between fullscreen, and percision mode.
#: --touch-mode Enable or Disable Touch on the Tablet
#: --pen-mode Switch between Releative and Absoulte Mode
#: --flip-tablet Flips the Orintation of the tablet. Buttons will flip as well.
#:
#: Be sure to edit the top part of the script. It configures based on the info you give it.
#:
#: Make sure to use bash to launch script, otherwise you will get an error when
#: the script tries to do the math for percision mode.
#:
#: Script uses a combination of both xinput and xsetwacom to change settings.
#:
#: Script written by Albert Westra(odysseywestra@gmail.com)
#: Percision Modes of this script is based off the script by David Revoy:
#: * https://gist.github.com/Deevad/51820854ffd5ea5cd883
#: License: CC-0/Public-Domain/WTFPL (http://www.wtfpl.net/) license
#:
# Look under your tablet for Model Number
tablet_model="PTH-651"
# Use "$ xsetwacom --list devices" or "$ xinput list" for it's name.
tablet_name="Wacom Intuos Pro M"
## Measurements
# Enter here the active area of your tablet in cm:
XtabletactiveareaCM=22.5
YtabletactiveareaCM=14
## Correction Scalling:
# This setting can enlarge a bit the precision zone. I saw during test a
# precision zone slightly larger has no impact on control quality, and might
# feels better.
#
# default=1 for real precision zone, enlarge=1.5 or reduce=0.8
#
# Tip: If you want the most accurate scale. Use a physical template like a
# circle template to draw on the tablet then compair to the one on your
# screen. If the shape on the monitor matches the shape on the template,
# then bingo you got it!
correctionscalefactor=1.06
# Alternative Size:
#correctionscalefactor=1.5
## Notify-send icon
# Custom Icon if you want to personalize your notifcations.
# NOTE: This assumes you have the Pop Icon theme installed.
tablet_icon="/usr/share/icons/Pop/scalable/devices/input-tablet-symbolic.svg"
## Button Shortcuts
# NOTE: You will need to set the Keybaord Shortcuts on your destkop environment with the appropiate commands for them to work.
# Top three buttons
button1="key +Control_L +Alt_L +Shift_L +F1 -F1" # Area Modes
button2="key +Control_L +Alt_L +Shift_L +F2 -F2" # Switch Monitor
button3="key +Control_L +Alt_L +Shift_L +F3 -F3" # Toggle Touch
button4="key +Control_L +Alt_L +Shift_L +F4 -F4" # Toggle Relative/Absolute
#Button 4 is the Scroll Wheel Mode Button
button5="key +Control_L +Alt_L +Shift_L +F5 -F5" # Switch Scroll Wheel Mode
# Bottom Three Buttons.
button6="key +Control_L +Alt_L +Shift_L +F6 -F6" # Flip Tablet Orintation
button7="key +Shift_L " # Left Shift Key
button8="key +Control_L" # Left Control Key
button9="key +Alt_L" # Left Alt Key
## Scroll Wheel Modes
# I Have four set cause I plan on binding it to button in the center of the
# scroll wheel. This button has a light which cycle in 4s.
# Mode 1
scrollwheelmode1="Step Zoom Mode"
scrollwheelup1="key +Shift_L +equal"
scrollwheeldown1="key +minus"
# Mode 2
scrollwheelmode2="Step Rotate Mode"
scrollwheelup2="key +Control_L +Left"
scrollwheeldown2="key +Control_L +Right"
# Mode 3
scrollwheelmode3="Brush Size Mode"
scrollwheelup3="key +f"
scrollwheeldown3="key +d"
# Mode 4
scrollwheelmode4="Layer Select Mode"
scrollwheelup4="key +PgUp"
scrollwheeldown4="key +PgDn"
# This is specific to a dual monitor setup. Leave at default
## Primary Display
# Name your display you have set as your primary monitor.
# Uncomment the second one if your just using a single monitor.
#
primaryname="External Display"
#primaryname="Primary Display"
## External/Secondary Display
#
secondaryname="Laptop Display"
# You shouldn't need to edit anything below this line for this device.
# ------------------------------------------------------------------------------
ignore="false"
said="false"
# Determine if Tablet is using the Wireless kit or Not. For me this is a
# better method.
get_tablet_info(){
if [ $(xsetwacom --list | grep -c "Wacom") = 0 ]; then
tablet_notify "No Tablet Detected. Exiting"
exit 1
else
if [ $(xsetwacom --list | grep -c "WL") = 4 ]; then
device="$tablet_name (WL)"
else
device="$tablet_name"
fi
fi
tablet_full_name="$device ($tablet_model)"
echo "Setup script for your $tablet_full_name"
echo "-----------------------------------------"
tabletstylus="$device Pen stylus"
tableteraser="$device Pen eraser"
tabletcursor="$device Pen cursor"
tabletpad="$device Pad pad"
tablettouch="$device Finger touch"
echo ""
echo "Tablet Information:"
echo "STYLUS: $tabletstylus"
echo "ERASER: $tableteraser"
echo "CURSOR: $tabletcursor"
echo "PAD: $tabletpad"
echo "TOUCH: $tablettouch"
echo ""
echo "-----------------------------------------"
}
# Getting Display Information
## Dual-Monitor Setup
# This is set up for my dual-monitor setup. This allows it to detect
# when my Display port is connected and sets the default monitor to map to.
get_display_info(){
#Check to see if you are using the nvidia card (Antergos Prime).
#Returns a 1 or 0
echo ""
echo "Gathering Display Information"
echo ""
nvidia=$(type -p nvidia-smi | grep -c nvidia)
echo "-----------------------------------------"
echo ""
if [ $nvidia = 1 ]; then
# Confirm Nvidia Card is there
echo "Nvidia GPU is being used"
else
echo "Intel GPU is being used"
fi
echo ""
echo "-----------------------------------------"
#First we need to findout if you are using more than one display.
if [ "$(xrandr --listmonitors | grep -w Monitors | awk '{print $2}')" -gt 1 ]; then
# Set the primary display
if [ $nvidia = 1 ]; then
# Set it for Nvidia
primary="HEAD-0"
# TODO Figure out how to get screen size info from Nvidia.
xrandrprimary="$(xrandr --listmonitors | grep 0: | awk '{print $4}')"
primarylocation="$(xrandr --current | grep -w $xrandrprimary | uniq | awk '{print $4}' | cut -d '+' -f 2-4)"
primarysize="$(xrandr --current | grep -w $xrandrprimary | uniq | awk '{print $4}' | cut -d '+' -f 1)"
else
# Set it for Intel
# Grabs name of display through xrandr.
primary="$(xrandr --listmonitors | grep 0: | awk '{print $4}')"
primarylocation="$(xrandr --current | grep -w $primary | uniq | awk '{print $4}' | cut -d '+' -f 2-4)"
primarysize="$(xrandr --current | grep -w $primary | uniq | awk '{print $4}' | cut -d '+' -f 1)"
fi
# Set the secondary display
if [ $nvidia = 1 ]; then
# Set for nvidia
secondary="HEAD-1"
# TODO Figure out how to get screen size info from Nvidia
xrandrsecondary="$(xrandr --listmonitors | grep 1: | awk '{print $4}')"
secondarylocation="$(xrandr --current | grep -w $xrandrsecondary | uniq | awk '{print $3}' | cut -d '+' -f 2-4)"
secondarysize="$(xrandr --current | grep -w $xrandrsecondary | uniq | awk '{print $3}' | cut -d '+' -f 1)"
else
# Set it for Intel
# Grabs name of display through xrandr.
secondary="$(xrandr --listmonitors | grep 1: | awk '{print $4}')"
secondarylocation="$(xrandr --current | grep -w $secondary | uniq | awk '{print $3}' | cut -d '+' -f 2-4)"
secondarysize="$(xrandr --current | grep -w $secondary | uniq | awk '{print $3}' | cut -d '+' -f 1)"
fi
else
# Set it as a single display
if [ $nvidia = 1 ]; then
# Set it for Nvidia
primary="HEAD-0"
# TODO Figure out how to get screen size info from Nvidia.
xrandrprimary="$(xrandr --listmonitors | grep 0: | awk '{print $4}')"
primarylocation="$(xrandr --current | grep -w $xrandrprimary | uniq | awk '{print $4}' | cut -d '+' -f 2-4)"
primarysize="$(xrandr --current | grep -w $xrandrprimary | uniq | awk '{print $4}' | cut -d '+' -f 1)"
else
# Set it for Intel
#Grabs name of display through xrandr.
primary="$(xrandr --listmonitors | grep 0: | awk '{print $4}')"
primarylocation="$(xrandr --current | grep -w $primary | uniq | awk '{print $4}' | cut -d '+' -f 2-4)"
primarysize="$(xrandr --current | grep -w $primary | uniq | awk '{print $4}' | cut -d '+' -f 1)"
fi
# Set Secondary to NONE
secondary="NONE"
secondaryname="NONE"
secondarylocation="0+0"
secondarysize="0x0"
secondaryname="NO NAME"
echo ""
echo "NO Secondary Display"
echo ""
echo "-----------------------------------------"
fi
# Show Display info for Debuggin Purposes.
echo ""
echo "Display Defaults"
echo "Primary Display: $primary ($primaryname)"
echo "Primary Display Size: $primarysize"
echo "Primary Display Location: $primarylocation"
echo ""
echo "Secondary Display: $secondary ($secondaryname)"
echo "Secondary Display Size: $secondarysize"
echo "Secondary Display Location: $secondarylocation"
echo ""
echo "-----------------------------------------"
}
## Delete tokens
tablet_delete_tokens(){
echo ""
echo "Removing Memory Tokens"
echo ""
rm -fv /tmp/wacomscript-$tablet_model*
echo ""
echo "-----------------------------------------"
tablet_notify "Removed Memory Tokens"
ignore="true"
}
tablet_notify(){
if [ $ignore == "false" ]; then
notify-send -i "$tablet_icon" "Tablet Settings" "$1"
else
if [ $said == "false" ]; then
notify-send -i "$tablet_icon" "Tablet Settings" "$device is ready to be used"
said="true"
fi
fi
}
## Set default Buttons
tablet_set_buttons(){
echo ""
if [ -f /tmp/wacomscript-$tablet_model-set_buttons-token ]; then
echo "Flipping Default Buttons for $tablepad"
xsetwacom set "$tabletpad" Button 13 "$button1"
xsetwacom set "$tabletpad" Button 12 "$button2"
xsetwacom set "$tabletpad" Button 11 "$button3"
xsetwacom set "$tabletpad" Button 10 "$button4"
xsetwacom set "$tabletpad" Button 1 "$button5"
xsetwacom set "$tabletpad" Button 9 "$button6"
xsetwacom set "$tabletpad" Button 8 "$button7"
xsetwacom set "$tabletpad" Button 3 "$button8"
xsetwacom set "$tabletpad" Button 2 "$button9"
echo ""
echo "Button 2: '$button9'"
echo "Button 3: '$button8'"
echo "Button 8: '$button7'"
echo "Button 9: '$button6'"
echo "Button 1: '$button5'"
echo "Button 10: '$button4'"
echo "Button 11: '$button3'"
echo "Button 12: '$button2'"
echo "Button 13: '$button1'"
tablet_notify "Buttons are Flipped as well"
rm /tmp/wacomscript-$tablet_model-set_buttons-token
else
echo "Setting Default Buttons for $tabletpad."
# This is the ture order of the buttons on the Tablet.
xsetwacom set "$tabletpad" Button 2 "$button1"
xsetwacom set "$tabletpad" Button 3 "$button2"
xsetwacom set "$tabletpad" Button 8 "$button3"
xsetwacom set "$tabletpad" Button 9 "$button4"
xsetwacom set "$tabletpad" Button 1 "$button5"
xsetwacom set "$tabletpad" Button 10 "$button6"
xsetwacom set "$tabletpad" Button 11 "$button7"
xsetwacom set "$tabletpad" Button 12 "$button8"
xsetwacom set "$tabletpad" Button 13 "$button9"
echo ""
echo "Button 2: '$button1'"
echo "Button 3: '$button2'"
echo "Button 8: '$button3'"
echo "Button 9: '$button4'"
echo "Button 1: '$button5'"
echo "Button 10: '$button6'"
echo "Button 11: '$button7'"
echo "Button 12: '$button8'"
echo "Button 13: '$button9'"
tablet_notify "Buttons are back to normal"
touch /tmp/wacomscript-$tablet_model-set_buttons-token
echo ""
echo "-----------------------------------------"
fi
}
## Tablet Display Mode
tablet_display_mode(){
if [ -f /tmp/wacomscript-$tablet_model-display-token ]; then
# This will map the tablet to the Secondary Display.
echo ""
echo "Mapped to $secondaryname"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" MapToOutput "$secondary"
xsetwacom set "$tableteraser" MapToOutput "$secondary"
xsetwacom set "$tabletcursor" MapToOutput "$secondary"
#xsetwacom set "$tablettouch" MapToOutput "$secondary"
tablet_notify "Mapped to $secondaryname"
rm /tmp/wacomscript-$tablet_model-display-token
else
# This will map the tablet to the Primary Display.
echo ""
echo "Mapped to $primaryname"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" MapToOutput "$primary"
xsetwacom set "$tableteraser" MapToOutput "$primary"
xsetwacom set "$tabletcursor" MapToOutput "$primary"
#xsetwacom set "$tablettouch" MapToOutput "$primary"
tablet_notify "Mapped to $primaryname"
if [ "$secondary" != "NONE" ]; then
touch /tmp/wacomscript-$tablet_model-display-token
else
echo ""
echo "NOTICE: There is only one display "
echo ""
echo "-----------------------------------------"
tablet_notify "There is only one Display"
fi
fi
}
## Tablet Scroll Mode
tablet_scroll_mode(){
if [ -f /tmp/wacomscript-$tablet_model-scroll_mode-token-mode2 ]; then
# This will put the scroll wheel in Mode 2
echo ""
echo "Switching Scroll Wheel to $scrollwheelmode2"
xsetwacom set "$tabletpad" AbsWheelUp "$scrollwheelup2"
xsetwacom set "$tabletpad" AbsWheelDown "$scrollwheeldown2"
echo ""
echo "AbsWheelUp set to $scrollwheelup2"
echo "AbsWheelDown set to $scrollwheeldown2"
echo ""
echo "-----------------------------------------"
tablet_notify "Scroll Wheel set to $scrollwheelmode2"
rm /tmp/wacomscript-$tablet_model-scroll_mode-token-mode2
touch /tmp/wacomscript-$tablet_model-scroll_mode-token-mode3
elif [ -f /tmp/wacomscript-$tablet_model-scroll_mode-token-mode3 ]; then
# This will put the scroll wheel in Mode 3
echo ""
echo "Switching Scroll Wheel to $scrollwheelmode3"
xsetwacom set "$tabletpad" AbsWheelUp "$scrollwheelup3"
xsetwacom set "$tabletpad" AbsWheelDown "$scrollwheeldown3"
echo ""
echo "AbsWheelUp set to $scrollwheelup3"
echo "AbsWheelDown set to $scrollwheeldown3"
echo ""
echo "-----------------------------------------"
tablet_notify "Scroll Wheel set to $scrollwheelmode3"
rm /tmp/wacomscript-$tablet_model-scroll_mode-token-mode3
touch /tmp/wacomscript-$tablet_model-scroll_mode-token-mode4
elif [ -f /tmp/wacomscript-$tablet_model-scroll_mode-token-mode4 ]; then
# This will put the scroll wheel in Mode 4
echo ""
echo "Swtiching Scroll Wheel to $scrollwheelmode4"
xsetwacom set "$tabletpad" AbsWheelUp "$scrollwheelup4"
xsetwacom set "$tabletpad" AbsWheelDown "$scrollwheeldown4"
echo ""
echo "AbsWheelUp set to $scrollwheelup4"
echo "AbsWheelDown set to $scrollwheeldown4"
echo ""
echo "-----------------------------------------"
tablet_notify "Scroll Wheel set to $scrollwheelmode4"
rm /tmp/wacomscript-$tablet_model-scroll_mode-token-mode4
else
# This will put the scroll wheel in Mode 1
echo "Switching Scroll Wheel to $scrollwheelmode1"
xsetwacom set "$tabletpad" AbsWheelUp "$scrollwheelup1"
xsetwacom set "$tabletpad" AbsWheelDown "$scrollwheeldown1"
echo ""
echo "AbsWheelUp: $scrollwheelup1"
echo "AbsWheelDown: $scrollwheeldown1"
echo ""
echo "-----------------------------------------"
tablet_notify "Scroll Wheel set to $scrollwheelmode1"
touch /tmp/wacomscript-$tablet_model-scroll_mode-token-mode2
fi
}
## Tablet accurate Mode
# This mode will only work on the Display selected.
tablet_precision_mode(){
# Tablet
xsetwacom --set "$tabletstylus" ResetArea
xsetwacom --set "$tableteraser" ResetArea
fulltabletarea=`xsetwacom get "$tabletstylus" Area | grep "[0-9]\+ [0-9]\+$" -o`
Xtabletmaxarea=`echo $fulltabletarea | grep "^[0-9]\+" -o`
Ytabletmaxarea=`echo $fulltabletarea | grep "[0-9]\+$" -o`
# Screen
if [ -f /tmp/wacomscript-$tablet_model-display-token ] || [ "$secondary" = "NONE" ]; then
#sceenname
screenname="$primaryname"
#display size
Xscreenpix=$(echo "$primarysize" | cut -d 'x' -f 1)
Yscreenpix=$(echo "$primarysize" | cut -d 'x' -f 2)
#display location
Xscreenoffsetpix=$(echo "$primarylocation" | cut -d '+' -f 1)
Yscreenoffsetpix=$(echo "$primarylocation" | cut -d '+' -f 2)
else
#screenname
screenname="$secondaryname"
#display size
Xscreenpix=$(echo "$secondarysize" | cut -d 'x' -f 1)
Yscreenpix=$(echo "$secondarysize" | cut -d 'x' -f 2)
#display location
Xscreenoffsetpix=$(echo "$secondarylocation" | cut -d '+' -f 1)
Yscreenoffsetpix=$(echo "$secondarylocation" | cut -d '+' -f 2)
fi
screenPPI=$(xdpyinfo | grep dots | awk '{print $2}' | awk -Fx '{print $1}')
XscreenPPI=$(bc <<< "scale = 2; $Xscreenpix / $screenPPI")
YscreenPPI=$(bc <<< "scale = 2; $Yscreenpix / $screenPPI")
XscreenCM=$(bc <<< "scale = 0; $Xscreenpix * 0.0254")
YscreenCM=$(bc <<< "scale = 0; $Yscreenpix * 0.0254")
# Precise Mode + Ratio
Ytabletmaxarearatiosized=$(bc <<< "scale = 0; $Yscreenpix * $Xtabletmaxarea / $Xscreenpix")
XtabletactiveareaPIX=$(bc <<< "scale = 0; $XtabletactiveareaCM * $screenPPI / 2.54 * $correctionscalefactor")
YtabletactiveareaPIX=$(bc <<< "scale = 0; $YtabletactiveareaCM * $screenPPI / 2.54 * $correctionscalefactor")
XtabletactiveareaPIX=$(bc <<< "scale = 0; ($XtabletactiveareaPIX + 0.5) / 1")
YtabletactiveareaPIX=$(bc <<< "scale = 0; ($YtabletactiveareaPIX + 0.5) / 1")
XOffsettabletactiveareaPIX=$(bc <<< "scale = 0; ($Xscreenpix - $XtabletactiveareaPIX) / 2 + $Xscreenoffsetpix")
YOffsettabletactiveareaPIX=$(bc <<< "scale = 0; ($Yscreenpix - $YtabletactiveareaPIX) / 2 + $Yscreenoffsetpix")
echo ""
echo "Percision Mode Information:"
echo "Tablet size (cm) :" "$XtabletactiveareaCM" x "$YtabletactiveareaCM"
echo "Screen size (px) :" "$Xscreenpix" x "$Yscreenpix"
echo "Screen size (cm) :" "$XscreenCM" x "$YscreenCM"
echo "Screen ppi :" "$screenPPI"
echo "Correction factor :" "$correctionscalefactor"
echo "Maximum tablet-Area (Wacom unit):" "$Xtabletmaxarea" x "$Ytabletmaxarea"
echo "Precision-mode area (px):" "$XtabletactiveareaPIX" x "$YtabletactiveareaPIX"
echo "Precision-mode offset (px):" "$XOffsettabletactiveareaPIX" x "$YOffsettabletactiveareaPIX"
echo ""
echo "-----------------------------------------"
if [ -f /tmp/wacomscript-$tablet_model-percision_mode-token ]; then
# Here Precision mode; full tablet area in cm are 1:1 on a portion of the screen.
echo ""
echo "Area Precision Mode on $screenname"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Area 0 0 "$Xtabletmaxarea" "$Ytabletmaxarea"
xsetwacom set "$tableteraser" Area 0 0 "$Xtabletmaxarea" "$Ytabletmaxarea"
xsetwacom set "$tabletstylus" MapToOutput "$XtabletactiveareaPIX"x"$YtabletactiveareaPIX"+"$XOffsettabletactiveareaPIX"+"$YOffsettabletactiveareaPIX"
xsetwacom set "$tabletstylus" MapToOutput "$XtabletactiveareaPIX"x"$YtabletactiveareaPIX"+"$XOffsettabletactiveareaPIX"+"$YOffsettabletactiveareaPIX"
tablet_notify "Area Percision Mode on $screenname"
rm -fv /tmp/wacomscript-$tablet_model-percision_mode-token
else
# Here normal mode; tablet map to Fullscreen with ratio correction
echo ""
echo "Area Full Mode on $screenname"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Area 0 0 "$Xtabletmaxarea" "$Ytabletmaxarearatiosized"
xsetwacom set "$tableteraser" Area 0 0 "$Xtabletmaxarea" "$Ytabletmaxarearatiosized"
xsetwacom set "$tabletstylus" MapToOutput "$Xscreenpix"x"$Yscreenpix"+"$Xscreenoffsetpix"+"$Yscreenoffsetpix"
xsetwacom set "$tableteraser" MapToOutput "$Xscreenpix"x"$Yscreenpix"+"$Xscreenoffsetpix"+"$Yscreenoffsetpix"
tablet_notify "Area Normal Mode on $screenname"
touch /tmp/wacomscript-$tablet_model-percision_mode-token
fi
}
## Enable or Disable Touch
# NOTE: Had to use xinput cause xsetwacom didn't have the touch listed when --list devices was called.
# I did commment out the old commands so you can swtich them if that happens.
tablet_touch_mode(){
if [ -f /tmp/wacomscript-$tablet_model-touch_mode-token ]; then
echo ""
echo "Disabling Touch on $tablettouch"
echo ""
echo "-----------------------------------------"
xinput disable "$tablettouch"
#xsetwacom set "$tablettouch" Touch "off"
tablet_notify "Touch Diasbled"
rm /tmp/wacomscript-$tablet_model-touch_mode-token
else
echo ""
echo "Enabling Touch on $tablettouch"
echo ""
echo "-----------------------------------------"
xinput enable "$tablettouch"
#xsetwacom set "$tablettouch" Touch "on"
tablet_notify "Touch Enabled"
touch /tmp/wacomscript-$tablet_model-touch_mode-token
fi
}
tablet_pen_mode(){
if [ -f /tmp/wacomscript-$tablet_model-pen_mode-token ]; then
echo ""
echo "Switching to Relative Mode for $tablet_full_name"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Mode "Relative"
tablet_notify "Mode Relative"
rm /tmp/wacomscript-$tablet_model-pen_mode-token
else
echo ""
echo "Switching to Absolute Mode for $tablet_full_name"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Mode "Absolute"
tablet_notify "Mode Absolute"
touch /tmp/wacomscript-$tablet_model-pen_mode-token
fi
}
tablet_flip_mode(){
if [ -f /tmp/wacomscript-$tablet_model-flip_mode-token ]; then
echo ""
echo "Flipping tablet to half on $tablet_full_name"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Rotate "half"
tablet_notify "Rotating Tablet Upsidedown"
rm /tmp/wacomscript-$tablet_model-flip_mode-token
else
echo ""
echo "Flipping tablet to normal mode on $tablet_full_name"
echo ""
echo "-----------------------------------------"
xsetwacom set "$tabletstylus" Rotate "none"
tablet_notify "Rotating Tablet Normal"
touch /tmp/wacomscript-$tablet_model-flip_mode-token
fi
}
## Commandline Processing
case "$1" in
--help)
grep '^#:' $0 | cut -d ':' -f 2-50
exit 0
;;
--display-info)
get_display_info
;;
--tablet-info)
get_tablet_info
;;
--set-all)
get_tablet_info
tablet_delete_tokens
get_display_info
tablet_set_buttons
tablet_display_mode
tablet_scroll_mode
tablet_precision_mode
tablet_touch_mode
tablet_pen_mode
tablet_flip_mode
;;
--set-buttons)
get_tablet_info
tablet_set_buttons
;;
--switch-display)
get_tablet_info
get_display_info
tablet_display_mode
;;
--scroll-mode)
get_tablet_info
tablet_scroll_mode
;;
--percision-switch)
get_tablet_info
get_display_info
tablet_precision_mode
;;
--touch-mode)
get_tablet_info
tablet_touch_mode
;;
--pen-mode)
get_tablet_info
tablet_pen_mode
;;
--flip-tablet)
get_tablet_info
tablet_flip_mode
tablet_set_buttons
;;
*)
grep '^#:' $0 | cut -d ':' -f 2-50
exit 0
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment