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