summaryrefslogtreecommitdiff
path: root/init.org
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-06-09 16:18:19 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-06-09 16:18:19 +0200
commit2240d3cf3ce1d2933ed880cdaff016bd15847f57 (patch)
tree9cd369ee66c825ef718e662b7002027179b031e8 /init.org
parent09f2b3ed16007ecbb0288c116150a12311627d46 (diff)
Add section for EXWM.
Diffstat (limited to 'init.org')
-rw-r--r--init.org76
1 files changed, 76 insertions, 0 deletions
diff --git a/init.org b/init.org
index de53f7d..7432c01 100644
--- a/init.org
+++ b/init.org
@@ -893,6 +893,81 @@ The procedure is added to the list of functions that are to be evaluated wheneve
TODO: This doesn’t work so well with org tables or genuinely wide content in eww buffers, so I need a way to quickly disable this. Maybe this really should be a minor mode.
+* Window management
+:PROPERTIES:
+:header-args: :noweb-ref exwm :noweb yes
+:END:
+
+Obviously, I’m using Emacs as my window manager. Here’s the default configuration:
+
+#+BEGIN_SRC elisp
+(require 'exwm)
+(require 'exwm-config)
+(exwm-config-default)
+#+END_SRC
+
+Since I’ve remapped C-t to C-x, I need to add C-t to the permitted prefix keys. I also add =s-t= to the prefix keys to ensure that it is passed to EXWM in “line mode”.
+
+#+BEGIN_SRC elisp
+(setq exwm-input-prefix-keys '(?\C-t ?\C-x ?\C-u ?\C-h ?\M-x ?\M-` ?\M-& ?\M-:))
+#+END_SRC
+
+Unfortunately, C-t is now swallowed by EXWM, which means that I cannot easily open a tab in a browser any more. Not a big deal because I can send =C-t= to the application with =C-x C-x= (which is really =C-t C-t= before translation) using simulated keys.
+
+#+BEGIN_SRC elisp
+(setq exwm-input-simulation-keys
+ '(([?\C-b] . [left])
+ ([?\C-f] . [right])
+ ([?\C-p] . [up])
+ ([?\C-n] . [down])
+ ([?\C-a] . [home])
+ ([?\C-e] . [end])
+ ([?\M-v] . [prior])
+ ([?\C-v] . [next])
+ ([?\C-d] . [delete])
+ ([?\C-k] . [S-end delete])
+ ([?\C-x ?\C-x] . [C-t])))
+#+END_SRC
+
+The most generic way around this is to switch from “line-mode” (where control characters are swallowed by EXWM) to “char-mode” (where almost all characters are passed through to the application). I use =s-t= to toggle the modes. The following snippet was taken from the [[https://emacs.stackexchange.com/a/33329][Emacs stackexchange site]].
+
+#+BEGIN_SRC elisp
+(defun fhd/exwm-input-line-mode ()
+ "Set exwm window to line-mode and show mode line"
+ (call-interactively #'exwm-input-grab-keyboard)
+ (exwm-layout-show-mode-line))
+
+(defun fhd/exwm-input-char-mode ()
+ "Set exwm window to char-mode and hide mode line"
+ (call-interactively #'exwm-input-release-keyboard)
+ (exwm-layout-hide-mode-line))
+
+(defun fhd/exwm-input-toggle-mode ()
+ "Toggle between line- and char-mode"
+ (interactive)
+ (with-current-buffer (window-buffer)
+ (when (eq major-mode 'exwm-mode)
+ (if (equal (cadr (cadr mode-line-process)) "line")
+ (fhd/exwm-input-char-mode)
+ (fhd/exwm-input-line-mode)))))
+
+(exwm-input-set-key (kbd "s-t") #'fhd/exwm-input-toggle-mode)
+#+END_SRC
+
+To make EXWM feel more like a proper desktop environment I also use the =desktop-environment= package, which binds common keys for brightness and volume control.
+
+#+BEGIN_SRC elisp
+(require 'desktop-environment)
+(desktop-environment-mode 1)
+(setq desktop-environment-brightness-get-command "light")
+(setq desktop-environment-brightness-set-command "light %s")
+(setq desktop-environment-brightness-get-regexp "\\([0-9.]+\\)")
+(setq desktop-environment-brightness-small-increment "-A 1")
+(setq desktop-environment-brightness-normal-increment "-A 5")
+(setq desktop-environment-brightness-small-decrement "-U 1")
+(setq desktop-environment-brightness-normal-decrement "-U 5")
+#+END_SRC
+
* Multimedia with EMMS
:PROPERTIES:
:header-args: :noweb-ref emms :noweb yes
@@ -1724,6 +1799,7 @@ Having defined named code blocks in the sections above we can finally put them a
<<god>>
<<email-lazy>>
<<ido-lazy>>
+<<exwm>>
<<completion-lazy>>
<<pretty-symbols>>
<<resize-dynamically>>