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