2022-04-14 10:39:25 +02:00
|
|
|
(define-module (oni home services herbstluftwm)
|
|
|
|
#:use-module (gnu services configuration)
|
|
|
|
#:use-module (gnu packages wm)
|
2022-04-15 09:48:15 +02:00
|
|
|
#:use-module (gnu packages shells)
|
2022-04-14 10:39:25 +02:00
|
|
|
#:use-module (gnu home services)
|
|
|
|
#:use-module (gnu home services utils)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix gexp)
|
2022-06-14 06:30:23 +02:00
|
|
|
#:use-module (oni home services xinit)
|
2022-04-16 07:13:33 +02:00
|
|
|
#:use-module (oni gexp)
|
2022-07-23 06:12:45 +02:00
|
|
|
#:use-module (oni kbd)
|
2022-04-15 09:48:15 +02:00
|
|
|
#:use-module (srfi srfi-1)
|
2022-04-14 10:39:25 +02:00
|
|
|
|
|
|
|
#:export (home-herbstluftwm-service-type
|
|
|
|
home-herbstluftwm-configuration))
|
|
|
|
|
|
|
|
(define-configuration/no-serialization home-herbstluftwm-configuration
|
|
|
|
(package
|
|
|
|
(package herbstluftwm)
|
2022-04-15 09:48:15 +02:00
|
|
|
"Package use for setting herbstluftwm")
|
2022-07-23 06:12:45 +02:00
|
|
|
(key-bindings
|
|
|
|
(alist '())
|
|
|
|
"Key bindings")
|
2022-04-15 09:48:15 +02:00
|
|
|
(mouse-bindings
|
|
|
|
(alist '())
|
|
|
|
"Mouse bindings")
|
|
|
|
(settings
|
|
|
|
(alist '())
|
|
|
|
"Settings")
|
|
|
|
(tags
|
|
|
|
(list '(1 2 3 4 5 6 7 8 9 0))
|
|
|
|
"Tags")
|
|
|
|
(tag-keys
|
|
|
|
(list '(1 2 3 4 5 6 7 8 9 0))
|
|
|
|
"Keys for the tags")
|
|
|
|
(attributes
|
|
|
|
(alist '())
|
|
|
|
"Attributes to set")
|
|
|
|
(rules
|
|
|
|
(list '())
|
|
|
|
"Rules to apply")
|
|
|
|
(padding
|
|
|
|
(list '(0 0 0 0 0))
|
|
|
|
"Padding to apply to the monitor")
|
|
|
|
(layouts
|
|
|
|
(alist '())
|
|
|
|
"Layouts to load for tags")
|
|
|
|
(extra
|
|
|
|
(list '())
|
|
|
|
"Extra commands"))
|
2022-04-14 10:39:25 +02:00
|
|
|
|
|
|
|
(define (add-herbstluftwm-packages config)
|
2022-04-16 08:38:18 +02:00
|
|
|
(list (home-herbstluftwm-configuration-package config) zsh))
|
2022-04-14 10:39:25 +02:00
|
|
|
|
2022-07-23 06:12:45 +02:00
|
|
|
(define (build-keybindings bindings)
|
|
|
|
(append
|
|
|
|
(list "herbstclient keyunbind --all\n")
|
|
|
|
(map (lambda (binding)
|
|
|
|
(format #f "herbstclient keybind ~a ~a\n"
|
|
|
|
(kbd (car binding)) (cdr binding)))
|
|
|
|
bindings)))
|
|
|
|
|
2022-04-15 09:48:15 +02:00
|
|
|
(define (home-herbstluftwm-autostart-file config)
|
|
|
|
(apply mixed-executable-file
|
|
|
|
"autostart"
|
|
|
|
"#!" zsh "/bin/zsh\n"
|
|
|
|
"herbstclient emit_hook reload\n"
|
|
|
|
(let ((tags (home-herbstluftwm-configuration-tags config)))
|
2022-07-23 06:12:45 +02:00
|
|
|
(append (build-keybindings
|
|
|
|
(home-herbstluftwm-configuration-key-bindings config))
|
|
|
|
|
|
|
|
(list "herbstclient mouseunbind --all\n")
|
2022-04-15 09:48:15 +02:00
|
|
|
(map (lambda (binding)
|
|
|
|
(format #f "herbstclient mousebind ~a ~a\n"
|
2022-07-23 06:12:45 +02:00
|
|
|
(kbd (car binding)) (cdr binding)))
|
2022-04-15 09:48:15 +02:00
|
|
|
(home-herbstluftwm-configuration-mouse-bindings config))
|
|
|
|
(map (lambda (setting)
|
|
|
|
(format #f "herbstclient set ~s ~s\n"
|
|
|
|
(car setting) (cdr setting)))
|
|
|
|
(home-herbstluftwm-configuration-settings config))
|
|
|
|
(map (lambda (tag)
|
|
|
|
(format #f "herbstclient add ~s\n" tag))
|
|
|
|
tags)
|
|
|
|
(map (lambda (key tag)
|
|
|
|
(format #f "herbstclient keybind Mod4-~a use ~s\n" key tag))
|
|
|
|
(take (home-herbstluftwm-configuration-tag-keys config)
|
|
|
|
(length tags))
|
|
|
|
tags)
|
|
|
|
(if (> (length tags) 0)
|
2022-04-19 10:16:11 +02:00
|
|
|
(list (format #f "herbstclient use ~s\nherbstclient merge_tag default ~s\n" (car tags) (car tags)))
|
2022-04-15 09:48:15 +02:00
|
|
|
'())
|
|
|
|
(map (lambda (attribute-pair)
|
|
|
|
(format #f "herbstclient attr ~a ~s\n"
|
|
|
|
(string-join (map symbol->string (car attribute-pair)) ".")
|
|
|
|
(cdr attribute-pair)))
|
|
|
|
(home-herbstluftwm-configuration-attributes config))
|
|
|
|
(list "herbstclient unrule -F\n")
|
|
|
|
(map (lambda (rule)
|
|
|
|
(format #f "herbstclient rule ~a\n"
|
|
|
|
(string-join rule " ")))
|
|
|
|
(home-herbstluftwm-configuration-rules config))
|
|
|
|
(list "herbstclient unlock\n"
|
|
|
|
(format #f "herbstclient pad ~a\n"
|
|
|
|
(string-join (map number->string (home-herbstluftwm-configuration-padding config)) " ")))
|
|
|
|
(map (lambda (layout-pair)
|
|
|
|
(format #f "herbstclient load ~s '~s'\n"
|
|
|
|
(car layout-pair)
|
|
|
|
(cdr layout-pair)))
|
|
|
|
(home-herbstluftwm-configuration-layouts config))
|
|
|
|
(map (lambda (line)
|
|
|
|
(format #f "herbstclient ~a\n" line))
|
|
|
|
(home-herbstluftwm-configuration-extra config))))))
|
|
|
|
|
2022-04-14 10:39:25 +02:00
|
|
|
(define (add-herbstluftwm-executable config)
|
2022-06-14 06:30:23 +02:00
|
|
|
(home-xinit-extension
|
2022-04-14 10:39:25 +02:00
|
|
|
(wm
|
|
|
|
(list
|
|
|
|
(mixed-text-file
|
2022-06-15 05:15:30 +02:00
|
|
|
"xinitrc"
|
2022-04-15 09:48:15 +02:00
|
|
|
"exec " herbstluftwm "/bin/herbstluftwm --autostart " (home-herbstluftwm-autostart-file config))))))
|
2022-04-14 10:39:25 +02:00
|
|
|
|
|
|
|
(define home-herbstluftwm-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-herbstluftwm)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-herbstluftwm-packages)
|
|
|
|
(service-extension
|
2022-06-14 06:30:23 +02:00
|
|
|
home-xinit-service-type
|
2022-04-14 10:39:25 +02:00
|
|
|
add-herbstluftwm-executable)))
|
|
|
|
(compose identity)
|
|
|
|
(default-value (home-herbstluftwm-configuration))
|
|
|
|
(description "Install and configure herbstluftwm.")))
|