m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/wacom
blob: 3c7fa96749a13d2f59f4b6dbc09d3dfea38e264a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

# Helper script for setting up a wacom tablet.
# USAGE: wacom [-r] [-c <config>]
# FLAGS:
#   -r: rotate the board's input 180°, useful if using the board upside down to
#   its assumed usage orientation.
#   -c: uses one of the hardcoded configurations for stylus button bindings.
# NOTE:
#   The configs are currently hardcoded for my personal preferences in several
#   programs/websites for the One by Wacom tablet.
# CONFIGS:
#   aww: (obsolete) for the AWW shared whiteboard.
#   krita: the Krita drawing program.
#   miro: for the Miro shared whiteboard.

ID=`xsetwacom list devices | awk '/stylus/ { print $8 }'`

function rotate {
    xsetwacom set $ID Rotate half
}

# AWW board, eraser + pencil
function set_aww {
    xsetwacom set $ID Button 2 "key e"
    xsetwacom set $ID Button 3 "key p"
}

# Krita - right click (tags wheel), middle click (pan)
function set_krita {
    xsetwacom set $ID Button 2 "button +2"
    xsetwacom set $ID Button 3 "button 3"
}

function set_miro {
    xsetwacom set $ID Button 2 "key v"
    xsetwacom set $ID Button 3 "key p"
}

function set_config {
    case "$1" in
        aww) set_aww ;;
        krita) set_krita ;;
        miro) set_miro ;;
        *) echo "Unexpected config \"$1\""; exit 1 ;;
    esac
}

while getopts 'rc:' flag; do
  case "${flag}" in
    r) rotate ;;
    c) set_config $OPTARG ;;
    *) error "Unexpected option ${flag}" ;;
  esac
done