diff --git a/oni/home/data/config.scm b/oni/home/data/config.scm index 6648adf..cfbfa46 100644 --- a/oni/home/data/config.scm +++ b/oni/home/data/config.scm @@ -241,4 +241,67 @@ (service home-xbindkeys-service-type) - (service home-herbstluftwm-service-type)))) + (service home-herbstluftwm-service-type + (home-herbstluftwm-configuration + (tags '(dev web game)) + (mouse-bindings + '(("Mod4-Button1" . "move") + ("Mod4-Button2" . "zoom") + ("Mod4-Button3" . "resize"))) + (settings + '((default_frame_layout . 2) + (frame_border_active_color . "#3d3d3d") + (frame_border_normal_color . "#222222") + (frame_bg_normal_color . "#111111") + (frame_bg_active_color . "#263f1f") + (frame_border_width . 0) + (window_border_width . 2) + (window_border_inner_width . 0) + (window_border_normal_color . "#222222") + (window_border_active_color . "#1f3f3f") + (window_border_inner_color . "#111111") + (always_show_frame . 0) + (frame_gap . 30) + (window_gap . 30) + (frame_padding . -30) + (frame_bg_transparent . 1) + (smart_window_surroundings . 0) + (smart_frame_surroundings . 0) + (mouse_recenter_gap . 0) + (swap_monitors_to_get_tag . 0) + (update_dragged_clients . 1) + (tree_style . "╾│ ├└╼─┐"))) + (attributes + '(((theme tiling reset) . 1) + ((theme floating reset) . 1))) + (rules + '(("focus=on") + ("class=Emacs" "tag=dev" "index=01" "switchtag=on" "hook=emacs") + ("class~'URxvt|kitty" "tag=dev" "index=1" "switchtag=on" "hook=urxvt") + ("class~'Conkeror|[Ff]irefox|Chromium" "tag=dev" "index=00" "switchtag=on") + ("class=Pinentry" "pseudotile=on") + ("class=Alsaplayer" "pseudotile=on") + ("class=Gcr-prompter" "pseudotile=on") + ("class=Steam" "title='Steam Login'" "pseudotile=on") + ("class=Steam" "title~'Steam - News .*'" "pseudotile=on") + ("class=" "title=Steam" "pseudotile=on") + ("class=xfreerdp" "floating=on" "tag=work" "index=0" "switchtag=on") + ("windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)'" "pseudotile=on") + ("windowtype='_NET_WM_WINDOW_TYPE_DIALOG'" "focus=on") + ("windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)'" "manage=off") + ("class=pinball.exe" "pseudotile=on"))) + (padding '(0 0 0 16 16)) + (layouts + '((web clients max:0) + (dev split horizontal:0.580:1 (clients max:0) (clients vertical:0)))) + (extra + (list + "set_monitors 1920x1080+0+0" + "focus_edge left" + "keybind Mod4-r spawn rofi -show run" + "keybind Mod4-w spawn rofi -show window -window-command \"$HOME/usr/bin/hlwm-switch-to-window {window}\"" + "systemctl --user start cmst" + "keybind Mod4-apostrophe spawn dunstctl close" + "keybind Mod4-quotedbl spawn dunstctl close-all" + "keybind Mod4-Control-apostrophe spawn dunstctl history-pop" + "keybind Mod4-Mod1-apostrophe spawn dunstctl context"))))))) diff --git a/oni/home/services/herbstluftwm.scm b/oni/home/services/herbstluftwm.scm index 6b68b2c..e69a17c 100644 --- a/oni/home/services/herbstluftwm.scm +++ b/oni/home/services/herbstluftwm.scm @@ -1,11 +1,13 @@ (define-module (oni home services herbstluftwm) #:use-module (gnu services configuration) #:use-module (gnu packages wm) + #:use-module (gnu packages shells) #: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) + #:use-module (srfi srfi-1) #:export (home-herbstluftwm-service-type home-herbstluftwm-configuration)) @@ -13,18 +15,112 @@ (define-configuration/no-serialization home-herbstluftwm-configuration (package (package herbstluftwm) - "Package use for setting herbstluftwm")) + "Package use for setting herbstluftwm") + (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")) (define (add-herbstluftwm-packages config) (list (home-herbstluftwm-configuration-package config))) +(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 (home-herbstluftwm-autostart-file config) + (apply mixed-executable-file + "autostart" + "#!" zsh "/bin/zsh\n" + "herbstclient emit_hook reload\n" + "herbstclient keyunbind --all\n" + (let ((tags (home-herbstluftwm-configuration-tags config))) + (append (list "herbstclient mouseunbind --all\n") + (map (lambda (binding) + (format #f "herbstclient mousebind ~a ~a\n" + (car binding) (cdr binding))) + (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) + (list "herbstclient merge_tag default\n") + '()) + (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)))))) + (define (add-herbstluftwm-executable config) (home-xsession-extension (wm (list (mixed-text-file "xsession" - "exec " herbstluftwm "/bin/herbstluftwm"))))) + "exec " herbstluftwm "/bin/herbstluftwm --autostart " (home-herbstluftwm-autostart-file config)))))) (define home-herbstluftwm-service-type (service-type