From 33b94a7f9d894daaeab4683433ae56f02c670cb0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 14 Dec 2023 11:41:25 +0000 Subject: [PATCH 1/3] home: wm: i3bar: add 'flatten' call This makes it easier to declare multiple blocks at once, as will be done in the next commit. --- modules/home/wm/i3bar/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/home/wm/i3bar/default.nix b/modules/home/wm/i3bar/default.nix index 645abeb..50913a4 100644 --- a/modules/home/wm/i3bar/default.nix +++ b/modules/home/wm/i3bar/default.nix @@ -17,7 +17,7 @@ in top = { icons = "awesome5"; - blocks = builtins.filter (attr: attr != { }) [ + blocks = builtins.filter (attr: attr != { }) (lib.flatten [ { block = "music"; # This format seems to remove the block when not playing, somehow @@ -92,7 +92,7 @@ in format = " $icon $timestamp.datetime(f:'%F %T') "; interval = 5; } - ]; + ]); }; }; }; From f47e66c28f711985618c0d67936246a233d5e59a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 14 Dec 2023 11:42:03 +0000 Subject: [PATCH 2/3] home: wm: i3bar: add VPN blocks --- modules/home/wm/default.nix | 25 +++++++++++++++++++++++++ modules/home/wm/i3bar/default.nix | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/modules/home/wm/default.nix b/modules/home/wm/default.nix index 6a615e5..f86049d 100644 --- a/modules/home/wm/default.nix +++ b/modules/home/wm/default.nix @@ -36,6 +36,31 @@ in i3bar = { enable = mkRelatedOption "i3bar configuration" [ "i3" ]; + + vpn = { + enable = mkEnableOption "VPN configuration"; + + blockConfigs = mkOption { + type = with types; listOf (attrsOf str); + default = [ + { + active_format = " VPN "; + service = "wg-quick-wg"; + } + { + active_format = " VPN (LAN) "; + service = "wg-quick-lan"; + } + ]; + example = [ + { + active_format = " WORK "; + service = "some-service-name"; + } + ]; + description = "list of block configurations, merged with the defauls"; + }; + }; }; rofi = { diff --git a/modules/home/wm/i3bar/default.nix b/modules/home/wm/i3bar/default.nix index 50913a4..5dbb505 100644 --- a/modules/home/wm/i3bar/default.nix +++ b/modules/home/wm/i3bar/default.nix @@ -59,6 +59,19 @@ in { block = "disk_space"; } + (lib.optionals cfg.vpn.enable + ( + let + defaults = { + block = "service_status"; + active_state = "Good"; + inactive_format = ""; + inactive_state = "Idle"; + }; + in + builtins.map (block: defaults // block) cfg.vpn.blockConfigs + ) + ) { block = "net"; format = " $icon{| $ssid|} $ip{| $signal_strength|} "; From b679280feaef74c67229e8a9f1671ad3e27981cd Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 14 Dec 2023 11:42:32 +0000 Subject: [PATCH 3/3] hosts: nixos: aramis: home: enable VPN blocks --- hosts/nixos/aramis/home.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hosts/nixos/aramis/home.nix b/hosts/nixos/aramis/home.nix index 66a0892..8f741dc 100644 --- a/hosts/nixos/aramis/home.nix +++ b/hosts/nixos/aramis/home.nix @@ -28,6 +28,13 @@ nm-applet.enable = true; # Terminal terminal.program = "alacritty"; + # WM configuration + wm = { + i3bar = { + # Show VPN blocks + vpn.enable = true; + }; + }; # Zathura document viewer zathura.enable = true; };