From 9ecf8144589f978ae5df50e4afcce05d45c9c427 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 14 Sep 2024 14:58:36 +0200 Subject: [PATCH] feat: support printscreen and brightness scripts in dwl --- home/home-configuration.scm | 2 - home/modules/ruther/home/dwl/config.h | 9 ++-- .../ruther/home/dwl/scripts/brightness.sh | 17 +++++++ home/modules/ruther/home/dwl/scripts/print.sh | 2 +- home/modules/ruther/home/dwl/wm.scm | 46 ++++++++++++++++++- 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 home/modules/ruther/home/dwl/scripts/brightness.sh diff --git a/home/home-configuration.scm b/home/home-configuration.scm index 1568185..11d9558 100644 --- a/home/home-configuration.scm +++ b/home/home-configuration.scm @@ -132,8 +132,6 @@ ;; TODO the services should be started by shepherd (".start-dwl" ,(start-dwl #:dwl dwl-mine #:waybar waybar-mine)) - (".config/dwl/scripts/print.sh" ,(local-file "dotfiles/dwl/print.sh")) - (".config/gammastep/config.ini" ,(local-file "dotfiles/gammastep.ini")) (".config/zsh/direnv/direnv" ,direnv) diff --git a/home/modules/ruther/home/dwl/config.h b/home/modules/ruther/home/dwl/config.h index 76c2b58..0551ea7 100644 --- a/home/modules/ruther/home/dwl/config.h +++ b/home/modules/ruther/home/dwl/config.h @@ -227,11 +227,12 @@ static const Key keys[] = { { 0, Key_XF86AudioPlay2, spawn, SHCMD(SEQUENCE_DETECTOR "-g mpris play") }, { 0, Key_XF86AudioNext, spawn, SHCMD(SEQUENCE_DETECTOR "-g mpris next") }, { 0, Key_XF86AudioPrev, spawn, SHCMD(SEQUENCE_DETECTOR "-g mpris prev") }, - { 0, Key_XF86MonBrightnessUp, spawn, SHCMD("$HOME/.config/dwl/scripts/brightness.sh up") }, - { 0, Key_XF86MonBrightnessDown, spawn, SHCMD("$HOME/.config/dwl/scripts/brightness.sh down") }, - { 0, Key_Print, spawn, SHCMD("$HOME/.config/dwl/scripts/print.sh -s") }, + { 0, Key_XF86MonBrightnessUp, spawn, SHCMD("%brightness% up") }, + { 0, Key_XF86MonBrightnessDown, spawn, SHCMD("%brightness% down") }, + { 0, Key_Print, spawn, SHCMD("%printscreen% -s") }, - { MODKEY, Key_y, spawn, SHCMD("emacs-anywhere") }, + /* { MODKEY, Key_y, spawn, SHCMD("emacs-anywhere") }, */ + // todo better passmenu with totp etc. { MODKEY, Key_p, spawn, SHCMD("passmenu") }, { MODKEY, Key_c, togglesticky, {0} }, diff --git a/home/modules/ruther/home/dwl/scripts/brightness.sh b/home/modules/ruther/home/dwl/scripts/brightness.sh new file mode 100644 index 0000000..363d01c --- /dev/null +++ b/home/modules/ruther/home/dwl/scripts/brightness.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +function send_notification() { + brightness=$(printf "%.0f\n" $(brillo -G)) + dunstify -a "brightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness %" +} + +case $1 in + up) + brillo -A 2 -q + ;; + down) + brillo -U 2 -q + ;; +esac + +send_notification $1 diff --git a/home/modules/ruther/home/dwl/scripts/print.sh b/home/modules/ruther/home/dwl/scripts/print.sh index eb8c3df..62b23e9 100755 --- a/home/modules/ruther/home/dwl/scripts/print.sh +++ b/home/modules/ruther/home/dwl/scripts/print.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env -S guix shell slurp grim wl-clipboard -- bash +#!/usr/bin/env bash out="$HOME/screens/$(date +%Y/%Y%m%d_%H%M%S).png" diff --git a/home/modules/ruther/home/dwl/wm.scm b/home/modules/ruther/home/dwl/wm.scm index ba9ab43..8ecc8e3 100644 --- a/home/modules/ruther/home/dwl/wm.scm +++ b/home/modules/ruther/home/dwl/wm.scm @@ -6,6 +6,8 @@ #:use-module (gnu packages emacs) #:use-module (gnu packages xdisorg) #:use-module (gnu packages terminals) + #:use-module (gnu packages hardware) + #:use-module (gnu packages image) #:use-module (ruther packages wayland) #:use-module (ruther home passwords) @@ -43,6 +45,46 @@ "XLIBS = xcb xcb-icccm") #$original-flags)))))) +;; TODO: make this a guile script +;; but I am too lazy for now. +(define brightness-script-builder + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (set-path-environment-variable + "PATH" (list "bin") + (list #$brillo)) + + (invoke #$(file-append bash "/bin/sh") + #$(local-file "scripts/brightness.sh"))))) + +(define-public brightness-script + (program-file + "brightness-script" + brightness-script-builder)) + +;; TODO: make this a guile script +;; but I am too lazy for now. +(define printscreen-script-builder + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + + (set-path-environment-variable + "PATH" (list "bin") + (list #$slurp + #$grim + #$wl-clipboard)) + + (invoke #$(file-append bash "/bin/bash") + #$(local-file "scripts/print.sh"))))) + +(define-public printscreen-script + (program-file + "printscreen-script" + printscreen-script-builder)) + (define-public dwl-mine-unwrapped (let ((base (make-dwl-xwayland dwl-0.7))) (package @@ -66,7 +108,9 @@ (("\"foot\"") (string-append "\"" #$foot "/bin/foot\"")) (("\"rofi\"") (string-append "\"" #$rofi-wayland "/bin/rofi\"")) (("\"passmenu\"") (string-append "\"" #$password-store-wl "/bin/passmenu\"")) - (("\"emacsclient\"") (string-append "\"" #$emacs-pgtk "/bin/emacsclient\"")))))))))))) + (("\"emacsclient\"") (string-append "\"" #$emacs-pgtk "/bin/emacsclient\"")) + (("%brightness%") #$brightness-script) + (("%printscreen%") #$printscreen-script))))))))))) ;; Packages I use when in the WM, it's dependent on those. (define wm-packages -- 2.48.1