From 4b57824e9867cf8d81bf10b4d6d3d07babc0ad7a Mon Sep 17 00:00:00 2001 From: laurensmiers Date: Wed, 20 Mar 2019 08:15:29 +0100 Subject: [PATCH 1/8] EXWM: Initial experiment - Can be loaded in with command line flag '-start_wm' --- config.org | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config.org b/config.org index 633adc9..31a94e0 100644 --- a/config.org +++ b/config.org @@ -24,6 +24,32 @@ This configuration requires the installation of : When first checking out this config, run =irony-install-server= to make and install the irony-server. +* EXWM + +#+BEGIN_SRC emacs-lisp +(defun found-custom-arg (switch) + (let ((found-switch (member switch command-line-args))) + (setq command-line-args (delete switch command-line-args)) + found-switch)) + +(use-package exwm + :ensure t +) + +(if (found-custom-arg "-start_wm") + (progn + (message "Loading EXWM...") + (require 'exwm) + (require 'exwm-config) + + ;; systray not working? + (require 'exwm-systemtray) + (exwm-systemtray-enable) + (exwm-config-default) + ) +) +#+END_SRC + * Resize frame Minor-mode to easily resize frames (works with EXWM (firefox, ...)). @@ -248,6 +274,9 @@ Since I like it to give me a list of recent files, we need to enable =recentf-mo ) #+END_SRC +Important to note, =dashboard-setup-startup-hook= will not display the dashboard when command-line arguments are provided. +It assumes the command line arguments are filenames and skips showing the dashboard. + * Zygospore Revert =C-x 1= by pressing =C-x 1= again: From fed3fe020461b0da286d88dcecd046dc954ddf7a Mon Sep 17 00:00:00 2001 From: laurensmiers Date: Fri, 12 Apr 2019 15:32:08 +0200 Subject: [PATCH 2/8] Customize EXWM config --- config.org | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/config.org b/config.org index 31a94e0..a7f00db 100644 --- a/config.org +++ b/config.org @@ -41,15 +41,69 @@ When first checking out this config, run =irony-install-server= to make and inst (message "Loading EXWM...") (require 'exwm) (require 'exwm-config) + (require 'exwm-randr) ;; systray not working? (require 'exwm-systemtray) (exwm-systemtray-enable) - (exwm-config-default) + + (setq exwm-workspace-number 2) + + (setq exwm-randr-workspace-output-plist + '(0 "DP1" 1 "DP2")) + (add-hook 'exwm-randr-screen-change-hook + (lambda () + (start-process-shell-command + "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) + (exwm-randr-enable) + + + + ;; Make class name the buffer name + (add-hook 'exwm-update-class-hook + (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) + ;; Global keybindings. + (setq exwm-input-global-keys + `( + ;; 's-r': Reset (to line-mode). + ([?\s-r] . exwm-reset) + ;; 's-w': Switch workspace. + ([?\s-w] . exwm-workspace-switch) + ;; 's-&': Launch application. + ([s-return] . (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + ;; 's-N': Switch to certain workspace. + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 0 9)))) + ;; Line-editing shortcuts + (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-s] . [C-f]) + ([?\C-k] . [S-end delete]))) + + (global-set-key (kbd "C-x C-b") 'exwm-workspace-switch-to-buffer) + + ;; Enable EXWM + (exwm-enable) ) ) #+END_SRC + * Resize frame Minor-mode to easily resize frames (works with EXWM (firefox, ...)). @@ -940,7 +994,20 @@ https://github.com/dimitri/switch-window (setq switch-window-shortcut-style 'qwerty) (setq switch-window-qwerty-shortcuts '("a" "s" "d" "f" "j" "k" "l" "i" "o")) -;; (setq switch-window-multiple-frames t) ;; TODO: doesn't work properly.. + (setq switch-window-multiple-frames t) + +;; TODO: test if this fixes exwm stuff + (setq switch-window-input-style 'minibuffer) + +;; (defun akirak/switch-window-frame-list-function () +;; "Frame list function for `switch-window' on EXWM." +;; (cl-remove-if-not #'exwm-workspace--active-p (visible-frame-list))) + +;; (setq switch-window-frame-list-function +;; 'akirak/switch-window-frame-list-function) + + + :bind ("C-x o" . switch-window)) #+END_SRC From 794973b0519f2b739582d9a386f08a5aa99d99be Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 15:36:08 +0200 Subject: [PATCH 3/8] Term-mode: Add hook to toggle between char/line mode --- config.org | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/config.org b/config.org index a7f00db..68fa439 100644 --- a/config.org +++ b/config.org @@ -103,6 +103,28 @@ When first checking out this config, run =irony-install-server= to make and inst ) #+END_SRC +* Term + +** Toggle between char- and line-mode + +Courtesy goes to https://joelmccracken.github.io/entries/switching-between-term-mode-and-line-mode-in-emacs-term/ + +#+BEGIN_SRC emacs-lisp +(require 'term) + +(defun jnm/term-toggle-mode () + "Toggles term between line mode and char mode" + (interactive) + (if (term-in-line-mode) + (term-char-mode) + (term-line-mode))) + +(define-key term-mode-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-mode-map (kbd "C-c C-k") 'jnm/term-toggle-mode) + +(define-key term-raw-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-raw-map (kbd "C-c C-k") 'jnm/term-toggle-mode) +#+END_SRC * Resize frame From 4906b9da53d587714d3186dfd0b63e0993f9bd5b Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 15:46:34 +0200 Subject: [PATCH 4/8] EXWM: Move config of exwm to use-package config section - + move found-custom-arg to 'Utils' section. --- config.org | 125 ++++++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/config.org b/config.org index 68fa439..9c23751 100644 --- a/config.org +++ b/config.org @@ -24,81 +24,88 @@ This configuration requires the installation of : When first checking out this config, run =irony-install-server= to make and install the irony-server. -* EXWM +* Utils + +** Custom command line arguments + +Return if a custom command line arguments was found. +If it was found, we delete it from the list of command line arguments. #+BEGIN_SRC emacs-lisp (defun found-custom-arg (switch) (let ((found-switch (member switch command-line-args))) (setq command-line-args (delete switch command-line-args)) found-switch)) +#+END_SRC -(use-package exwm - :ensure t -) +* EXWM +Arandr config is still too static, should find a way to simplify this. + +#+BEGIN_SRC emacs-lisp (if (found-custom-arg "-start_wm") (progn (message "Loading EXWM...") - (require 'exwm) - (require 'exwm-config) - (require 'exwm-randr) + (use-package exwm + :ensure t + :config + (require 'exwm-systemtray) + (exwm-systemtray-enable) - ;; systray not working? - (require 'exwm-systemtray) - (exwm-systemtray-enable) + (require 'exwm-randr) + (setq exwm-workspace-number 2) - (setq exwm-workspace-number 2) - - (setq exwm-randr-workspace-output-plist - '(0 "DP1" 1 "DP2")) - (add-hook 'exwm-randr-screen-change-hook - (lambda () - (start-process-shell-command - "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) - (exwm-randr-enable) - - - - ;; Make class name the buffer name - (add-hook 'exwm-update-class-hook + (setq exwm-randr-workspace-output-plist + '(0 "DP1" 1 "DP2")) + (add-hook 'exwm-randr-screen-change-hook (lambda () - (exwm-workspace-rename-buffer exwm-class-name))) - ;; Global keybindings. - (setq exwm-input-global-keys - `( - ;; 's-r': Reset (to line-mode). - ([?\s-r] . exwm-reset) - ;; 's-w': Switch workspace. - ([?\s-w] . exwm-workspace-switch) - ;; 's-&': Launch application. - ([s-return] . (lambda (command) - (interactive (list (read-shell-command "$ "))) - (start-process-shell-command command nil command))) - ;; 's-N': Switch to certain workspace. - ,@(mapcar (lambda (i) - `(,(kbd (format "s-%d" i)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,i)))) - (number-sequence 0 9)))) - ;; Line-editing shortcuts - (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-s] . [C-f]) - ([?\C-k] . [S-end delete]))) + (start-process-shell-command + "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) + (exwm-randr-enable) - (global-set-key (kbd "C-x C-b") 'exwm-workspace-switch-to-buffer) + (require 'exwm-config) - ;; Enable EXWM - (exwm-enable) + ;; Make class name the buffer name + (add-hook 'exwm-update-class-hook + (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) + ;; Global keybindings. + (setq exwm-input-global-keys + `( + ;; 's-r': Reset (to line-mode). + ([?\s-r] . exwm-reset) + ;; 's-w': Switch workspace. + ([?\s-w] . exwm-workspace-switch) + ;; 's-return': Launch application. + ([s-return] . (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + ;; 's-N': Switch to certain workspace. + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 0 9)))) + ;; Line-editing shortcuts + (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-s] . [C-f]) + ([?\C-k] . [S-end delete]))) + + (global-set-key (kbd "C-x C-b") 'exwm-workspace-switch-to-buffer) + + ;; Enable EXWM + (exwm-enable) + ) ) ) #+END_SRC From 16979c58e3e5c8988fd34c6134f7b35801e0024f Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 15:49:13 +0200 Subject: [PATCH 5/8] EXWM: Move EXWM section to bottom to avoid overwriting EXWM keymaps - F.e. C-x C-b should still work in non-EXWM environments --- config.org | 144 ++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/config.org b/config.org index 9c23751..66ec60f 100644 --- a/config.org +++ b/config.org @@ -38,78 +38,6 @@ If it was found, we delete it from the list of command line arguments. found-switch)) #+END_SRC -* EXWM - -Arandr config is still too static, should find a way to simplify this. - -#+BEGIN_SRC emacs-lisp -(if (found-custom-arg "-start_wm") - (progn - (message "Loading EXWM...") - (use-package exwm - :ensure t - :config - (require 'exwm-systemtray) - (exwm-systemtray-enable) - - (require 'exwm-randr) - (setq exwm-workspace-number 2) - - (setq exwm-randr-workspace-output-plist - '(0 "DP1" 1 "DP2")) - (add-hook 'exwm-randr-screen-change-hook - (lambda () - (start-process-shell-command - "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) - (exwm-randr-enable) - - (require 'exwm-config) - - ;; Make class name the buffer name - (add-hook 'exwm-update-class-hook - (lambda () - (exwm-workspace-rename-buffer exwm-class-name))) - ;; Global keybindings. - (setq exwm-input-global-keys - `( - ;; 's-r': Reset (to line-mode). - ([?\s-r] . exwm-reset) - ;; 's-w': Switch workspace. - ([?\s-w] . exwm-workspace-switch) - ;; 's-return': Launch application. - ([s-return] . (lambda (command) - (interactive (list (read-shell-command "$ "))) - (start-process-shell-command command nil command))) - ;; 's-N': Switch to certain workspace. - ,@(mapcar (lambda (i) - `(,(kbd (format "s-%d" i)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,i)))) - (number-sequence 0 9)))) - ;; Line-editing shortcuts - (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-s] . [C-f]) - ([?\C-k] . [S-end delete]))) - - (global-set-key (kbd "C-x C-b") 'exwm-workspace-switch-to-buffer) - - ;; Enable EXWM - (exwm-enable) - ) - ) -) -#+END_SRC - * Term ** Toggle between char- and line-mode @@ -1297,6 +1225,78 @@ https://github.com/Malabarba/paradox ) #+END_SRC +* EXWM + +Arandr config is still too static, should find a way to simplify this. + +#+BEGIN_SRC emacs-lisp +(if (found-custom-arg "-start_wm") + (progn + (message "Loading EXWM...") + (use-package exwm + :ensure t + :config + (require 'exwm-systemtray) + (exwm-systemtray-enable) + + (require 'exwm-randr) + (setq exwm-workspace-number 2) + + (setq exwm-randr-workspace-output-plist + '(0 "DP1" 1 "DP2")) + (add-hook 'exwm-randr-screen-change-hook + (lambda () + (start-process-shell-command + "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) + (exwm-randr-enable) + + (require 'exwm-config) + + ;; Make class name the buffer name + (add-hook 'exwm-update-class-hook + (lambda () + (exwm-workspace-rename-buffer exwm-class-name))) + ;; Global keybindings. + (setq exwm-input-global-keys + `( + ;; 's-r': Reset (to line-mode). + ([?\s-r] . exwm-reset) + ;; 's-w': Switch workspace. + ([?\s-w] . exwm-workspace-switch) + ;; 's-return': Launch application. + ([s-return] . (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + ;; 's-N': Switch to certain workspace. + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 0 9)))) + ;; Line-editing shortcuts + (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-s] . [C-f]) + ([?\C-k] . [S-end delete]))) + + (global-set-key (kbd "C-x C-b") 'exwm-workspace-switch-to-buffer) + + ;; Enable EXWM + (exwm-enable) + ) + ) +) +#+END_SRC + * TODO stuff i need to look into: From 887886bb7da9a60f6c0e815e9e40fdf80fb13ed9 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 16:09:20 +0200 Subject: [PATCH 6/8] EXWM: Use global flags to signal command-line-args --- config.org | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config.org b/config.org index 66ec60f..f872f52 100644 --- a/config.org +++ b/config.org @@ -38,6 +38,23 @@ If it was found, we delete it from the list of command line arguments. found-switch)) #+END_SRC +** Global variables + +Some package behave strangely if we have custom command line parameters. +F.e. Dashboard assumes you are directly opening a file so it won't load the dashboard. + +So, we remove our custom variables from the command line arguments and set global 'flags'. +These flags will enable/disable parts of the config. + +#+BEGIN_SRC emacs-lisp +(setq EXWM_ENABLE nil) + +(if (found-custom-arg "-start_wm") + (setq EXWM_ENABLE t) +) + +#+END_SRC + * Term ** Toggle between char- and line-mode @@ -1230,7 +1247,7 @@ https://github.com/Malabarba/paradox Arandr config is still too static, should find a way to simplify this. #+BEGIN_SRC emacs-lisp -(if (found-custom-arg "-start_wm") +(if EXWM_ENABLE (progn (message "Loading EXWM...") (use-package exwm From 17bec5fe79a176ab2a15f03d747b34adac69f4c8 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 16:35:20 +0200 Subject: [PATCH 7/8] EXWM: cleanup switch window --- config.org | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/config.org b/config.org index f872f52..aedd9bc 100644 --- a/config.org +++ b/config.org @@ -958,6 +958,8 @@ Credit goes to https://github.com/daedreth/UncleDavesEmacs https://github.com/dimitri/switch-window +Explanation for different config when EXWM is in the README on the github. + #+BEGIN_SRC emacs-lisp (use-package switch-window :ensure t @@ -970,15 +972,12 @@ https://github.com/dimitri/switch-window '("a" "s" "d" "f" "j" "k" "l" "i" "o")) (setq switch-window-multiple-frames t) -;; TODO: test if this fixes exwm stuff - (setq switch-window-input-style 'minibuffer) + (if EXWM_ENABLE + (progn + (setq switch-window-input-style 'minibuffer) + ) + ) -;; (defun akirak/switch-window-frame-list-function () -;; "Frame list function for `switch-window' on EXWM." -;; (cl-remove-if-not #'exwm-workspace--active-p (visible-frame-list))) - -;; (setq switch-window-frame-list-function -;; 'akirak/switch-window-frame-list-function) @@ -988,14 +987,13 @@ https://github.com/dimitri/switch-window When using exwm, have a look at this: https://github.com/dimitri/switch-window/pull/62 - -** Multi-frame rebindings (obsolete with switch-window) +** Multi-frame rebindings (OBSOLETE with switch-window) Sometimes I have multiple emacs-frames open. In the past, I preferred that the normal =C-x o= can deal with this but this is used by switch-window now. #+BEGIN_SRC emacs-lisp -;; Use C-x o to switch to other frame when using multi-monitor +;; ;; Use C-x o to switch to other frame when using multi-monitor ;; (global-set-key (kbd "C-x o") 'next-multiframe-window) #+END_SRC @@ -1318,9 +1316,9 @@ Arandr config is still too static, should find a way to simplify this. stuff i need to look into: - ibuffer -- switch-window +- fix dired-mode (f.e. new-buffer for every folder, ...) +- helm-exwm - symon - spaceline - async -- exwm - helm-hide-minibuffer From 3a034f94cf94c0b489c996ac293a3b63ea787951 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Fri, 19 Apr 2019 16:36:01 +0200 Subject: [PATCH 8/8] EXWM: Set workspace number to 1 and comment xrandr stuff --- config.org | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config.org b/config.org index aedd9bc..cb6f27f 100644 --- a/config.org +++ b/config.org @@ -1255,15 +1255,15 @@ Arandr config is still too static, should find a way to simplify this. (exwm-systemtray-enable) (require 'exwm-randr) - (setq exwm-workspace-number 2) + (setq exwm-workspace-number 1) - (setq exwm-randr-workspace-output-plist - '(0 "DP1" 1 "DP2")) - (add-hook 'exwm-randr-screen-change-hook - (lambda () - (start-process-shell-command - "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) - (exwm-randr-enable) + ;; (setq exwm-randr-workspace-output-plist + ;; '(0 "DP1" 1 "DP2")) + ;; (add-hook 'exwm-randr-screen-change-hook + ;; (lambda () + ;; (start-process-shell-command + ;; "xrandr" nil "xrandr --output DP2 --primary --mode 1920x1080 --pos 1920x0 --rotate left --output DP1 --mode 1920x1080 --pos 0x0 --rotate normal --auto"))) + ;; (exwm-randr-enable) (require 'exwm-config)