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