diff --git a/README.md b/README.md index 8da5597..ebf2086 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ --- +## 📷 Preview + +![preview](./preview.png) + ## ✨ Main Applications - [X] Hyprland diff --git a/home/config/scripts/wgStatus.sh b/home/config/scripts/wgStatus.sh new file mode 100755 index 0000000..29e5744 --- /dev/null +++ b/home/config/scripts/wgStatus.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +INTERFACE="wg0" + +if [ "$1" = "toggle" ]; then + if ip link show "$INTERFACE" >/dev/null 2>&1; then + pkexec wg-quick down "$INTERFACE" + else + pkexec wg-quick up "$INTERFACE" + fi + exit 0 +fi + +if ! ip link show "$INTERFACE" >/dev/null 2>&1; then + echo "{\"text\": \"Not Connected\", \"tooltip\": \"WireGuard is down\", \"alt\": \"disconnected\", \"class\": \"disconnected\"}" + exit 0 +fi + +echo "{\"text\": \"Connected\", \"tooltip\": \"WireGuard connected\", \"alt\": \"connected\", \"class\": \"connected\"}" +exit 0 diff --git a/home/config/waybar/config.jsonc b/home/config/waybar/config.jsonc index 8697e63..78dd63d 100644 --- a/home/config/waybar/config.jsonc +++ b/home/config/waybar/config.jsonc @@ -26,6 +26,7 @@ "modules-right": [ "wlr/taskbar", + "custom/wireguard", "idle_inhibitor", "network", "cpu", @@ -83,6 +84,7 @@ "modules-right": [ "wlr/taskbar", + "custom/wireguard", "temperature", "idle_inhibitor", "network", diff --git a/home/config/waybar/modules.jsonc b/home/config/waybar/modules.jsonc index c29a138..86e4b8f 100644 --- a/home/config/waybar/modules.jsonc +++ b/home/config/waybar/modules.jsonc @@ -215,5 +215,20 @@ "activated": "󰅶", "deactivated": "󰾫" } + }, + + "custom/wireguard": { + "format": "{icon}", + "format-icons": { + "connected": "󰒘", + "disconnected": "" + }, + "exec": "~/.config/scripts/wgStatus.sh", + "exec-if": "which wg-quick", + "on-click": "~/.config/scripts/wgStatus.sh toggle", + "tooltip": true, + "interval": 3, + "return-type": "json", + "escape": true } } diff --git a/home/config/waybar/style.css b/home/config/waybar/style.css index 06036ee..ab94e10 100644 --- a/home/config/waybar/style.css +++ b/home/config/waybar/style.css @@ -42,6 +42,7 @@ tooltip label { #idle_inhibitor, #custom-cava, +#custom-wireguard, #clock, #cpu, #memory, @@ -78,6 +79,7 @@ tooltip label { #memory #temperature, #network, +#custom-wireguard, #battery { margin-left: 4px; } @@ -123,6 +125,7 @@ tooltip label { /* Center Icon */ #custom-os, +#custom-wireguard, #network, #idle_inhibitor { padding-left: 10px; padding-right: 14px; diff --git a/preview.png b/preview.png new file mode 100644 index 0000000..d643d4c Binary files /dev/null and b/preview.png differ diff --git a/system/modules/wireguard.nix b/system/modules/wireguard.nix index 8381c77..5deb8f7 100644 --- a/system/modules/wireguard.nix +++ b/system/modules/wireguard.nix @@ -1,4 +1,6 @@ -{ lib, ... }: +{ + ... +}: let configPath = "/etc/wireguard/wg0.conf"; in