diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2023-06-10 09:36:37 +0200 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2023-07-02 13:52:12 +0200 |
commit | ef565a486511cbbb86e0d1f80264b3b57d2ac88a (patch) | |
tree | 4e0b04e78f288985a629ad8b9a8e56eb266de6a4 /.config/emacs/jd-exwm | |
parent | 2b62ae597cc6a4c213f7d4b54b112ff9c216dbaa (diff) | |
download | dotfiles-ef565a486511cbbb86e0d1f80264b3b57d2ac88a.tar.gz dotfiles-ef565a486511cbbb86e0d1f80264b3b57d2ac88a.zip |
Migrate from .org to .el Emacs config.
Diffstat (limited to '.config/emacs/jd-exwm')
-rw-r--r-- | .config/emacs/jd-exwm/init.el | 149 | ||||
-rw-r--r-- | .config/emacs/jd-exwm/start.sh | 15 |
2 files changed, 164 insertions, 0 deletions
diff --git a/.config/emacs/jd-exwm/init.el b/.config/emacs/jd-exwm/init.el new file mode 100644 index 0000000..cf043fb --- /dev/null +++ b/.config/emacs/jd-exwm/init.el | |||
@@ -0,0 +1,149 @@ | |||
1 | (defun jd/exwm-update-class () | ||
2 | (exwm-workspace-rename-buffer exwm-class-name)) | ||
3 | |||
4 | (defun jd-exwm/run-in-background (command) | ||
5 | (let ((command-parts (split-string command "[ ]+"))) | ||
6 | (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) | ||
7 | |||
8 | (defun jd-exwm/restart-process (program-name) | ||
9 | (call-process "killall" nil nil nil program-name) | ||
10 | (jd-exwm/run-in-background program-name)) | ||
11 | |||
12 | (defun jd-exwm/exwm-init-hook () | ||
13 | (jd-exwm/run-in-background "nitrogen --restore") | ||
14 | (start-process-shell-command "xinput" nil "xinput set-prop 'ETPS/2 Elantech Touchpad' 'Synaptics Tap Action' 1 1 1 2 1") | ||
15 | (start-process-shell-command "syndaemon" nil "syndaemon -i 0.8 -K -R -d") | ||
16 | |||
17 | (jd-exwm/restart-process "polybar") | ||
18 | (jd-exwm/restart-process "nm-applet") | ||
19 | (jd-exwm/restart-process "redshift-gtk -l 54.37:18.6") | ||
20 | (jd-exwm/restart-process "blueman-applet")) | ||
21 | |||
22 | (defun jd-exwm/exwm-update-title () | ||
23 | (exwm-workspace-rename-buffer exwm-title)) | ||
24 | |||
25 | (defun jd-exwm/configure-window-by-class () | ||
26 | (interactive) | ||
27 | (pcase exwm-class-name | ||
28 | ("firefox" (exwm-workspace-move-window 2)) | ||
29 | ("Brave" (exwm-workspace-move-window 2)) | ||
30 | ("qutebrowser" (exwm-workspace-move-window 2)) | ||
31 | ("discord" (exwm-workspace-move-window 5)) | ||
32 | ("obs" (exwm-workspace-move-window 5)) | ||
33 | ("Virt-manager" (exwm-workspace-move-window 4)))) | ||
34 | |||
35 | (use-package exwm | ||
36 | :config | ||
37 | (setq exwm-workspace-number 10) | ||
38 | |||
39 | (add-hook 'exwm-init-hook #'jd-exwm/exwm-init-hook) | ||
40 | (add-hook 'exwm-update-class-hook #'jd/exwm-update-class) | ||
41 | (add-hook 'exwm-update-title-hook #'jd-exwm/exwm-update-title) | ||
42 | (add-hook 'exwm-manage-finish-hook #'jd-exwm/configure-window-by-class) | ||
43 | |||
44 | (require 'exwm-randr) | ||
45 | (setq exwm-randr-workspace-monitor-plist '(9 "eDP-1" 0 "eDP-1")) | ||
46 | (exwm-randr-enable) | ||
47 | |||
48 | (setq exwm-input-simulation-keys | ||
49 | '(([?\C-h] . [left]) | ||
50 | ([?\C-l] . [right]) | ||
51 | ([?\C-k] . [up]) | ||
52 | ([?\C-j] . [down]))) | ||
53 | |||
54 | (setq exwm-input-prefix-keys | ||
55 | '(?\C-x | ||
56 | ?\C-u | ||
57 | ?\C-h | ||
58 | ?\M-x | ||
59 | ?\M-` | ||
60 | ?\M-& | ||
61 | ?\M-: | ||
62 | ?\C-\M-j | ||
63 | ?\C-\ )) | ||
64 | |||
65 | (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) | ||
66 | (exwm-input-set-key (kbd "s-p") 'counsel-linux-app) | ||
67 | |||
68 | (setq exwm-input-global-keys | ||
69 | `(([?\s-R] . exwm-reset) | ||
70 | |||
71 | |||
72 | ([?\s-r] . (lambda (command) | ||
73 | (interactive (list (read-shell-command "$ "))) | ||
74 | (start-process-shell-command command nil command))) | ||
75 | |||
76 | ([?\s-W] . exwm-workspace-move-window) | ||
77 | ([?\s-w] . exwm-workspace-switch) | ||
78 | |||
79 | ,@(mapcar (lambda (i) | ||
80 | `(,(kbd (format "s-%d" i)) . | ||
81 | (lambda () | ||
82 | (interactive) | ||
83 | (exwm-workspace-switch-create ,i)))) | ||
84 | (number-sequence 0 9)))) | ||
85 | |||
86 | (exwm-enable)) | ||
87 | |||
88 | (use-package desktop-environment | ||
89 | :after exwm | ||
90 | :config (desktop-environment-mode) | ||
91 | :custom | ||
92 | (desktop-environment-brightness-small-increment "2%+") | ||
93 | (desktop-environment-brightness-small-decrement "2%-") | ||
94 | (desktop-environment-brightness-normal-increment "5%+") | ||
95 | (desktop-environment-brightness-normal-decrement "5%-")) | ||
96 | |||
97 | (set-frame-parameter (selected-frame) 'alpha '(90 . 90)) | ||
98 | (add-to-list 'default-frame-alist `(alpha . (90 . 90))) | ||
99 | (set-frame-parameter (selected-frame) 'fullscreen 'maximized) | ||
100 | (add-to-list 'default-frame-alist '(fullscreen . maximized)) | ||
101 | |||
102 | (defun jd-exwm/get-color (ATTRIBUTE) | ||
103 | (face-attribute 'default ATTRIBUTE)) | ||
104 | |||
105 | (defun theme-to-xresources () | ||
106 | (interactive) | ||
107 | (require 'term) | ||
108 | (with-temp-buffer | ||
109 | (insert "! Generated by theme-to-xresources\n") | ||
110 | (dolist (spec | ||
111 | '(("emacs.background" :background "E6") | ||
112 | ("emacs.foreground" :foreground ""))) | ||
113 | (let ((color (jd-exwm/get-color (cadr spec)))) | ||
114 | (insert (format "%s: #%s%s\n" | ||
115 | (car spec) | ||
116 | (caddr spec) | ||
117 | (string-remove-prefix "#" color)))) | ||
118 | (write-region (point-min) (point-max) "~/.Xresources"))) | ||
119 | (call-process "xrdb" nil nil nil "-merge" (expand-file-name "~/.Xresources"))) | ||
120 | |||
121 | (defun jd/theme-sync () | ||
122 | (interactive) | ||
123 | (theme-to-xresources) | ||
124 | (setq org-confirm-babel-evaluate nil) | ||
125 | (org-babel-tangle-file "~/dotfiles/Desktop.org") | ||
126 | (setq org-confirm-babel-evaluate 't) | ||
127 | (call-process "killall" nil nil nil "dunst") ;; TODO: prevent clear notification history | ||
128 | (jd-exwm/restart-process "polybar")) | ||
129 | |||
130 | (add-hook 'jd/load-theme-hook #'jd/theme-sync) | ||
131 | (add-hook 'exwm-init-hook #'jd/theme-sync) | ||
132 | |||
133 | (defun jd/dunst-show-history () | ||
134 | (interactive) | ||
135 | (start-process-shell-command "dunstctl" nil "dunstctl history-pop")) | ||
136 | |||
137 | (defun jd/dunst-close () | ||
138 | (interactive) | ||
139 | (start-process-shell-command "dunstctl" nil "dunstctl close")) | ||
140 | |||
141 | (defun jd/dunst-close-all () | ||
142 | (interactive) | ||
143 | (start-process-shell-command "dunstctl" nil "dunstctl close-all")) | ||
144 | |||
145 | (jd/leader-key-def | ||
146 | "d" '(nil :which-key "dunst") | ||
147 | "dh" '(jd/dunst-show-history :which-key "show history") | ||
148 | "dc" '(jd/dunst-close :which-key "close") | ||
149 | "da" '(jd/dunst-close-all :which-key "close all")) | ||
diff --git a/.config/emacs/jd-exwm/start.sh b/.config/emacs/jd-exwm/start.sh new file mode 100644 index 0000000..98149b6 --- /dev/null +++ b/.config/emacs/jd-exwm/start.sh | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # picom & | ||
4 | |||
5 | xss-lock -- slock & | ||
6 | |||
7 | export VISUAL="emacsclient -a vim" | ||
8 | export EDITOR="$VISUAL" | ||
9 | export GTK_THEME="Adwaita:dark" | ||
10 | export CALIBRE_USE_DARK_PALETTE=1 | ||
11 | export JD_EXWM=1 | ||
12 | |||
13 | gentoo-pipewire-launcher & | ||
14 | |||
15 | exec dbus-launch --exit-with-session emacs -mm --debug-init -l ~/.config/emacs/exwm/desktop.el | ||