Add herbstluftwm configuration with xsession extension

The herbstluftwm configuration isn't complete yet, it's only the package so far,
but it does extend the xsession service to include a line in xsession to execute
the window manager in a bit of a hacky way.

This also adds a ‘mixed-executable-file’ function which is the same as the
‘mixed-text-file’ except that it also sets the executable bit for the computed
file.
This commit is contained in:
Tom Willemse 2022-04-14 01:39:25 -07:00
parent 00f51af69d
commit 9363fb88cf
3 changed files with 91 additions and 11 deletions

View file

@ -7,6 +7,7 @@
#:use-module (gnu packages)
#:use-module (gnu packages admin)
#:use-module (gnu packages shellutils)
#:use-module (gnu packages wm)
#:use-module (guix gexp)
#:use-module (oni home services xdisorg)
#:use-module (oni home services xmodmap)
@ -14,7 +15,8 @@
#:use-module (oni home services xsession)
#:use-module (oni home services compton)
#:use-module (oni home services xbindkeys)
#:use-module (oni home services zsh))
#:use-module (oni home services zsh)
#:use-module (oni home services herbstluftwm))
(home-environment
(packages (list (specification->package+output "glibc-locales")))
@ -218,10 +220,12 @@
(home-xsession-configuration
(configuration
(list
"xrdb -cpp m4 -merge \"${HOME}/.config/X11/Xresources\" -I\"${HOME}/.config/X11/Xresources.d\""
"xrandr --setprovideroutputsource modesetting NVIDIA-0"
"xrandr --auto"
"xrandr --dpi 96"))))
(mixed-text-file
"xsession"
"xrdb -cpp m4 -merge \"${HOME}/.config/X11/Xresources\" -I\"${HOME}/.config/X11/Xresources.d\"\n"
"xrandr --setprovideroutputsource modesetting NVIDIA-0\n"
"xrandr --auto\n"
"xrandr --dpi 96\n")))))
(service home-picom-service-type
(home-picom-configuration
@ -235,4 +239,6 @@
"class_g = 'trayer'"
"bounding_shaped"))))))
(service home-xbindkeys-service-type))))
(service home-xbindkeys-service-type)
(service home-herbstluftwm-service-type))))

View file

@ -0,0 +1,41 @@
(define-module (oni home services herbstluftwm)
#:use-module (gnu services configuration)
#:use-module (gnu packages wm)
#:use-module (gnu home services)
#:use-module (gnu home services utils)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (oni home services xsession)
#:export (home-herbstluftwm-service-type
home-herbstluftwm-configuration))
(define-configuration/no-serialization home-herbstluftwm-configuration
(package
(package herbstluftwm)
"Package use for setting herbstluftwm"))
(define (add-herbstluftwm-packages config)
(list (home-herbstluftwm-configuration-package config)))
(define (add-herbstluftwm-executable config)
(home-xsession-extension
(wm
(list
(mixed-text-file
"xsession"
"exec " herbstluftwm "/bin/herbstluftwm")))))
(define home-herbstluftwm-service-type
(service-type
(name 'home-herbstluftwm)
(extensions
(list (service-extension
home-profile-service-type
add-herbstluftwm-packages)
(service-extension
home-xsession-service-type
add-herbstluftwm-executable)))
(compose identity)
(default-value (home-herbstluftwm-configuration))
(description "Install and configure herbstluftwm.")))

View file

@ -4,20 +4,52 @@
#:use-module (gnu home services utils)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:export (home-xsession-service-type
home-xsession-configuration))
home-xsession-configuration
home-xsession-extension))
(define-configuration/no-serialization home-xsession-configuration
(define-configuration home-xsession-configuration
(configuration
(text-config '())
"Configuration"))
(define-configuration/no-serialization home-xsession-extension
(wm
(text-config '())
"String"))
(define* (mixed-executable-file name #:key guile #:rest text)
"Return an object representing store file NAME containing TEXT. TEXT is a
sequence of strings and file-like objects, as in:
(mixed-text-file \"profile\"
\"export PATH=\" coreutils \"/bin:\" grep \"/bin\")
This is the declarative counterpart of 'text-file*'."
(define build
(let ((text (if guile (drop text 2) text)))
(gexp (call-with-output-file (ungexp output "out")
(lambda (port)
(set-port-encoding! port "UTF-8")
(display (string-append (ungexp-splicing text)) port)
(chmod port #o555))))))
(computed-file name build #:guile guile))
(define (xsession-home-files config)
`(("xsession"
,(mixed-text-file
`((".xsession"
,(mixed-executable-file
"xsession"
(string-join (home-xsession-configuration-configuration config) "\n")))))
(serialize-text-config 'configuration (home-xsession-configuration-configuration config))))))
(define (home-xsession-extensions original-config extension-configs)
(home-xsession-configuration
(inherit original-config)
(configuration
(append (home-xsession-configuration-configuration original-config)
(home-xsession-extension-wm (last extension-configs))))))
(define home-xsession-service-type
(service-type
@ -27,5 +59,6 @@
home-files-service-type
xsession-home-files)))
(compose identity)
(extend home-xsession-extensions)
(default-value (home-xsession-configuration))
(description "Configure xsession.")))