Have rofi extend xbindkeys for keys to bind

This commit is contained in:
Tom Willemse 2022-04-20 22:23:27 -07:00
parent 33ef2ba4f1
commit fd82bcabcd
3 changed files with 27 additions and 6 deletions

View file

@ -280,8 +280,6 @@
((XF86AudioPlay) . "herbstclient spawn mpc toggle") ((XF86AudioPlay) . "herbstclient spawn mpc toggle")
((XF86AudioNext) . "herbstclient spawn mpc next") ((XF86AudioNext) . "herbstclient spawn mpc next")
((XF86AudioPrev) . "herbstclient spawn mpc prev") ((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) ((mod4 c)
("1" . "herbstclient move_index 0") ("1" . "herbstclient move_index 0")
("2" . "herbstclient move_index 1") ("2" . "herbstclient move_index 1")
@ -354,8 +352,6 @@
(list (list
"set_monitors 1920x1080+0+0" "set_monitors 1920x1080+0+0"
"focus_edge left" "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-apostrophe spawn dunstctl close"
"keybind Mod4-quotedbl spawn dunstctl close-all" "keybind Mod4-quotedbl spawn dunstctl close-all"
"keybind Mod4-Control-apostrophe spawn dunstctl history-pop" "keybind Mod4-Control-apostrophe spawn dunstctl history-pop"

View file

@ -8,7 +8,8 @@
#:use-module (guix gexp) #:use-module (guix gexp)
#:export (home-xbindkeys-service-type #:export (home-xbindkeys-service-type
home-xbindkeys-configuration)) home-xbindkeys-configuration
home-xbindkeys-extension))
(define-configuration home-xbindkeys-configuration (define-configuration home-xbindkeys-configuration
(package (package
@ -19,6 +20,12 @@
"Keybindings") "Keybindings")
(no-serialization)) (no-serialization))
(define-configuration home-xbindkeys-extension
(keybindings
(alist '())
"Keybindings")
(no-serialization))
(define (serialize-keymap parent keymap) (define (serialize-keymap parent keymap)
(string-join (string-join
(let* ((prefixes (filter (lambda (pair) (list? (cdr pair))) keymap)) (let* ((prefixes (filter (lambda (pair) (list? (cdr pair))) keymap))
@ -76,6 +83,13 @@
(define (add-xbindkeys-packages config) (define (add-xbindkeys-packages config)
(list (home-xbindkeys-configuration-package 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) (define (home-xbindkeys-shepherd-service config)
(list (list
(shepherd-service (shepherd-service
@ -101,5 +115,6 @@
home-shepherd-service-type home-shepherd-service-type
home-xbindkeys-shepherd-service))) home-xbindkeys-shepherd-service)))
(compose identity) (compose identity)
(extend home-xbindkeys-extensions)
(default-value (home-xbindkeys-configuration)) (default-value (home-xbindkeys-configuration))
(description "Install and configure xbindkeys."))) (description "Install and configure xbindkeys.")))

View file

@ -9,6 +9,7 @@
#:use-module (guix i18n) #:use-module (guix i18n)
#:use-module (guix modules) #:use-module (guix modules)
#:use-module (guix diagnostics) #:use-module (guix diagnostics)
#:use-module (oni home services xbindkeys)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:use-module (ice-9 match) #:use-module (ice-9 match)
@ -138,6 +139,12 @@
(append-map home-rofi-configuration-theme (append-map home-rofi-configuration-theme
extension-configs))))))) 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 (define home-rofi-service-type
(service-type (name 'home-rofi) (service-type (name 'home-rofi)
(extensions (extensions
@ -146,7 +153,10 @@
home-rofi-files-service) home-rofi-files-service)
(service-extension (service-extension
home-profile-service-type home-profile-service-type
home-rofi-profile-service))) home-rofi-profile-service)
(service-extension
home-xbindkeys-service-type
add-rofi-xbindkeys-keybindings)))
(compose concatenate) (compose concatenate)
(extend home-rofi-extension) (extend home-rofi-extension)
(default-value (home-rofi-configuration)) (default-value (home-rofi-configuration))