Last active
December 19, 2015 15:59
-
-
Save tarao/5980290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /usr/local/sbin/hotplug | |
# sysctl -w kernel.hotplug=/usr/local/sbin/hotplug | |
dir=/usr/local/etc/hotplug | |
for script in `ls -1 "$dir"/*`; do | |
[ -x "$script" ] && ( "$script" >/dev/null 2>&1 ) & | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# /usr/local/etc/wacom-disable-touch.sh | |
log=/var/log/hotplug.log | |
internal='eDP1' | |
display='127.0.0.1:0' | |
wacom_device='Wacom ISD' | |
touch_device='Atmel maXTouch' | |
[ "x$1" = 'x-v' ] || log=/dev/null # silent unless -v | |
log() { | |
echo "$@" >> "$log" | |
} | |
xsetwacom() { | |
DISPLAY="$display" command xsetwacom "$@" | |
} | |
is_wacom_active() { | |
xsetwacom list devices | grep "$wacom_device" >/dev/null || return 1 | |
} | |
xinput() { | |
DISPLAY="$display" command xinput "$@" | |
} | |
touch_device() { | |
xinput --list | grep "$touch_device" | sed 's/^.*id=\([0-9]\+\).*$/\1/' || return 1 | |
} | |
touch_enable() { | |
id=`touch_device` | |
[ -n "$id" ] && { | |
xinput --enable "$id" | |
log "[wacom] enable device $id" | |
} | |
} | |
touch_disable() { | |
id=`touch_device` | |
[ -n "$id" ] && { | |
xinput --disable "$id" | |
log "[wacom] disable device $id" | |
} | |
} | |
update() { | |
[ -z "$INTERFACE" ] && return | |
is_wacom_active && { | |
touch_disable | |
return | |
} | |
touch_enable | |
} | |
log "[$ACTION][$TYPE][$INTERFACE][$PRODUCT]\n$DEVPATH" | |
case "$ACTION" in | |
add|remove) | |
( sleep 1; update ) & | |
;; | |
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /usr/local/etc/wacom-rotation.sh | |
log=/var/log/hotplug.log | |
internal='eDP1' | |
display='127.0.0.1:0' | |
wacom_device='Wacom ISD' | |
[ "x$1" = 'x-v' ] || log=/dev/null # silent unless -v | |
log() { | |
echo "$@" >> "$log" | |
} | |
xrandr() { | |
DISPLAY="$display" command xrandr "$@" | |
} | |
xsetwacom() { | |
DISPLAY="$display" command xsetwacom "$@" | |
} | |
list_wacom_devices() { | |
xsetwacom list devices | grep "$wacom_device" | sed 's/[ \t]*id: .*//' | |
} | |
current_rotation() { | |
xrandr --verbose -q | grep "$internal" | grep 'connected' | cut -f 5 -d ' ' | |
} | |
update_wacom() { | |
[ -z "$INTERFACE" ] && return | |
case `current_rotation` in | |
normal) | |
rotation=none | |
;; | |
right) | |
rotation=cw | |
;; | |
inverted) | |
rotation=half | |
;; | |
left) | |
rotation=ccw | |
esac | |
[ -z "$rotation" ] && return | |
list_wacom_devices | while read device; do | |
xsetwacom set "$device" Rotate "$rotation" >> "$log" 2>&1 | |
xsetwacom set "$device" MapToOutput "$internal" >> "$log" 2>&1 | |
log "[wacom] device="$device" rotation=$rotation" | |
done | |
} | |
log "[$ACTION][$TYPE][$INTERFACE][$PRODUCT]\n$DEVPATH" | |
case "$ACTION" in | |
add) | |
update_wacom | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment