You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/usr/bin/env bash
  2. # author: unknown
  3. # sentby: MoreChannelNoise (https://www.youtube.com/user/MoreChannelNoise)
  4. # editby: gotbletu (https://www.youtube.com/user/gotbletu)
  5. # demo: https://www.youtube.com/watch?v=kxJClZIXSnM
  6. # info: this is a script to launch other rofi scripts,
  7. # saves us the trouble of binding multiple hotkeys for each script,
  8. # when we can just use one hotkey for everything.
  9. declare -A LABELS
  10. declare -A COMMANDS
  11. ###
  12. # List of defined 'bangs'
  13. # launch programs
  14. COMMANDS["apps"]="dmenu_run -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee'"
  15. LABELS["apps"]=""
  16. # clipboard
  17. COMMANDS["clipboard"]="greenclip print | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'clipboard: ' | xclip -selection clipboard"
  18. LABELS["clipboard"]=""
  19. # search local files
  20. COMMANDS["emoji"]="~/.bin/dmenu-scripts/dmenu-emoji"
  21. LABELS["emoji"]=""
  22. # mount drives
  23. COMMANDS["mount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount"
  24. LABELS["mount"]=""
  25. # umount drives
  26. COMMANDS["unmount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount unmount"
  27. LABELS["unmount"]=""
  28. # shutdown
  29. COMMANDS["shutdown"]="sudo ~/.bin/dmenu-scripts/dmenu-shutdown"
  30. LABELS["shutdown"]=""
  31. # PDF man pages
  32. COMMANDS["man"]="~/.bin/dmenu-scripts/dmenu-man"
  33. LABELS["man"]=""
  34. # locate files
  35. COMMANDS["locate"]="~/.bin/dmenu-scripts/dmenu-locate"
  36. LABELS["locate"]=""
  37. ################################################################################
  38. # do not edit below
  39. ################################################################################
  40. ##
  41. # Generate menu
  42. ##
  43. function print_menu()
  44. {
  45. for key in ${!LABELS[@]}
  46. do
  47. echo "$key ${LABELS}"
  48. # echo "$key ${LABELS[$key]}"
  49. # my top version just shows the first field in labels row, not two words side by side
  50. done
  51. }
  52. ##
  53. # Show rofi.
  54. ##
  55. function start()
  56. {
  57. print_menu | sort | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#222222" -nf "#bbbbbb" -sb "#005577" -sf "#eeeeee" -p "dmenu bangs: "
  58. }
  59. # Run it
  60. value="$(start)"
  61. # Split input.
  62. # grab upto first space.
  63. choice=${value%%\ *}
  64. # graph remainder, minus space.
  65. input=${value:$((${#choice}+1))}
  66. ##
  67. # Cancelled? bail out
  68. ##
  69. if test -z ${choice}
  70. then
  71. exit
  72. fi
  73. # check if choice exists
  74. if test ${COMMANDS[$choice]+isset}
  75. then
  76. # Execute the choice
  77. eval ${COMMANDS[$choice]}
  78. else
  79. eval $choice | dmenu
  80. fi