fork download
  1. #!/bin/bash
  2. id_re='id:[[:space:]]*([[:digit:]]+)' # assign regex to variable
  3. stylus_ids=( ) # make an empty array to store ids in
  4.  
  5. while IFS= read -r line; do
  6. [[ $line = *stylus* ]] || continue # skip lines without "stylus"
  7. [[ $line =~ $id_re ]] || continue # match against regex, or skip the line otherwise
  8. stylus_id=${BASH_REMATCH[1]} # take the match group from the regex
  9. echo "# Command for line $line"
  10. printf '%q ' xsetwacom --set "$stylus_id" area 123 123 123 123 </dev/null; echo
  11. echo
  12. done
  13.  
Success #stdin #stdout 0s 19664KB
stdin
Wacom Bamboo 2FG 4x5 Pad pad          id: 21   type: PAD
Wacom Bamboo 2FG 4x5 Ped stylus       id: 22   type: STYLUS
Wacom Bamboo 2FG 4x5 Pen eraser       id: 23   type: ERASER
Wacom Bamboo 2FG 4x5 Finger touch     id: 24   type: TOUCH

Wacom Intuos S Pad pad                id: 21   type: PAD
Wacom Intuos S Pen stylus             id: 22   type: STYLUS
Wacom Intuos S Pen eraser             id: 23   type: ERASER
stdout
# Command for line Wacom Bamboo 2FG 4x5 Ped stylus       id: 22   type: STYLUS
xsetwacom --set 22 area 123 123 123 123 

# Command for line Wacom Intuos S Pen stylus             id: 22   type: STYLUS
xsetwacom --set 22 area 123 123 123 123