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 {