slack.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # -----------------------------------------------------------------------------
  3. # Info:
  4. # author: Colin Powell
  5. # file: slack.sh
  6. # created: 20.03.2020
  7. # revision: ---
  8. # version: 1.0
  9. # -----------------------------------------------------------------------------
  10. # Requirements:
  11. # rofi
  12. # Description:
  13. # Use rofi to update slack
  14. # Usage:
  15. # slack.sh
  16. # -----------------------------------------------------------------------------
  17. # Script:
  18. declare -A OPTIONS
  19. OPTIONS=(
  20. ["set status"]="slack status edit "
  21. ["clear status"]="slack status edit "
  22. ["set away"]="slack presence away"
  23. ["set available"]="slack presence active"
  24. )
  25. # List for rofi
  26. gen_list() {
  27. for i in "${!OPTIONS[@]}"
  28. do
  29. echo "$i"
  30. done
  31. }
  32. main() {
  33. # Pass the list to rofi
  34. platform=$( (gen_list) | rofi -dmenu -matching fuzzy -no-custom -location 0 -p "Command -> " )
  35. if [[ -n "$platform" ]]; then
  36. query=$( (echo ) | rofi -dmenu -matching fuzzy -location 0 -p "Input -> " )
  37. if [[ -n "$query" ]]; then
  38. option=${OPTIONS[$platform]}$query
  39. eval "$option"
  40. else
  41. exit
  42. fi
  43. else
  44. exit
  45. fi
  46. }
  47. main
  48. exit 0