My scripts for startup, dmenu, and the command line
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

162 wiersze
3.5 KiB

  1. #!/bin/sh
  2. launch() {
  3. app=$(printf "Notes
  4. Files
  5. Editor
  6. Terminal
  7. Multiplexer
  8. LBRY
  9. Chat
  10. Music
  11. Browser
  12. Email
  13. Processes" | tr -d '\t' |
  14. dmenu -i -p "Launcher")
  15. case $app in
  16. Notes) st -e vim "+cd ~/Notes/text" "+CtrlP";;
  17. Files) st -e nnn;;
  18. Editor) st -e vim;;
  19. Terminal) st;;
  20. Multiplexer) st -e tmux $*;;
  21. LBRY) lbry;;
  22. Chat) element-desktop;;
  23. Music) st -e ncmpcpp;;
  24. Browser) brave-browser;;
  25. Email) brave-browser mail.protonmail.com/login;;
  26. Processes) st -e htop;;
  27. esac
  28. }
  29. action() {
  30. action=$(printf "Play Music
  31. Pause Music
  32. Toggle Music
  33. Command
  34. Command to clipboard
  35. Search github
  36. Search ddg
  37. Select VPN
  38. Disable VPN
  39. Enable VPN
  40. VPN Status
  41. Rebind Keys
  42. Disable Bar
  43. Enable Bar" | tr -d '\t' |
  44. dmenu -i -p "Actions")
  45. case $action in
  46. 'Play Music') mpc play ;;
  47. 'Pause Music') mpc pause ;;
  48. 'Toggle Music') mpc toggle ;;
  49. 'Rebind Keys') setup-xbindkeys;;
  50. 'Disable Bar') tmux set -g status off;;
  51. 'Enable Bar') tmux set -g status on;;
  52. 'Search github') github;;
  53. 'Search ddg') ddg;;
  54. 'Command') cmd;;
  55. 'Command to clipboard') cmd_clip;;
  56. esac
  57. }
  58. screenshot() {
  59. method=$(printf "clipboard
  60. file
  61. both" |
  62. dmenu -i -p "Screenshot")
  63. if [ $method = "file" ]; then
  64. scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
  65. -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png
  66. fi
  67. if [ $method = "clipboard" ]; then
  68. scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
  69. -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
  70. -e "xclip $f; rm $f"
  71. fi
  72. if [ $method = "both" ]; then
  73. scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
  74. -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
  75. -e "xclip $f;"
  76. fi
  77. }
  78. search_type() {
  79. search_string="$(printf "New window\nBookmarks\nHistory" | dmenu -p "ddg")"
  80. search_mode='tab'
  81. case "$search_string" in
  82. 'New window') search_mode='window'; search_string=$(printf '' | dmenu -p 'new ddg');;
  83. 'Bookmarks');;
  84. 'History') ;;
  85. # *) printf "Invalid argument";;
  86. esac
  87. printf "$search_string|$search_mode"
  88. }
  89. brave_search() {
  90. search_prefix="$1"
  91. search_info="$(search_type)"
  92. search_string=$(printf "$search_info" | cut -d'|' -f1)
  93. search_mode=$(printf "$search_info" | cut -d'|' -f2)
  94. if [ -z "$search_string" ]; then exit; fi
  95. new_string=$(rawurlencode "$search_string")
  96. search="$search_prefix$new_string"
  97. case "$search_mode" in
  98. tab) brave-browser "$search";;
  99. window) brave-browser --new-window "$search";;
  100. esac
  101. }
  102. rawurlencode() {
  103. #Takes the first argument and encodes it
  104. search_string="$1"
  105. string_length=$(expr length "$search_string")
  106. char=''; new_string='';
  107. i=1
  108. while [ $i -le $string_length ]
  109. do
  110. char=$(expr substr "$search_string" $i 1)
  111. # new_string="$new_string$(rawurlencode "$char")"
  112. case "$char" in
  113. [-_.~a-zA-Z0-9] ) new_string="$new_string$char";;
  114. * ) new_string="$new_string%$(printf '%%%02x' "'$char")";;
  115. esac
  116. i=$(expr $i + 1)
  117. done
  118. printf "$new_string"
  119. }
  120. ddg() {
  121. brave_search "https://duckduckgo.com/?q="
  122. }
  123. github() {
  124. brave_search "https://github.com/search?q="
  125. }
  126. cmd() {
  127. sh -c "$(printf '' | dmenu -i -p 'cmd')"
  128. }
  129. cmd_clip() {
  130. value=$(cmd)
  131. show_value="$(expr substr "$value" 1 200)\n..."
  132. notify-send -u low -t 2000 "Items cliped" "$show_value"
  133. printf "%s" "$value" | xclip -selection clipboard
  134. }
  135. case $1 in
  136. launch) launch;;
  137. action) action;;
  138. cmd) action;;
  139. cmd_clip) cmd_clip;;
  140. ddg) brave_search "https://duckduckgo.com/?q=";;
  141. github) brave_search "https://github.com/search?q=";;
  142. *) printf "Invalid argument";;
  143. esac