From 6f6090e0461942e88cac704595510025fac0e367 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sat, 27 Dec 2025 11:00:01 +0100 Subject: [PATCH] pinwheel: Update `work-vpn` script --- hosts/pinwheel/modules/waybar/default.nix | 22 ++++++++++++++++++---- hosts/pinwheel/modules/work/default.nix | 11 +++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hosts/pinwheel/modules/waybar/default.nix b/hosts/pinwheel/modules/waybar/default.nix index 3727863..690995b 100644 --- a/hosts/pinwheel/modules/waybar/default.nix +++ b/hosts/pinwheel/modules/waybar/default.nix @@ -85,11 +85,25 @@ let ''; work-vpn-status = pkgs.writeShellScript "work-vpn-status" '' - STAGING=$(systemctl is-active openvpn-work-staging.service) - [ "$STAGING" == "active" ] && echo "WORK-VPN STAGING ON" && exit 0 + ACTIVE_ENVS="" - PRODUCTION=$(systemctl is-active openvpn-work-production.service) - [ "$PRODUCTION" == "active" ] && echo "WORK-VPN PRODUCTION ON" && exit 0 + STAGING_STATUS=$(systemctl is-active openvpn-work-staging.service) + if [ "$STAGING_STATUS" == "active" ]; then + ACTIVE_ENVS="S" + fi + + PRODUCTION_STATUS=$(systemctl is-active openvpn-work-production.service) + if [ "$PRODUCTION_STATUS" == "active" ]; then + if [ -n "$ACTIVE_ENVS" ]; then + ACTIVE_ENVS="$ACTIVE_ENVS&P" + else + ACTIVE_ENVS="P" + fi + fi + + if [ -n "$ACTIVE_ENVS" ]; then + echo "WORK-VPN $ACTIVE_ENVS ON" + fi ''; toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" '' diff --git a/hosts/pinwheel/modules/work/default.nix b/hosts/pinwheel/modules/work/default.nix index a265b89..a02aa31 100644 --- a/hosts/pinwheel/modules/work/default.nix +++ b/hosts/pinwheel/modules/work/default.nix @@ -34,6 +34,17 @@ in # for `radio` pkgs.go-mockery pkgs.golangci-lint + + (pkgs.writeShellScriptBin "work-vpn" '' + case $1 in + up) + sudo sh -c "systemctl start openvpn-work-staging.service; systemctl start openvpn-work-production.service" + ;; + down) + sudo sh -c "systemctl stop openvpn-work-staging.service; systemctl stop openvpn-work-production.service" + ;; + esac + '') ]; programs.go = lib.mkIf goEnabled {