Created
June 1, 2020 20:54
-
-
Save jigpu/1fad061de7e84c2a1ee3208e1a971342 to your computer and use it in GitHub Desktop.
Wacom Autoconfig on Hotplug
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/bash | |
| # Usage: | |
| # xorg-hotplug.sh [device] | |
| # | |
| # device - Name of an Xorg device to configure. | |
| # | |
| # xorg-hotplug should be added to your window manager's list of startup programs. If | |
| # run with no arguments, it will sit in the background monitoring for hotplug events | |
| # by monitoring the Xorg log file. When a new device is connected, it will automatically | |
| # launch a new instance of itself with the name of the deivce to handle configuration. | |
| # | |
| # The bottom half of this script should be customized to change the list of devices that | |
| # it recognizes and the commands that get run in response. | |
| # If run without arguments, monitor for xorg hotplug events | |
| if [[ $# -eq 0 ]]; then | |
| CMD=$(readlink -e "$0") | |
| DPY=${DISPLAY#:} | |
| [[ -f "$LOG" ]] || LOG=~/.local/share/xorg/Xorg.${DPY}.log | |
| [[ -f "$LOG" ]] || LOG=/var/log/Xorg.${DPY}.log | |
| [[ -f "$LOG" ]] || exit 1 | |
| AWKPROG=$(cat <<'EOF' | |
| /XINPUT: Adding extended input device/ { | |
| DEVICE=$2 | |
| if (length(DEVICE) > 0) { | |
| print "Hotplugging " DEVICE; | |
| system("\""CMD"\" \""DEVICE"\""); | |
| } | |
| } | |
| EOF | |
| ) | |
| echo "Monitoring for hotplug events from ${LOG}" | |
| tail -f -n +1 "${LOG}" | awk -vFS=\" -vCMD="${CMD}" "${AWKPROG}" | |
| exit 0 | |
| fi | |
| # If run with arguments, set up the specified device | |
| DEVICE=$1 | |
| echo "Configuring ${DEVICE}" | |
| case "${DEVICE}" in | |
| "Wacom Cintiq 24HD touch Pen stylus") | |
| xsetwacom set "${DEVICE}" maptooutput DVI-I-2 | |
| # Other | |
| # Commands | |
| # Go | |
| # Here | |
| ;; | |
| "Wacom Cintiq 24HD touch Pen eraser") | |
| xsetwacom set "${DEVICE}" maptooutput DVI-I-2 | |
| # Other | |
| # Commands | |
| # Go | |
| # Here | |
| ;; | |
| "Wacom Cintiq 24HD touch Finger touch") | |
| xsetwacom set "${DEVICE}" maptooutput DVI-I-2 | |
| # Other | |
| # Commands | |
| # Go | |
| # Here | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment