From 43c251b90d3d864e51c02e551186442a2d11b444 Mon Sep 17 00:00:00 2001 From: rope Date: Sun, 17 May 2026 13:47:59 +0100 Subject: [PATCH] macbook: add wob OSD for keyboard backlight keys wob (Wayland OSD Bar) runs as a systemd user service listening on a FIFO. Keyboard brightness keybindings now pipe the new brightness percentage to the FIFO after each adjustment, showing a progress bar overlay. Co-Authored-By: Claude Sonnet 4.6 --- hosts/FredOS-Macbook.nix | 22 +++++++++++++++++++++- settings/hyprland.nix | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/hosts/FredOS-Macbook.nix b/hosts/FredOS-Macbook.nix index 3136e5b..5ef0ee2 100644 --- a/hosts/FredOS-Macbook.nix +++ b/hosts/FredOS-Macbook.nix @@ -33,10 +33,30 @@ HandleLidSwitchExternalPower = "suspend"; }; - home-manager.users.fred = { ... }: { + home-manager.users.fred = { pkgs, ... }: { wayland.windowManager.hyprland.settings.monitor = [ ",preferred,auto,auto" ]; + # wob reads 0-100 integers from a FIFO and shows a progress bar overlay + systemd.user.services.wob = { + Unit = { + Description = "Wayland OSD Bar"; + After = [ "graphical-session.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.writeShellScript "wob-start" '' + rm -f "%t/wob.fifo" + mkfifo "%t/wob.fifo" + tail -f "%t/wob.fifo" | ${pkgs.wob}/bin/wob + ''}"; + ExecStopPost = "${pkgs.coreutils}/bin/rm -f %t/wob.fifo"; + Restart = "on-failure"; + }; + Install.WantedBy = [ "graphical-session.target" ]; + }; + systemd.user.services.kbd-backlight-init = { Unit = { Description = "Set keyboard backlight to 10% on login"; diff --git a/settings/hyprland.nix b/settings/hyprland.nix index d6a65e3..eb90b6a 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -313,8 +313,18 @@ in ", XF86MonBrightnessUp, exec, swayosd-client --brightness raise" ", XF86MonBrightnessDown, exec, swayosd-client --brightness lower" ] ++ lib.optionals isMacbook [ - ", XF86KbdBrightnessUp, exec, brightnessctl -d smc::kbd_backlight set +10%" - ", XF86KbdBrightnessDown, exec, brightnessctl -d smc::kbd_backlight set 10%-" + ", XF86KbdBrightnessUp, exec, ${pkgs.writeShellScript "kbd-bright-up" '' + ${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight set +10% + brightness=$(${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight get) + max=$(${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight max) + echo $(( brightness * 100 / max )) > "$XDG_RUNTIME_DIR/wob.fifo" + ''}" + ", XF86KbdBrightnessDown, exec, ${pkgs.writeShellScript "kbd-bright-down" '' + ${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight set 10%- + brightness=$(${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight get) + max=$(${pkgs.brightnessctl}/bin/brightnessctl -d smc::kbd_backlight max) + echo $(( brightness * 100 / max )) > "$XDG_RUNTIME_DIR/wob.fifo" + ''}" ]; bindl = [