From 3315faabe0201f9a209235ef5291f02076dbcbac Mon Sep 17 00:00:00 2001
From: Gregor Kleen <gkleen@yggdrasil.li>
Date: Tue, 28 Jan 2025 10:59:42 +0100
Subject: ...

---
 accounts/gkleen@sif/niri/default.nix | 16 +++++------
 accounts/gkleen@sif/niri/swayosd.nix | 53 ++++++++++++++++++++++++++++++++++++
 accounts/gkleen@sif/niri/waybar.nix  | 16 ++++++-----
 3 files changed, 70 insertions(+), 15 deletions(-)
 create mode 100644 accounts/gkleen@sif/niri/swayosd.nix

(limited to 'accounts/gkleen@sif/niri')

diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index 17da42d6..f603a9f9 100644
--- a/accounts/gkleen@sif/niri/default.nix
+++ b/accounts/gkleen@sif/niri/default.nix
@@ -2,11 +2,10 @@
 let
   niri = config.programs.niri.package;
   terminal = lib.getExe config.programs.kitty.package;
-  lightctl = lib.getExe' config.services.avizo.package "lightctl";
-  volumectl = lib.getExe' config.services.avizo.package "volumectl";
   makoctl = lib.getExe' config.services.mako.package "makoctl";
   loginctl = lib.getExe' hostConfig.systemd.package "loginctl";
   systemctl = lib.getExe' hostConfig.systemd.package "systemctl";
+  swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client";
 
   focus_or_spawn = pkgs.writeShellApplication {
     name = "focus-or-spawn";
@@ -122,6 +121,7 @@ in {
   imports = [
     ./waybar.nix
     ./mako.nix
+    ./swayosd.nix
   ];
 
   config = {
@@ -577,27 +577,27 @@ in {
         };
 
         "XF86MonBrightnessUp" = {
-          action = spawn lightctl "-d" "-e4" "-n1" "up";
+          action = spawn swayosd-client "--brightness" "raise";
           allow-when-locked = true;
         };
         "XF86MonBrightnessDown" = {
-          action = spawn lightctl "-d" "-e4" "-n1" "down";
+          action = spawn swayosd-client "--brightness" "lower";
           allow-when-locked = true;
         };
         "XF86AudioRaiseVolume" = {
-          action = spawn volumectl "-d" "-u" "up";
+          action = spawn swayosd-client "--output-volume" "raise";
           allow-when-locked = true;
         };
         "XF86AudioLowerVolume" = {
-          action = spawn volumectl "-d" "-u" "down";
+          action = spawn swayosd-client "--output-volume" "lower";
           allow-when-locked = true;
         };
         "XF86AudioMute" = {
-          action = spawn volumectl "-d" "toggle-mute";
+          action = spawn swayosd-client "--output-volume" "mute-toggle";
           allow-when-locked = true;
         };
         "XF86AudioMicMute" = {
-          action = spawn volumectl "-d" "-m" "toggle-mute";
+          action = spawn swayosd-client "--input-volume" "mute-toggle";
           allow-when-locked = true;
         };
 
diff --git a/accounts/gkleen@sif/niri/swayosd.nix b/accounts/gkleen@sif/niri/swayosd.nix
new file mode 100644
index 00000000..48899c10
--- /dev/null
+++ b/accounts/gkleen@sif/niri/swayosd.nix
@@ -0,0 +1,53 @@
+{ pkgs, ... }:
+{
+  config = {
+    services.swayosd = {
+      enable = true;
+      topMargin = 0.0344;
+      stylePath = pkgs.runCommand "style.css" {
+        src = pkgs.writeText "style.scss" ''
+          window#osd {
+            padding: 12px 20px;
+            border-radius: 999px;
+            border: none;
+            background: rgba(0, 0, 0, 0.66);
+
+            #container {
+              margin: 16px;
+            }
+
+            image,
+            label {
+              color: rgb(255, 255, 255);
+            }
+
+            progressbar:disabled,
+            image:disabled {
+              opacity: 0.5;
+            }
+
+            progressbar {
+              min-height: 6px;
+              border-radius: 999px;
+              background: transparent;
+              border: none;
+            }
+            trough {
+              min-height: inherit;
+              border-radius: inherit;
+              border: none;
+              background: rgba(255, 255, 255, 0.5);
+            }
+            progress {
+              min-height: inherit;
+              border-radius: inherit;
+              border: none;
+              background: rgb(255, 255, 255);
+            }
+          }
+        '';
+        buildInputs = with pkgs; [sass];
+      } "scss -C --sourcemap=none $src $out";
+    };
+  };
+}
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix
index 625deea5..8667a4a4 100644
--- a/accounts/gkleen@sif/niri/waybar.nix
+++ b/accounts/gkleen@sif/niri/waybar.nix
@@ -1,5 +1,7 @@
-{ lib, pkgs, ... }:
-{
+{ lib, config, pkgs, ... }:
+let
+  swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client";
+in {
   config = {
     programs.waybar = {
       enable = true;
@@ -190,8 +192,8 @@
             icon-size = iconSize;
             tooltip-format = "{percent}%";
             format-icons = ["&#xf00da;" "&#xf00db;" "&#xf00dc;" "&#xf00dd;" "&#xf00de;" "&#xf00df;" "&#xf00e0;"];
-            on-scroll-up = "lightctl -d -e4 -n1 up";
-            on-scroll-down = "lightctl -d -e4 -n1 down";
+            on-scroll-up = "${swayosd-client} --brightness raise";
+            on-scroll-down = "${swayosd-client} --brightness lower";
           };
           wireplumber = {
             format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>";
@@ -200,9 +202,9 @@
             format-icons = ["&#xf057f;" "&#xf0580;" "&#xf057e;"];
             format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">&#xf075f;</span>";
             # ignored-sinks = ["Easy Effects Sink"];
-            on-scroll-up = "volumectl -d -u up";
-            on-scroll-down = "volumectl -d -u down";
-            on-click = "volumectl -d toggle-mute";
+            on-scroll-up = "${swayosd-client} --output-volume raise";
+            on-scroll-down = "${swayosd-client} --output-volume lower";
+            on-click = "${swayosd-client} --output-volume mute-toggle";
           };
         }
         {
-- 
cgit v1.2.3