My scripts for startup, dmenu, and the command line
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

139 行
2.9 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 '\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. Select VPN
  36. Disable VPN
  37. Enable VPN
  38. VPN Status
  39. Rebind Keys
  40. Disable Bar
  41. Enable Bar" | tr -d '\t' |
  42. dmenu -i -p "Actions")
  43. case $action in
  44. 'Play Music') mpc play ;;
  45. 'Pause Music') mpc pause ;;
  46. 'Toggle Music') mpc toggle ;;
  47. 'Rebind Keys') setup-xbindkeys;;
  48. 'Disable Bar') tmux set -g status off;;
  49. 'Enable Bar') tmux set -g status on;;
  50. 'Command') cmd;;
  51. 'Command to clipboard') cmd_clip;;
  52. esac
  53. }
  54. screenshot() {
  55. method=$(printf "clipboard
  56. file
  57. both" |
  58. dmenu -i -p "Screenshot")
  59. if [ $method = "file" ]; then
  60. scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
  61. -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png
  62. fi
  63. if [ $method = "clipboard" ]; 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. -e "xclip $f; rm $f"
  67. fi
  68. if [ $method = "both" ]; then
  69. scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
  70. -s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
  71. -e "xclip $f;"
  72. fi
  73. }
  74. ddg() {
  75. search_string="$(printf "New window\nBookmarks\nHistory" | dmenu -p "ddg")"
  76. search_mode='tab'
  77. case "$search_string" in
  78. 'New window') search_mode='window'; search_string=$(printf '' | dmenu -p 'new ddg');;
  79. 'Bookmarks');;
  80. 'History') ;;
  81. *) printf "Invalid argument";;
  82. esac
  83. string_length=$(expr length "$search_string")
  84. char=''; new_string='';
  85. i=1
  86. while [ $i -le $string_length ]
  87. do
  88. char=$(expr substr "$search_string" $i 1)
  89. new_string="$new_string$(rawurlencode "$char")"
  90. # printf "this is newstring %s\n" "$new_string"
  91. i=$(expr $i + 1)
  92. done
  93. search="https://duckduckgo.com/?q=$new_string"
  94. case "$search_mode" in
  95. tab) brave-browser "$search";;
  96. window) brave-browser --new-window "$search";;
  97. esac
  98. }
  99. rawurlencode() {
  100. case "$1" in
  101. [-_.~a-zA-Z0-9] ) result=$1; printf $result;;
  102. * ) result=$(printf '%%%02x' "'$1"); printf %$result;;
  103. esac
  104. }
  105. cmd() {
  106. sh -c "$(printf '' | dmenu -i -p 'cmd')"
  107. }
  108. cmd_clip() {
  109. value=$(cmd)
  110. show_value="$(expr substr "$value" 1 200)\n..."
  111. notify-send -u low -t 2000 "Items cliped" "$show_value"
  112. printf "%s" "$value" | xclip -selection clipboard
  113. }
  114. case $1 in
  115. launch) launch;;
  116. action) action;;
  117. cmd) action;;
  118. cmd_clip) cmd_clip;;
  119. ddg) ddg;;
  120. *) printf "Invalid argument";;
  121. esac