about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2023-02-02 14:15:25 +0100
committersternenseemann <sternenseemann@systemli.org>2023-02-02 14:17:06 +0100
commit33f4a858d5e2afc218f2975aaa64f24f4155f2d3 (patch)
tree447b8b3c7f500a45119cdf207ba32017c762b29c
parent2cafbd7e6881732e64477e11f4e0a1884e89f730 (diff)
machines/sternenseemann/wolfgang: display state of wireguard ifaces
-rw-r--r--machines/sternenseemann/wireguard.nix17
-rw-r--r--modules/user/sternenseemann/services/sway.nix29
2 files changed, 46 insertions, 0 deletions
diff --git a/machines/sternenseemann/wireguard.nix b/machines/sternenseemann/wireguard.nix
index b365dbe8..4011ee10 100644
--- a/machines/sternenseemann/wireguard.nix
+++ b/machines/sternenseemann/wireguard.nix
@@ -33,5 +33,22 @@ in
         };
       };
     };
+
+    vuizvui.user.sternenseemann.services.sway.extraStatus = builtins.listToAttrs (
+      builtins.concatLists (
+        builtins.map (
+          iface:
+          builtins.map (
+            ip:
+            {
+              name = "path_exists ${iface}${ip}";
+              value = ''
+                path = "/proc/sys/net/ip${ip}/conf/${iface}"
+              '';
+            }
+          ) [ "v4" "v6" ]
+        ) (builtins.attrNames config.networking.wg-quick.interfaces)
+      )
+    );
   };
 }
diff --git a/modules/user/sternenseemann/services/sway.nix b/modules/user/sternenseemann/services/sway.nix
index 11048c49..e0f5eca3 100644
--- a/modules/user/sternenseemann/services/sway.nix
+++ b/modules/user/sternenseemann/services/sway.nix
@@ -132,6 +132,17 @@ in {
           Additional lines to append to the configuration.
         '';
       };
+
+      extraStatus = lib.mkOption {
+        type = lib.types.attrsOf lib.types.lines;
+        default = {};
+        description = "Additional i3status entries to prepend to the bar.";
+        example = {
+          "path_exists LOCK" = ''
+            path = "/run/lock"
+          '';
+        };
+      };
     };
   };
 
@@ -304,6 +315,13 @@ in {
           interval = 1
         }
 
+        ${
+          lib.concatStrings (
+            lib.mapAttrsToList
+              (name: _: "order += \"${name}\"\n")
+              cfg.extraStatus
+          )
+        }
         order += "volume master"
         order += "battery all"
         order += "tztime kalenderwoche"
@@ -344,6 +362,17 @@ in {
         tztime offset {
           format = "%z"
         }
+
+        ${
+          lib.concatStrings (
+            lib.mapAttrsToList (name: config: ''
+              ${name} {
+                ${builtins.replaceStrings [ "\n" ] [ "\n  " ] config}
+              }
+            ''
+            ) cfg.extraStatus
+          )
+        }
       '';
     };
   };