1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
;; -*- lexical-binding: t; -*-
;;
;; Configure desktop environment settings, including both window-management
;; (reka) as well as additional system-wide commands.
(require 'reka)
(require 'f)
(require 'ring)
(require 's)
(require 'seq)
(defun pactl (cmd)
(shell-command (concat "pactl " cmd))
(message "Volume command: %s" cmd))
(defun volume-mute () (interactive) (pactl "set-sink-mute @DEFAULT_SINK@ toggle"))
(defun volume-up () (interactive) (pactl "set-sink-volume @DEFAULT_SINK@ +5%"))
(defun volume-down () (interactive) (pactl "set-sink-volume @DEFAULT_SINK@ -5%"))
(defun brightness-up ()
(interactive)
(shell-command "brightnessctl set +3%")
(message "Brightness increased"))
(defun brightness-down ()
(interactive)
(shell-command "brightnessctl set 3%-")
(message "Brightness decreased"))
(defun create-window-name ()
"Construct window names to be used for EXWM buffers by
inspecting the window's X11 class and title.
A lot of commonly used applications either create titles that
are too long by default, or in the case of web
applications (such as Cider) end up being constructed in
awkward ways.
To avoid this issue, some rewrite rules are applied for more
human-accessible titles."
(pcase (list (or exwm-class-name "unknown") (or exwm-title "unknown"))
;; Yandex.Music -> `Я.Music<... stuff ...>'
(`("Chromium-browser" ,(and (pred (lambda (title) (s-starts-with? "Yandex.Music - " title))) title))
(format "Я.Music<%s>" (s-chop-prefix "Yandex.Music - " title)))
;; For other Chromium windows, make the title shorter.
(`("Chromium-browser" ,title)
(format "Chromium<%s>" (s-truncate 42 (s-chop-suffix " - Chromium" title))))
;; similarly for Firefox
(`("firefox" ,title)
(format "FF<%s>" title))
;; Quassel buffers
;;
;; These have a title format that looks like:
;; "Quassel IRC - #tvl (hackint) — Quassel IRC"
(`("quassel" ,title)
(progn
(if (string-match
(rx "Quassel IRC - "
(group (one-or-more (any alnum "[" "]" "&" "-" "#"))) ;; <-- channel name
" (" (group (one-or-more (any ascii space))) ")" ;; <-- network name
" — Quassel IRC")
title)
(format "Quassel<%s>" (match-string 2 title))
title)))
;; For any other application, a name is constructed from the
;; window's class and name.
(`(,class ,title) (format "%s<%s>" class (s-truncate 12 title)))))
;; reka configuration
;; TODO: bind this correctly to 1..9 instead of tab-keys
(defun tab-bar-select-or-return ()
"This function behaves like `tab-bar-select-tab', except it calls
`tab-recent' if asked to jump to the current tab. This simulates
the back&forth behaviour of i3."
(interactive)
(let* ((key (event-basic-type last-command-event))
(tab (if (and (characterp key) (>= key ?1) (<= key ?9))
(- key ?0)
0))
(current (1+ (tab-bar--current-tab-index))))
(if (eq tab current)
(tab-recent)
(tab-bar-select-tab tab))))
(defun tazjin-configure-reka ()
(interactive)
(setq tab-bar-show 1)
(setq tab-bar-tab-hints t)
(setq tab-bar-format
'(tab-bar-format-history
tab-bar-format-tabs tab-bar-separator
tab-bar-format-align-right tab-bar-format-global))
(setq tab-bar-new-tab-choice
(lambda () (get-buffer-create "*scratch*")))
(tab-bar-mode 1)
(global-set-key (kbd "s-t") #'tab-new)
(global-set-key (kbd "s-w") #'tab-close)
(global-set-key (kbd "s-j") #'tab-previous)
(global-set-key (kbd "s-k") #'tab-next)
(global-set-key (kbd "s-d") #'run-xdg-app)
;; Show time & battery status in the mode line
(display-time-mode)
(display-battery-mode)
(global-set-key (kbd "<XF86AudioMute>") #'volume-mute)
(global-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
(global-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
(global-set-key (kbd "<MonBrightnessDown>") #'brightness-down)
(global-set-key (kbd "<MonBrightnessUp>") #'brightness-up)
(let ((tab-keys (seq-map (lambda (i) (format "s-%d" i))
(number-sequence 0 9)))
(static '("C-x" "C-u" "C-h" "M-x" ;; standard emacs prefixes
"s-t" "s-w" "s-j" "s-k" ;; tab management
"s-d" ;; app launching
"M-s-l" ;; screen locker
"<XF86AudioMute>"
"<XF86AudioRaiseVolume>"
"<XF86AudioLowerVolume>"
)))
(setq reka-intercept-prefixes (append tab-keys static))
(reka-push-intercept-prefixes)
(dolist (key tab-keys)
(global-set-key (kbd key) #'tab-bar-select-or-return)))
;; TODO: do this in some more proper way
(let ((all-procs (seq-map (lambda (p) (s-join " " (process-command p))) (process-list))))
(unless (seq-find (lambda (p) (s-contains? "kanshi" p)) all-procs)
(run-external-command--handler "kanshi"))
(unless (seq-find (lambda (p) (s-contains? "bin/channel" p)) all-procs)
(run-external-command--handler "channel"))))
(provide 'desktop)
|