zaphyra's git: nixfiles

zaphyra's nixfiles

commit f47adcf771dcb998562a30f9e33194b71a4ed9ef
parent 619902116974f3dc311d1657cf2f54c208f04eaa
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Tue, 1 Jul 2025 19:36:11 +0200

config/home/zaphyra/services: add `swaync`
1 file changed, 241 insertions(+), 0 deletions(-)
A
config/home/zaphyra/services/swaync.nix
|
241
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/config/home/zaphyra/services/swaync.nix b/config/home/zaphyra/services/swaync.nix
@@ -0,0 +1,241 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}:
+
+{
+
+  services.swaync = {
+    enable = true;
+    settings = {
+      "$schema" = "/etc/xdg/swaync/configSchema.json";
+
+      keyboard-shortcuts = true;
+
+      cssPriority = "user";
+      positionX = "center";
+      positionY = "top";
+      fit-to-screen = false;
+      control-center-layer = "top";
+      control-center-height = 900;
+      control-center-positionX = "none";
+      control-center-positionY = "none";
+
+      widgets = [
+        "buttons-grid#actions"
+        "buttons-grid#powerprofiles"
+        "backlight"
+        "volume"
+        "title"
+      ];
+      widget-config = {
+        volume.label = "";
+        backlight.label = "󰃟";
+        title = {
+          text = "Notification Center";
+          clear-all-button = true;
+          button-text = "󰆴 Clear";
+        };
+
+        "buttons-grid#powerprofiles".actions = [
+          {
+            type = "toggle";
+            label = "   Power Saver ";
+            update-command = "sh -c '[[ $(powerprofilesctl get) == \"power-saver\" ]] && echo true || echo false'";
+            command = "sh -c 'swaync-client -cp; powerprofilesctl set power-saver'";
+          }
+          {
+            type = "toggle";
+            label = "   Balanced ";
+            update-command = "sh -c '[[ $(powerprofilesctl get) == \"balanced\" ]] && echo true || echo false'";
+            command = "sh -c 'swaync-client -cp; powerprofilesctl set balanced'";
+          }
+          {
+            type = "toggle";
+            label = "  Performance ";
+            update-command = "sh -c '[[ $(powerprofilesctl get) == \"performance\" ]] && echo true || echo false'";
+            command = "sh -c 'swaync-client -cp; powerprofilesctl set performance'";
+          }
+        ];
+        "buttons-grid#actions".actions = [
+          {
+            type = "toggle";
+            label = " ☕ ";
+            command = "systemctl --user is-active --quiet swayidle.service && systemctl --user stop swayidle.service || systemctl --user start swayidle.service";
+            update-command = "systemctl --user is-active --quiet swayidle.service && echo false || echo true";
+          }
+          {
+            type = "toggle";
+            label = "󰂛";
+            command = "swaync-client -d";
+            tooltip = "Do not disturb";
+            update-command = "swaync-client --get-dnd";
+          }
+          {
+            type = "toggle";
+            active = true;
+            label = "KB";
+            command = "sh -c '[[ $SWAYNC_TOGGLE_STATE == true ]] && ${lib.getExe pkgs.brightnessctl} --device='tpacpi::kbd_backlight' set 1 || ${lib.getExe pkgs.brightnessctl} --device='tpacpi::kbd_backlight' set 0'";
+            update-command = "sh -c '[[ $(${lib.getExe pkgs.brightnessctl} --device='tpacpi::kbd_backlight' get) == \"1\" ]] && echo true || echo false'";
+          }
+          {
+            type = "toggle";
+            active = true;
+            label = "直";
+            command = "sh -c '[[ $SWAYNC_TOGGLE_STATE == true ]] && nmcli radio wifi on || nmcli radio wifi off'";
+            update-command = "sh -c '[[ $(nmcli radio wifi) == \"enabled\" ]] && echo true || echo false'";
+          }
+          {
+            type = "toggle";
+            label = "";
+            command = "swaync-client -cp; ${config.home.sessionVariables.TERMINAL} -e ${lib.getExe pkgs.bluetui}";
+            update-command = "sh -c 'bluetoothctl show | grep -q \\\"Powered: yes\\\" && echo true || echo false'";
+          }
+          {
+            label = "";
+            command =
+              let
+                icons = "${pkgs.nwg-bar}/share/nwg-bar/images";
+                config = pkgs.writeText "nwg-bar.json" (
+                  builtins.toJSON [
+                    {
+                      label = "Lock";
+                      exec = "loginctl lock-session";
+                      icon = "${icons}/system-lock-screen.svg";
+                    }
+                    {
+                      label = "Logout";
+                      exec = "systemctl start niri-shutdown.target";
+                      icon = "${icons}/system-log-out.svg";
+                    }
+                    {
+                      label = "Reboot";
+                      exec = "systemctl reboot";
+                      icon = "${icons}/system-reboot.svg";
+                    }
+                    {
+                      label = "Shutdown";
+                      exec = "systemctl -i poweroff";
+                      icon = "${icons}/system-shutdown.svg";
+                    }
+                  ]
+                );
+                style = pkgs.writeText "nwg-bar.css" ''
+                  window {
+                    background: transparent;
+                  	padding: 20px;
+                  }
+
+                  /* Outer bar container, takes all the window width/height */
+                  #outer-box {
+                  	margin: 0px;
+                  }
+
+                  /* Inner bar container, surrounds buttons */
+                  #inner-box {
+                    box-shadow: 0 0 10px 0 rgba(0,0,0,.80);
+                    border-radius: 10px;
+                    background-color: #303030;
+                    border: 1px solid rgba(255, 255, 255, 0.08);
+1                  	margin: 10px;
+                  }
+                              
+                  button {
+                    border: 1px solid rgba(255, 255, 255, 0.08);
+                  	padding-left: 10px;
+                  	padding-right: 10px;
+                  	margin: 5px
+                  }
+
+                  button:hover {
+                    background: rgba(255, 255, 255, 0.1);
+                  }
+                '';
+                nwg-bar = lib.concatStringsSep " " [
+                  (lib.getExe pkgs.nwg-bar)
+                  "-t"
+                  config
+                  "-s"
+                  style
+                  "-p"
+                  "top"
+                  "-mt"
+                  "45"
+                ];
+
+              in
+              "swaync-client -cp; ${nwg-bar}";
+          }
+        ];
+      };
+    };
+    style = ''
+      @define-color border-color rgba(255, 255, 255, 0.08);
+
+      * {
+        font-family: "Adwaita Sans", "Symbols Nerd Font";
+      }
+
+      .control-center {
+        background-color: #303030;
+        border-radius: 0 0 10px 10px;
+        border: 2px solid @border-color;
+        border-top: 0;
+        box-shadow: 0 0 10px 0 rgba(0,0,0,.80);
+        padding: 4px;
+      }
+
+      .widget-title > button {
+        background: rgba(255, 255, 255, 0.06);
+        border: 1px solid @border-color;
+        border-radius: 4px;
+      }
+      .widget-title > button:hover {
+        background: rgba(255, 255, 255, 0.1);
+      }
+
+      .widget-backlight, .widget-volume, .widget-buttons-grid {
+        background: transparent;
+      }
+
+      .widget-backlight,
+      .widget-volume {
+        margin: 0px;
+        padding: 5px 10px;
+      }
+
+      /* Buttons */
+      .widget-buttons-grid {
+        padding: 0px;        
+      }
+
+      .widget-buttons-grid > flowbox > flowboxchild > button {
+        background: rgba(255, 255, 255, 0.06);
+        border: 1px solid @border-color;
+        border-radius: 4px;
+      }
+
+      .widget-buttons-grid > flowbox > flowboxchild > button:checked {
+        border-bottom: 2px solid rgb(74, 169, 108);
+      }
+
+      .widget-buttons-grid > flowbox > flowboxchild > button:hover {
+        background: rgba(255, 255, 255, 0.1);
+      }
+
+        /* Sliders */
+      scale {
+        padding: 0px;
+        margin: 0px 5px 0px 5px;
+      }
+
+      scale highlight {
+        background: rgb(74, 169, 108);
+        border-radius: 5px;
+      }
+    '';
+  };
+
+}