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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
(define-module (sigils home services hyprland)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (gnu services configuration)
#:use-module (sigils packages hyprland)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:export (hypr-config?
%default-hyprland-config
home-hyprland-configuration
home-hyprland-service-type
home-hyprpaper-configuration
home-hyprpaper-service-type
home-hyprlock-configuration
home-hyprlock-service-type
home-hypridle-configuration
home-hypridle-service-type))
(define hypr-config? list?)
(define (serialize-hypr-config var)
(define (align nestness)
(apply string-append
(map (const " ") (iota nestness))))
(define (serialize-term term)
(match term
(('rgba color) (list (format #f "rgba(~a)" (symbol->string color))))
(('rgb color) (list (format #f "rgb(~a)" (symbol->string color))))
;; I'd say it's not the most elegant way.
(('rgba r g b a) (list (format #f "rgba(~a, ~a, ~a, ~a)" r g b a)))
(('rgb r g b) (list (format #f "rgb(~a, ~a, ~a)" r g b)))
((e lst ...)
(append
(serialize-term e)
(append-map (lambda (n)
`(" " ,@(serialize-term n)))
lst)))
(single
`(,(match single
(#t "true")
(#f "false")
((? symbol? e) (symbol->string e))
((? number? e) (number->string e))
((? string? e) e)
(() "")
(e e))))))
(define* (serialize-config
config #:optional (nestness 0))
(match config
((term ((expressions ...) ...))
`(,(align nestness) ,@(serialize-term term) " {\n"
,@(append-map (lambda (e)
(serialize-config e (1+ nestness)))
expressions)
,(align nestness) "}\n"))
((term r . est)
`(,(align nestness)
,@(serialize-term term)
" = "
,@(serialize-term r)
,@(append-map
(lambda (t)
`(", " ,@(serialize-term t)))
est)
"\n"))
((term . rterm)
`(,(align nestness)
,@(serialize-term term)
" = "
,@(serialize-term rterm)
"\n"))))
(append-map serialize-config var))
;;; Hyprland
(define %default-hyprland-config
'(($terminal kitty)
($fileManager dolphin)
($menu (wofi --show drun))
($mainMod SUPER)
;; autogenerated
(autogenerated 0)
;; monitors
(monitor () preferred auto auto)
;; general
(general ((gaps_in 5)
(gaps_out 20)
(border_size 2)
(col.active_border ((rgba 33ccffee) (rgba 00ff99ee) 45deg))
(col.inactive_border (rgba 595959aa)) ;; Ugly trick
(resize_on_border #f)
(allow_tearing #f)
(layout dwindle)))
;; decoration
(decoration ((rounding 10)
(active_opacity 1.0)
(inactive_opacity 1.0)
(drop_shadow #t)
(shadow_range 4)
(shadow_render_power 3)
(col.shadow (rgba 1a1a1aee))
(blur ((enabled #t)
(size 3)
(passes 1)
(vibrancy 0.1696)))))
;; animations
(animations ((enabled #t)
(bezier myBezier 0.05 0.9 0.1 1.05)
(animation windows 1 7 myBezier)
(animation windowsOut 1 7 default (popin 80%))
(animation border 1 10 default)
(animation borderangle 1 8 default)
(animation fade 1 7 default)
(animation workspaces 1 6 default)))
;; dwindle
(dwindle ((pseudotile #t)
(preserve_split #t)))
;; master
(master ((new_status master)))
;; misc
(misc ((force_default_wallpaper -1)
(disable_hyprland_logo #f)))
;; input
(input ((kb_layout us)
(kb_variant)
(kb_model)
(kb_options)
(kb_rules)
(follow_mouse 1)
(sensitivity 0)
(touchpad ((natural_scroll #f)))))
;; gestures
(gestures ((workspace_swipe #f)))
;; device
(device ((name epic-mouse-v1)
(sensitivity -0.5)))
;; binds
(bind $mainMod Q exec $terminal)
(bind $mainMod C killactive ())
(bind $mainMod M exit ())
(bind $mainMod E exec $fileManager)
(bind $mainMod V togglefloating ())
(bind $mainMod R exec $menu)
(bind $mainMod P pseudo ())
(bind $mainMod J togglesplit ())
(bind $mainMod left movefocus l)
(bind $mainMod right movefocus r)
(bind $mainMod up movefocus u)
(bind $mainMod down movefocus d)
(bind $mainMod 1 workspace 1)
(bind $mainMod 2 workspace 2)
(bind $mainMod 3 workspace 3)
(bind $mainMod 4 workspace 4)
(bind $mainMod 5 workspace 5)
(bind $mainMod 6 workspace 6)
(bind $mainMod 7 workspace 7)
(bind $mainMod 8 workspace 8)
(bind $mainMod 9 workspace 9)
(bind $mainMod 0 workspace 10)
(bind ($mainMod SHIFT) 1 movetoworkspace 1)
(bind ($mainMod SHIFT) 2 movetoworkspace 2)
(bind ($mainMod SHIFT) 3 movetoworkspace 3)
(bind ($mainMod SHIFT) 4 movetoworkspace 4)
(bind ($mainMod SHIFT) 5 movetoworkspace 5)
(bind ($mainMod SHIFT) 6 movetoworkspace 6)
(bind ($mainMod SHIFT) 7 movetoworkspace 7)
(bind ($mainMod SHIFT) 8 movetoworkspace 8)
(bind ($mainMod SHIFT) 9 movetoworkspace 9)
(bind ($mainMod SHIFT) 0 movetoworkspace 10)
(bind $mainMod S togglespecialworkspace magic)
(bind ($mainMod SHIFT) S movetoworkspace special:magic)
(bind $mainMod mouse_down workspace e+1)
(bind $mainMod mouse_up workspace e-1)
(bindm $mainMod mouse:272 movewindow)
(bindm $mainMod mouse:273 resizewindow)
(bindel () XF86AudioRaiseVolume exec (wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+))
(bindel () XF86AudioLowerVolume exec (wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-))
(bindel () XF86AudioMute exec (wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle))
(bindel () XF86AudioMicMute exec (wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle))
(bindel () XF86MonBrightnessUp exec (brightnessctl s 10%+))
(bindel () XF86MonBrightnessDown exec (brightnessctl s 10%-))
(bindl () XF86AudioNext exec (playerctl next))
(bindl () XF86AudioPause exec (playerctl play-pause))
(bindl () XF86AudioPlay exec (playerctl play-pause))
(bindl () XF86AudioPrev exec (playerctl previous))
;; windowrules
(windowrulev2 (suppressevent maximize) class:.*)
(windowrulev2 nofocus class:^$ title:^$ xwayland:1 floating:1 fullscreen:0 pinned:0)))
(define-configuration/no-serialization home-hyprland-configuration
(plugins
(list-of-packages '())
"Additional plugins to load with Hyprland.")
(config
(hypr-config %default-hyprland-config)
"Hyprland configuration"))
(define (hyprland-configuration->file config)
`(("hypr/hyprland.conf"
,(apply
mixed-text-file "hyprland-config"
`(,@(append-map
(lambda (plugin)
`("plugin = " ,plugin "/lib/lib" ,(package-name plugin) ".so\n"))
(home-hyprland-configuration-plugins config))
,@(serialize-hypr-config
(home-hyprland-configuration-config config)))))))
(define hyprctl-reload-gexp
#~(begin
(system* (string-append #+hyprland "/bin/hyprctl") "reload")))
(define home-hyprland-service-type
(service-type
(name 'home-hyprland)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
hyprland-configuration->file)
(service-extension
home-activation-service-type
(const hyprctl-reload-gexp))))
(compose identity)
(default-value (home-hyprland-configuration))
(description "Configure Hyprland by providing @file{~/.config/hypr/hyprland.conf}")))
;;; Hyprpaper
(define-configuration/no-serialization home-hyprpaper-configuration
(hyprpaper
(file-like hyprpaper)
"The hyprpaper package to use.")
(config
(hypr-config '())
"Hyprpaper configuration"))
(define (hyprpaper-configuration->file config)
`(("hypr/hyprpaper.conf"
,(apply mixed-text-file
"hyprpaper-config"
(serialize-hypr-config
(home-hyprpaper-configuration-config config))))))
(define home-hyprpaper-service-type
(service-type
(name 'home-hyprpaper)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
hyprpaper-configuration->file)
(service-extension
home-profile-service-type
(lambda (config)
(list (home-hyprpaper-configuration-hyprpaper config))))))
(compose identity)
(default-value (home-hyprpaper-configuration))
(description "Configure Hyprpaper by providing @file{~/.config/hypr/hyprpaper.conf}.")))
;;; Hyprlock
(define-configuration/no-serialization home-hyprlock-configuration
(hyprlock
(file-like hyprlock)
"The hyprlock package to use.")
(config
(hypr-config '())
"Hyprlock configuration"))
(define (hyprlock-configuration->file config)
`(("hypr/hyprlock.conf"
,(apply mixed-text-file
"hyprlock-config"
(serialize-hypr-config
(home-hyprlock-configuration-config config))))))
(define home-hyprlock-service-type
(service-type
(name 'home-hyprlock)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
hyprlock-configuration->file)
(service-extension
home-profile-service-type
(lambda (config)
(list (home-hyprlock-configuration-hyprlock config))))))
(compose identity)
(default-value (home-hyprlock-configuration))
(description "Configure Hyprlock by providing @file{~/.config/hypr/hyprlock.conf}.")))
;;; Hypridle
(define-configuration/no-serialization home-hypridle-configuration
(hypridle
(file-like hypridle)
"The hypridle package to use.")
(config
(hypr-config '())
"Hypridle configuration"))
(define (hypridle-configuration->file config)
`(("hypr/hypridle.conf"
,(apply mixed-text-file
"hypridle-config"
(serialize-hypr-config
(home-hypridle-configuration-config config))))))
(define (home-hypridle-shepherd-service config)
(shepherd-service
(documentation "Hypridle daemon")
(provision '(hypridle))
(requirement '(dbus))
(start #~(make-forkexec-constructor
(list #$(file-append
(home-hypridle-configuration-hypridle config)
"/bin/hypridle"))))
(stop #~(make-kill-destructor))))
(define home-hypridle-service-type
(service-type
(name 'home-hypridle)
(extensions
(list (service-extension
home-xdg-configuration-files-service-type
hypridle-configuration->file)
;; (service-extension
;; home-shepherd-service-type
;; (lambda (config)
;; (list (home-hypridle-shepherd-service config))))
(service-extension
home-profile-service-type
(lambda (config)
(list (home-hypridle-configuration-hypridle config))))))
(compose identity)
(default-value (home-hypridle-configuration))
(description "Configure Hypridle by providing @file{~/.config/hypr/hypridle.conf} and start the service.")))
|