#!/bin/sh # License : GPLv3 # Variables that change behaviour SLOP_CURRENT_WINDOW=false EXIT_ON_RESET=false # Arg parsing while [ "$1" ]; do case "$1" in -h|--help) echo "Usage: $0 [current|reset] [= ..]" echo " current skip window selection (useful for keybinding)" echo " reset reset zone to draw to fullscreen" echo " = add settings applyable to xsetwacom (val can be empty)" echo "Examples :" echo " $0 current # select the rectangle zone to draw" echo " $0 reset mode=relative # reset the zone to draw and apply mode relative" exit 0 ;; debug) set -x ;; current) SLOP_CURRENT_WINDOW=true ;; reset) EXIT_ON_RESET=true ;; *=*) OTHER_SETTINGS="${OTHER_SETTINGS} $1" ;; esac shift done PENTABLET_LIST="$(xsetwacom --list | sed 's/^.*\sid:\s*//;s/\s*type:.*//')" PENTABLET_ID=$(echo $PENTABLET_LIST | cut -d' ' -f1) _xsetwacom(){ for dev in $PENTABLET_LIST; do xsetwacom set $dev $* done } #reset and apply other settings _xsetwacom MapToOutput $(xwininfo -root | sed -n 's/.*geometry//p') for i in $OTHER_SETTINGS; do _xsetwacom $(echo "$i" | tr '=' ' ') done if $EXIT_ON_RESET; then exit 0 fi #get tablet size _setup_tablet_area_vars() { DEFAULT_W=$3 DEFAULT_H=$4 } _setup_tablet_area_vars $(xsetwacom get ${PENTABLET_ID} area) # select the window if ! $SLOP_CURRENT_WINDOW; then xmessage -timeout 2 -default "Setting Screen Area" -buttons "" "Select window with Alt-Tab and click on it" & xwininfo 2> /dev/null 1>&2 # only to select the right window fi # select the area xmessage -timeout 2 -default "Setting Screen Area" -buttons "" "Select region" & _ret=$(slop -f '%w %x %y') if [ -n "${_ret}" ] ; then # setup the draw rect _xsetwacom mode absolute _set_draw_rect(){ _w=$1 _x=$2 _y=$3 _h=$(( _w * DEFAULT_H / DEFAULT_W )) _xsetwacom MapToOutput "${_w}x${_h}+${_x}+${_y}" } _set_draw_rect $_ret fi