hid-commands 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. set -e
  3. LAST_APPSEL_START=0
  4. cmd_wm () {
  5. WIN="$(xdotool getactivewindow)"
  6. wmctrl -i -r ${WIN} -b remove,maximized_vert,maximized_horz
  7. xdotool windowsize ${WIN} 100% 100%
  8. wmctrl -i -r ${WIN} -b add,maximized_vert,maximized_horz
  9. }
  10. cmd_appsel_helper () {
  11. rofi -show window
  12. }
  13. _cmd_appsel () {
  14. wmctrl -x -a $1 || true
  15. xdotool key Escape
  16. }
  17. cmd_appsel_music () {
  18. wmctrl -x -a rhythmbox || wmctrl -x -a spotify || \
  19. wmctrl -x -a banshee || wmctrl -x -a kodi || \
  20. wmctrl -x -a plex || true
  21. xdotool key Escape
  22. }
  23. cmd_appsel_slack () {
  24. wmctrl -x -a slack || wmctrl -x -a Mstdn || true
  25. xdotool key Escape
  26. }
  27. cmd_appsel_emacs () {
  28. _cmd_appsel emacs
  29. }
  30. cmd_appsel_term () {
  31. _cmd_appsel gnome-terminal
  32. }
  33. cmd_appsel_chrome () {
  34. wmctrl -x -a chrom || wmctrl -x -a Chrome || true
  35. xdotool key Escape
  36. }
  37. cmd_appsel_start () {
  38. if [ ! -z "${DISABLE_APPSEL_START}" ]; then
  39. return
  40. fi
  41. APPSEL_START=$(date +%s)
  42. if [ $APPSEL_START -lt $(expr $LAST_APPSEL_START + 10) ]; then
  43. return
  44. fi
  45. LAST_APPSEL_START=$APPSEL_START
  46. notify-send -t 1000 "Please select an application!" -c device -u low \
  47. -i /usr/share/icons/Adwaita/24x24/devices/video-display.png
  48. }
  49. cmd_appsel_social () {
  50. # Save the current window
  51. a=$(xdotool getactivewindow)
  52. # Raise & Focus Mstdn & Tweetdeck
  53. wmctrl -x -a trunk.mad-scientist.club.Google-chrome || true; wmctrl -x -a tweetdeck || true
  54. # Focus the previously active window
  55. xdotool windowfocus $a || true; xdotool windowactivate $a || true
  56. xdotool key Escape
  57. }
  58. cmd_appsel_social2 () {
  59. # Save the current window
  60. a=$(xdotool getactivewindow)
  61. # Raise & Focus Viber & Signal
  62. wmctrl -x -a Viber || true; wmctrl -a Signal || true
  63. # Focus the previously active window
  64. xdotool windowfocus $a || true; xdotool windowactivate $a || true
  65. xdotool key Escape
  66. }
  67. cmd_appsel_pwmgr () {
  68. _cmd_appsel keepass
  69. }
  70. cmd_reflash () {
  71. teensy_loader_cli -v -w ~/src/ext/qmk_firmware/algernon.hex --mcu atmega32u4 || true
  72. }
  73. cmd_help () {
  74. cat <<EOF
  75. Use the source, Luke!
  76. EOF
  77. }
  78. while read l; do
  79. case "$l" in
  80. "CMD:"*)
  81. ;;
  82. *)
  83. continue
  84. ;;
  85. esac
  86. cmd="$(echo $l | cut -d: -f2-)"
  87. echo "Got command: ${cmd}"
  88. if type cmd_${cmd} >/dev/null 2>&1; then
  89. cmd_${cmd}
  90. fi
  91. done