keys.lisp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. ;;; keys.lisp --- Key bindings (Dvorak layout)
  2. ;; Copyright © 2013–2017 Alex Kost <alezost@gmail.com>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;;
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (in-package :stumpwm)
  17. (set-prefix-key (kbd "s-t"))
  18. ;;; Functional/additional keys (placed on the same keys)
  19. (defvar al/f-keys-alist
  20. '(("F1" . "Help")
  21. ("F2" . "SunUndo")
  22. ("F3" . "SunAgain")
  23. ("F4" . "XF86New")
  24. ("F5" . "XF86Open")
  25. ("F6" . "XF86Close")
  26. ("F7" . "XF86Reply")
  27. ("F8" . "XF86Forward")
  28. ("F9" . "XF86Send")
  29. ("F10" . "XF86Spell")
  30. ("F11" . "XF86Save")
  31. ("F12" . "SunPrint_Screen"))
  32. "Alist of functional and additional keys bound to the same commands.")
  33. (defun al/define-key (map key command)
  34. "Similar to `define-key', except KEY should be a string.
  35. If KEY is a functional key from `al/f-keys-alist', bind COMMAND to the
  36. additional key."
  37. (define-key map (kbd key) command)
  38. (let ((add-key (cdr (assoc key al/f-keys-alist :test 'equal))))
  39. (when add-key
  40. (define-key map (kbd add-key) command))))
  41. ;; Bind "H-<key>" to sending <key> to the current window
  42. ;; (<key> is a key from `al/f-keys-alist').
  43. (dolist (key-assoc al/f-keys-alist)
  44. (let ((fun-key (car key-assoc))
  45. (add-key (cdr key-assoc)))
  46. (flet ((dk (bound-key sent-key)
  47. (define-key *top-map*
  48. (kbd (concat "H-" bound-key))
  49. (concat "al/send-key " sent-key))))
  50. (dk fun-key fun-key)
  51. (dk add-key fun-key))))
  52. ;;; Managing windows, frames & groups
  53. (al/define-key *root-map* "F" "fselect")
  54. (al/define-key *root-map* "=" "balance-frames")
  55. (al/define-key *root-map* "s-c" "delete-window")
  56. (al/define-key *root-map* "C" "kill-window")
  57. (al/define-key *root-map* "o" "al/fother")
  58. (al/define-key *root-map* "M-o" "fnext")
  59. (al/define-key *top-map* "s-r" "al/toggle-root")
  60. (al/define-key *top-map* "s-w" "windowlist")
  61. (al/define-key *top-map* "M-s-w" "vgroups")
  62. (al/define-key *top-map* "M-s-g" "grouplist")
  63. (al/define-key *top-map* "H-o" "al/other H-o")
  64. (al/define-key *top-map* "H-M-o" "al/next H-M-o")
  65. (al/define-key *top-map* "s-H-o" "al/toggle-ignore-emacs")
  66. (al/define-key *top-map* "s-n" "gother")
  67. (al/define-key *top-map* "M-s-n" "al/gmove-to-other-group")
  68. (al/define-key *tile-group-root-map* "s-f" "fullscreen")
  69. (al/define-key *tile-group-top-map* "s-z" "hsplit")
  70. (al/define-key *tile-group-top-map* "M-s-z" "vsplit")
  71. (al/define-key *tile-group-top-map* "s-x" "only")
  72. ;;; Focusing windows
  73. (al/define-key *tile-group-top-map* "s-b" "pull-hidden-other")
  74. (al/define-key *tile-group-top-map* "M-s-b" "pull-hidden-next")
  75. (al/define-key *tile-group-top-map* "s-TAB" "pull-hidden-next")
  76. (al/define-key *tile-group-top-map* "s-ISO_Left_Tab" "pull-hidden-previous")
  77. (al/define-key *float-group-top-map* "s-b" "al/float-window-other")
  78. (al/define-key *float-group-top-map* "M-s-b" "al/float-window-next")
  79. (al/define-key *float-group-top-map* "s-TAB" "al/float-window-next")
  80. (al/define-key *float-group-top-map* "s-ISO_Left_Tab" "al/float-window-previous")
  81. ;;; Moving/resizing windows
  82. ;; Use numpad keys for manipulating windows:
  83. ;; [C-]M-<key> for resizing
  84. ;; [C-]s-<key> for moving
  85. ;; C-<key> for moving to the screen edges
  86. (al/define-key *float-group-top-map*
  87. "s-KP_Begin" "al/float-window-gravity center")
  88. (defun al/define-numpad-key-xy (map modifier cmd val)
  89. (flet ((dk (key x y)
  90. (define-key map (kbd (concat modifier key))
  91. (format nil "~a ~D ~D" cmd x y))))
  92. (dk "KP_Home" (- val) (- val))
  93. (dk "KP_Up" 0 (- val))
  94. (dk "KP_Page_Up" val (- val))
  95. (dk "KP_Right" val 0)
  96. (dk "KP_Page_Down" val val)
  97. (dk "KP_Down" 0 val)
  98. (dk "KP_End" (- val) val)
  99. (dk "KP_Left" (- val) 0)))
  100. (al/define-numpad-key-xy *float-group-top-map* "s-" "al/move-float-window" 10)
  101. (al/define-numpad-key-xy *float-group-top-map* "C-s-" "al/move-float-window" 1)
  102. (al/define-numpad-key-xy *float-group-top-map* "M-" "al/resize-float-window" 10)
  103. (al/define-numpad-key-xy *float-group-top-map* "C-M-" "al/resize-float-window" 1)
  104. (defun al/define-numpad-key-gravity (map modifier cmd)
  105. (flet ((dk (key gravity)
  106. (define-key map (kbd (concat modifier key))
  107. (format nil "~a ~a" cmd gravity))))
  108. (dk "KP_Begin" "center")
  109. (dk "KP_Home" "top-left")
  110. (dk "KP_Up" "top")
  111. (dk "KP_Page_Up" "top-right")
  112. (dk "KP_Right" "right")
  113. (dk "KP_Page_Down" "bottom-right")
  114. (dk "KP_Down" "bottom")
  115. (dk "KP_End" "bottom-left")
  116. (dk "KP_Left" "left")))
  117. (al/define-numpad-key-gravity *tile-group-top-map* "C-" "gravity")
  118. (al/define-numpad-key-gravity *float-group-top-map* "C-" "al/float-window-gravity")
  119. ;;; Resizing frames
  120. (al/define-key *top-map* "M-s-XF86AudioRaiseVolume" "resize 0 10")
  121. (al/define-key *top-map* "M-s-XF86AudioLowerVolume" "resize 0 -10")
  122. (al/define-key *top-map* "C-M-s-XF86AudioRaiseVolume" "resize 0 1")
  123. (al/define-key *top-map* "C-M-s-XF86AudioLowerVolume" "resize 0 -1")
  124. (al/define-key *top-map* "s-XF86AudioRaiseVolume" "resize 10 0")
  125. (al/define-key *top-map* "s-XF86AudioLowerVolume" "resize -10 0")
  126. (al/define-key *top-map* "C-s-XF86AudioRaiseVolume" "resize 1 0")
  127. (al/define-key *top-map* "C-s-XF86AudioLowerVolume" "resize -1 0")
  128. ;;; Controlling sound
  129. (al/define-key *top-map* "XF86AudioMute" "sound-set-current-scontrol toggle")
  130. (al/define-key *top-map* "M-XF86AudioMute" "sound-next-scontrol")
  131. (al/define-key *top-map* "C-XF86AudioMute" "exec tvtime-command TOGGLE_MUTE")
  132. (al/define-key *top-map* "XF86AudioRaiseVolume" "sound-set-current-scontrol 3%+")
  133. (al/define-key *top-map* "XF86AudioLowerVolume" "sound-set-current-scontrol 3%-")
  134. (al/define-key *top-map* "C-XF86AudioRaiseVolume" "sound-set-current-scontrol 1%+")
  135. (al/define-key *top-map* "C-XF86AudioLowerVolume" "sound-set-current-scontrol 1%-")
  136. (al/define-key *top-map* "M-XF86AudioRaiseVolume" "sound-set-current-scontrol 10%+")
  137. (al/define-key *top-map* "M-XF86AudioLowerVolume" "sound-set-current-scontrol 10%-")
  138. (al/define-key *top-map* "C-M-XF86AudioRaiseVolume" "sound-set-current-scontrol 60%")
  139. (al/define-key *top-map* "C-M-XF86AudioLowerVolume" "sound-set-current-scontrol 20%")
  140. ;;; Controlling EMMS
  141. (al/define-key *top-map* "C-XF86AudioPlay" "al/emms-eval (emms-play-file \"~/docs/audio/grass.wav\")")
  142. (al/define-key *top-map* "XF86AudioPlay" "al/emms-eval (emms-pause)")
  143. (al/define-key *top-map* "XF86AudioStop" "al/emms-eval (emms-pause)")
  144. (al/define-key *top-map* "H-XF86AudioStop" "al/emms-eval (emms-stop)")
  145. (al/define-key *top-map* "s-XF86AudioStop" "al/emms-eval (emms-stop)")
  146. (al/define-key *top-map* "H-XF86AudioPrev" "al/emms-eval (emms-previous)")
  147. (al/define-key *top-map* "s-XF86AudioPrev" "al/emms-eval (emms-previous)")
  148. (al/define-key *top-map* "H-XF86AudioNext" "al/emms-eval (emms-next)")
  149. (al/define-key *top-map* "s-XF86AudioNext" "al/emms-eval (emms-next)")
  150. (al/define-key *top-map* "H-XF86AudioPlay" "al/emms-eval (al/emms-first)")
  151. (al/define-key *top-map* "s-XF86AudioPlay" "al/emms-eval (al/emms-first)")
  152. (al/define-key *top-map* "XF86AudioPrev" "al/emms-eval (al/emms-seek-backward 10)")
  153. (al/define-key *top-map* "XF86AudioNext" "al/emms-eval (al/emms-seek-forward 10)")
  154. (al/define-key *top-map* "C-XF86AudioPrev" "al/emms-eval (al/emms-seek-backward 3)")
  155. (al/define-key *top-map* "C-XF86AudioNext" "al/emms-eval (al/emms-seek-forward 3)")
  156. (al/define-key *top-map* "M-XF86AudioPrev" "al/emms-eval (al/emms-seek-backward 60)")
  157. (al/define-key *top-map* "M-XF86AudioNext" "al/emms-eval (al/emms-seek-forward 60)")
  158. (al/define-key *top-map* "C-M-XF86AudioPrev" "al/emms-eval (al/emms-seek-backward 180)")
  159. (al/define-key *top-map* "C-M-XF86AudioNext" "al/emms-eval (al/emms-seek-forward 180)")
  160. (al/define-key *top-map* "XF86AudioMedia" "al/emms-eval (emms-smart-browse)")
  161. (al/define-key *top-map* "XF86Music" "al/emms-eval (al/emms-notify)")
  162. ;;; Miscellaneous bindings
  163. (defvar *al/emacs-map* (make-sparse-keymap)
  164. "Keymap for finding files (and doing other things) in emacs.")
  165. (al/define-key *top-map* "s-f" '*al/emacs-map*)
  166. (al/define-key *al/emacs-map* "1" "al/frames1")
  167. (al/define-key *al/emacs-map* "b" "al/emacs-eval-show (find-file \"~/notes/bookmarks.org\")")
  168. (al/define-key *al/emacs-map* "n" "al/emacs-eval-show (org-capture 1 \"n\")")
  169. (al/define-key *al/emacs-map* "t" "al/emacs-eval-show (find-file \"~/notes/tasks.org\")")
  170. (al/define-key *al/emacs-map* "i" "al/emacs-eval-show (find-file \"~/notes/info.org\")")
  171. (al/define-key *al/emacs-map* "m" "al/emms-eval (al/emms-notify)")
  172. (al/define-key *top-map* "s-g" "abort")
  173. (al/define-key *top-map* "s-h" '*help-map*)
  174. (al/define-key *top-map* "s-u" "time")
  175. (al/define-key *top-map* "s-i" "info")
  176. (al/define-key *top-map* "s-l" "lastmsg")
  177. (al/define-key *top-map* "s-d" "al/send-key-to-emacs XF86Spell")
  178. (al/define-key *top-map* "XF86Documents" "al/emacs-eval-show (find-file \"~/notes/bookmarks.org\")")
  179. (al/define-key *top-map* "C-XF86Documents" "al/emacs-eval-show (org-capture 1 \"n\")")
  180. (al/define-key *top-map* "M-XF86Documents" "al/emacs-eval-show (find-file \"~/notes/tasks.org\")")
  181. (al/define-key *top-map* "S-XF86Documents" "al/emacs-eval-show (find-file \"~/notes/info.org\")")
  182. (al/define-key *top-map* "XF86Calculator" "al/emacs-eval-show (calc)")
  183. (al/define-key *top-map* "C-XF86Calculator" "al/emacs-eval-show (calendar)")
  184. (al/define-key *top-map* "H-ESC" "exec hide-osds")
  185. (al/define-key *top-map* "s-7" "layout-set 0 s-7")
  186. (al/define-key *top-map* "s-8" "layout-set 1 s-8")
  187. (al/define-key *top-map* "s-9" "layout-set 2 s-9")
  188. (al/define-key *top-map* "H-y" "al/yank-primary")
  189. (al/define-key *top-map* "F12" "exec capture desktop")
  190. (al/define-key *top-map* "M-F12" "exec capture image")
  191. (al/define-key *top-map* "M-SunPrint_Screen" "exec capture image")
  192. (al/define-key *top-map* "C-S-F12" "exec capture video")
  193. (al/define-key *top-map* "C-S-SunPrint_Screen" "exec capture video")
  194. (al/define-key *top-map* "s-F12" "exec toggle-osd-clock")
  195. (al/define-key *top-map* "s-SunPrint_Screen" "exec toggle-osd-clock")
  196. (al/define-key *top-map* "XF86TouchpadToggle" "exec toggle-touchpad")
  197. (al/define-key *top-map* "XF86Sleep" "exec monitor blank")
  198. (al/define-key *top-map* "C-XF86Sleep" "exec monitor suspend")
  199. (al/define-key *top-map* "M-XF86Sleep" "exec monitor off")
  200. (al/define-key *top-map* "C-M-H-XF86Sleep" "exec shutdown now")
  201. ;; Using "exec suspend" is not possible, because "suspend" is a shell
  202. ;; builtin command, and "sh -c" (which is called by "exec") does not
  203. ;; load my "~/.bashrc" where it is disabled.
  204. (al/define-key *top-map* "S-s-XF86Sleep" "exec `which suspend`")
  205. ;; root map
  206. (al/define-key *root-map* "V" "version")
  207. (al/define-key *root-map* "c" "colon")
  208. (al/define-key *root-map* "v" "eval")
  209. (al/define-key *root-map* "i" "list-window-properties")
  210. (al/define-key *root-map* "s-b" "al/banish-pointer")
  211. (al/define-key *root-map* "s-u" "al/toggle-unclutter")
  212. ;; menu map
  213. (al/define-key *menu-map* "s-c" 'menu-up)
  214. (al/define-key *menu-map* "s-t" 'menu-down)
  215. (al/define-key *menu-map* "C-." 'menu-up)
  216. (al/define-key *menu-map* "C-e" 'menu-down)
  217. (al/define-key *menu-map* "M-." 'menu-scroll-up)
  218. (al/define-key *menu-map* "M-e" 'menu-scroll-down)
  219. (al/define-key *menu-map* "s-m" 'menu-finish)
  220. (al/define-key *menu-map* "s-g" 'menu-abort)
  221. ;; input map
  222. (al/define-key *input-map* "C-p" 'input-delete-backward-char)
  223. (al/define-key *input-map* "M-p" 'input-backward-kill-word)
  224. (al/define-key *input-map* "C-," 'input-delete-forward-char)
  225. (al/define-key *input-map* "M-," 'input-forward-kill-word)
  226. (al/define-key *input-map* "C-u" 'input-forward-char)
  227. (al/define-key *input-map* "M-u" 'input-forward-word)
  228. (al/define-key *input-map* "C-o" 'input-backward-char)
  229. (al/define-key *input-map* "M-o" 'input-backward-word)
  230. (al/define-key *input-map* "C-a" 'input-move-beginning-of-line)
  231. (al/define-key *input-map* "C-i" 'input-move-end-of-line)
  232. (al/define-key *input-map* "M-<" 'input-kill-line)
  233. (al/define-key *input-map* "M-P" 'input-kill-to-beginning)
  234. (al/define-key *input-map* "M-." 'input-history-back)
  235. (al/define-key *input-map* "M-e" 'input-history-forward)
  236. (al/define-key *input-map* "C-m" 'input-submit)
  237. ;;; Web jumps
  238. (defvar *al/web-map* (make-sparse-keymap)
  239. "Keymap for quick browsing with conkeror.")
  240. (defvar *al/web-wiki-map* (make-sparse-keymap)
  241. "Keymap for quick browsing wikipedia with conkeror.")
  242. (al/define-key *top-map* "F5" '*al/web-map*)
  243. (al/define-key *al/web-map* "F5" "al/conkeror-eval-show find-url-new-buffer")
  244. (al/define-key *al/web-map* "g" "al/conkeror-eval-show internet-search-github-prompted")
  245. (al/define-key *al/web-map* "G" "al/conkeror-eval-show internet-search-google-prompted")
  246. (al/define-key *al/web-map* "d" "al/conkeror-eval-show internet-search-duckduckgo-prompted")
  247. (al/define-key *al/web-map* "c" "al/conkeror-eval-show internet-search-conkeror-prompted")
  248. (al/define-key *al/web-map* "e" "al/conkeror-eval-show internet-search-emacswiki-prompted")
  249. (al/define-key *al/web-map* "a" "al/conkeror-eval-show internet-search-archwiki-prompted")
  250. (al/define-key *al/web-map* "A" "al/conkeror-eval-show internet-search-arch-package-prompted")
  251. (al/define-key *al/web-map* "m" "al/conkeror-eval-show internet-search-multitran-prompted")
  252. (al/define-key *al/web-map* "i" "al/conkeror-eval-show internet-search-ip-prompted")
  253. (al/define-key *al/web-map* "y" "al/conkeror-eval-show internet-search-youtube-prompted")
  254. (al/define-key *al/web-map* "p" "al/conkeror-eval-show internet-search-python3-prompted")
  255. (al/define-key *al/web-map* "z" "al/conkeror-browse-show zeus")
  256. (al/define-key *al/web-map* "t" "al/conkeror-browse-show http://tv.yandex.ru/4/?period=all-day")
  257. (al/define-key *al/web-map* "M" "al/conkeror-browse-show https://maps.google.com/maps?hl=ru")
  258. (al/define-key *al/web-map* "W" "al/conkeror-browse-show http://www.gismeteo.ru/city/hourly/5039/")
  259. (al/define-key *al/web-map* "w" '*al/web-wiki-map*)
  260. (al/define-key *al/web-wiki-map* "e" "al/conkeror-eval-show internet-search-wikipedia-en-prompted")
  261. (al/define-key *al/web-wiki-map* "r" "al/conkeror-eval-show internet-search-wikipedia-ru-prompted")
  262. ;; tv and radio jumps
  263. (defvar *al/tv-radio-map* (make-sparse-keymap)
  264. "Keymap for quick access to tv and radio resources.")
  265. (al/define-key *top-map* "F6" '*al/tv-radio-map*)
  266. (al/define-key *al/tv-radio-map* "F6" "exec toggle-tvtime")
  267. (al/define-key *al/tv-radio-map* "v" "al/emms-eval (emms-play-url \"mms://live.rfn.ru/vesti_fm\")")
  268. (al/define-key *al/tv-radio-map* "o" "al/conkeror-browse-show http://www.onlinetv.ru/")
  269. (al/define-key *al/tv-radio-map* "e" "al/send-key-to-emacs C-M-s-e")
  270. ;;; Executing progs
  271. (defvar *al/exec-map* (make-sparse-keymap)
  272. "Keymap for executing shell commands or switching to running applications.")
  273. (al/define-key *top-map* "s-m" '*al/exec-map*)
  274. (al/define-key *al/exec-map* "s-m" "exec")
  275. (al/define-key *al/exec-map* "e" "al/emacs")
  276. (al/define-key *al/exec-map* "E" "exec emacs --no-site-file --debug-init")
  277. (al/define-key *al/exec-map* "t" "al/xterm")
  278. (al/define-key *al/exec-map* "T" "exec xterm")
  279. (al/define-key *al/exec-map* "c" "al/conkeror")
  280. (al/define-key *al/exec-map* "f" "al/firefox")
  281. (al/define-key *al/exec-map* "M" "al/emacs-eval (mana-start)")
  282. ;;; Mode line
  283. (defvar *al/mode-line-map* (make-sparse-keymap)
  284. "Keymap for controlling the mode line.")
  285. (al/define-key *top-map* "M-s-m" '*al/mode-line-map*)
  286. (al/define-key *al/mode-line-map* "M-s-m" "mode-line")
  287. (al/define-key *al/mode-line-map* "t" "mode-line")
  288. (al/define-key *al/mode-line-map* "." "al/mode-line-top")
  289. (al/define-key *al/mode-line-map* "e" "al/mode-line-bottom")
  290. ;;; Mana
  291. (defvar *al/mana-map* (make-sparse-keymap)
  292. "Keymap for sending keys to Mana.")
  293. (al/define-key *top-map* "s-j" '*al/mana-map*)
  294. (al/define-key *al/mana-map* "s-j" "mana-state")
  295. (al/define-key *al/mana-map* "a" "mana-attack")
  296. (al/define-key *al/mana-map* "A" "mana-quick-attack")
  297. (al/define-key *al/mana-map* "H" "mana-bat-quest-full")
  298. (al/define-key *al/mana-map* "h" "mana-bat-quest-cont")
  299. (al/define-key *al/mana-map* "l" "al/emacs-eval-show (find-file \"~/.local/share/mana/logs/server.themanaworld.org/\")")
  300. (al/define-key *al/mana-map* "m" "al/emacs-eval-show (find-file \"~/notes/tmw/monsters.org\")")
  301. (al/define-key *al/mana-map* "q" "al/emacs-eval-show (find-file \"~/notes/tmw/quests.org\")")
  302. (al/define-key *al/mana-map* "s" "al/emacs-eval-show (find-file \"~/notes/tmw/spells.org\")")
  303. (al/define-key *al/mana-map* "S" "al/emacs-eval-show (find-file \"~/src/tmw/tmwa-server-data/world/map/npc\")")
  304. (al/define-key *al/mana-map* "b" "mana-break")
  305. (al/define-key *al/mana-map* "k" "mana-kill")
  306. (al/define-key *al/mana-map* "w" "al/conkeror-eval-show internet-search-mana-prompted")
  307. ;;; keys.lisp ends here