{ config, lib, pkgs, ... }: # SwayOSD: a transient on-screen popup for volume and brightness changes. { options.modules.desktop.utilities.osd.enable = lib.mkEnableOption "the SwayOSD volume and brightness popup"; config = lib.mkIf config.modules.desktop.utilities.osd.enable { environment.systemPackages = [ pkgs.swayosd ]; # The udev rule chgrps each backlight's brightness node to `video` and adds # group write, so the server dims the panel without root. # Membership below grants the running session that access. services.udev.packages = [ pkgs.swayosd ]; users.users.${config.user.name}.extraGroups = [ "video" ]; # The server draws the popups, so it runs for the whole graphical session. # It binds to the target uwsm activates. home-manager.users.${config.user.name}.systemd.user.services.swayosd = { Unit = { Description = "SwayOSD on-screen display server"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" ]; }; Service = { ExecStart = lib.getExe' pkgs.swayosd "swayosd-server"; Restart = "on-failure"; }; Install.WantedBy = [ "graphical-session.target" ]; }; registry.keybind.${config.networking.hostName} = { brightness-up = { keys = "XF86MonBrightnessUp"; repeating = true; action = { kind = "exec"; command = "${lib.getExe' pkgs.swayosd "swayosd-client"} --brightness raise"; }; }; brightness-down = { keys = "XF86MonBrightnessDown"; repeating = true; action = { kind = "exec"; command = "${lib.getExe' pkgs.swayosd "swayosd-client"} --brightness lower"; }; }; }; }; }