From fd82bcabcd2f998a23931f3986e81d7cac949c13 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 20 Apr 2022 22:23:27 -0700 Subject: [PATCH] Have rofi extend xbindkeys for keys to bind --- oni/home/data/config.scm | 4 ---- oni/home/services/xbindkeys.scm | 17 ++++++++++++++++- oni/home/services/xdisorg.scm | 12 +++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/oni/home/data/config.scm b/oni/home/data/config.scm index 217b239..09f0949 100644 --- a/oni/home/data/config.scm +++ b/oni/home/data/config.scm @@ -280,8 +280,6 @@ ((XF86AudioPlay) . "herbstclient spawn mpc toggle") ((XF86AudioNext) . "herbstclient spawn mpc next") ((XF86AudioPrev) . "herbstclient spawn mpc prev") - ((mod4 r) . "herbstclient spawn rofi -show run") - ((mod4 w) . "herbstclient spawn rofi -show window -window-command \"/home/chelys/usr/bin/hlwm-switch-to-window {window}\"") ((mod4 c) ("1" . "herbstclient move_index 0") ("2" . "herbstclient move_index 1") @@ -354,8 +352,6 @@ (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}\"" "keybind Mod4-apostrophe spawn dunstctl close" "keybind Mod4-quotedbl spawn dunstctl close-all" "keybind Mod4-Control-apostrophe spawn dunstctl history-pop" diff --git a/oni/home/services/xbindkeys.scm b/oni/home/services/xbindkeys.scm index 0fe2a9c..f361594 100644 --- a/oni/home/services/xbindkeys.scm +++ b/oni/home/services/xbindkeys.scm @@ -8,7 +8,8 @@ #:use-module (guix gexp) #:export (home-xbindkeys-service-type - home-xbindkeys-configuration)) + home-xbindkeys-configuration + home-xbindkeys-extension)) (define-configuration home-xbindkeys-configuration (package @@ -19,6 +20,12 @@ "Keybindings") (no-serialization)) +(define-configuration home-xbindkeys-extension + (keybindings + (alist '()) + "Keybindings") + (no-serialization)) + (define (serialize-keymap parent keymap) (string-join (let* ((prefixes (filter (lambda (pair) (list? (cdr pair))) keymap)) @@ -76,6 +83,13 @@ (define (add-xbindkeys-packages config) (list (home-xbindkeys-configuration-package config))) +(define (home-xbindkeys-extensions original-config extension-configs) + (home-xbindkeys-configuration + (inherit original-config) + (keybindings + (apply append (home-xbindkeys-configuration-keybindings original-config) + (map home-xbindkeys-extension-keybindings extension-configs))))) + (define (home-xbindkeys-shepherd-service config) (list (shepherd-service @@ -101,5 +115,6 @@ home-shepherd-service-type home-xbindkeys-shepherd-service))) (compose identity) + (extend home-xbindkeys-extensions) (default-value (home-xbindkeys-configuration)) (description "Install and configure xbindkeys."))) diff --git a/oni/home/services/xdisorg.scm b/oni/home/services/xdisorg.scm index 26ed246..1f3bdf7 100644 --- a/oni/home/services/xdisorg.scm +++ b/oni/home/services/xdisorg.scm @@ -9,6 +9,7 @@ #:use-module (guix i18n) #:use-module (guix modules) #:use-module (guix diagnostics) + #:use-module (oni home services xbindkeys) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) @@ -138,6 +139,12 @@ (append-map home-rofi-configuration-theme extension-configs))))))) +(define (add-rofi-xbindkeys-keybindings config) + (home-xbindkeys-extension + (keybindings + '(((mod4 r) . "herbstclient spawn rofi -show run") + ((mod4 w) . "herbstclient spawn rofi -show window -window-command \"/home/chelys/usr/bin/hlwm-switch-to-window {window}\""))))) + (define home-rofi-service-type (service-type (name 'home-rofi) (extensions @@ -146,7 +153,10 @@ home-rofi-files-service) (service-extension home-profile-service-type - home-rofi-profile-service))) + home-rofi-profile-service) + (service-extension + home-xbindkeys-service-type + add-rofi-xbindkeys-keybindings))) (compose concatenate) (extend home-rofi-extension) (default-value (home-rofi-configuration))