tdock.sh 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # Ref: https://feeding.cloud.geek.nz/posts/hooking-into-docking-undocking-events-to-run-scripts/
  3. function usage {
  4. echo "tdock <install|dock|undock>"
  5. exit 0
  6. }
  7. function install {
  8. echo "[+] installing tdock..."
  9. echo "[*] Info: this tool requires sudo access at some point"
  10. if [ -d "/opt/tdock" ]; then
  11. echo "[-] tdock is already installed (remove /opt/tdock)"
  12. exit 1
  13. fi
  14. # Bash allows not whitespaces infront :/
  15. cat <<- EOF > /tmp/dock.txt
  16. event=ibm/hotkey LEN0068:00 00000080 00006030
  17. action=su $(whoami) -c "/opt/tdock/tdock.sh dock"
  18. EOF
  19. # Bash allows not whitespaces infront :/
  20. cat <<- EOF > /tmp/undock.txt
  21. event=ibm/hotkey LEN0068:00 00000080 00004011
  22. action=su $(whoami) -c "/opt/tdock/tdock.sh undock"
  23. EOF
  24. }
  25. # having the wrong number of arguments
  26. if [ "$#" -ne 1 ]; then
  27. usage
  28. fi
  29. if [ "$1" = "install" ]; then
  30. install
  31. elif [ "$1" = "dock" ]; then
  32. dock
  33. elif [ "$1" = "undock" ]; then
  34. undock
  35. fi