vpn button waybar
This commit is contained in:
@ -43,6 +43,7 @@
|
||||
"clock#date", // date
|
||||
"custom/right4",
|
||||
|
||||
"custom/wireguard", // wireguard
|
||||
"custom/wifi", // wi-fi
|
||||
"bluetooth", // bluetooth
|
||||
"custom/update", // system update
|
||||
@ -178,6 +179,19 @@
|
||||
"max-length": 8
|
||||
},
|
||||
|
||||
|
||||
// ──────────────────────────────────────────────────────────┤ wireguard ├───
|
||||
|
||||
"custom/wireguard": {
|
||||
"exec": "~/.config/waybar/scripts/wireguard-status.sh",
|
||||
"return-type": "json",
|
||||
"format": "{}",
|
||||
"on-click": "~/.config/waybar/scripts/wireguard-toggle.sh",
|
||||
"interval": 3,
|
||||
"min-length": 1,
|
||||
"max-length": 1
|
||||
},
|
||||
|
||||
// ──────────────────────────────────────────────────────────────┤ wi-fi ├───
|
||||
|
||||
"custom/wifi": {
|
||||
@ -186,7 +200,7 @@
|
||||
"format": "{}",
|
||||
"on-click": "~/.config/waybar/scripts/wifi-menu.sh",
|
||||
"on-click-right": "kitty --title ' Network Manager TUI' bash -c nmtui",
|
||||
"interval": 1,
|
||||
"interval": 3,
|
||||
"min-length": 1,
|
||||
"max-length": 1
|
||||
},
|
||||
@ -212,7 +226,7 @@
|
||||
|
||||
"on-click": "~/.config/waybar/scripts/bluetooth-menu.sh",
|
||||
"on-click-right": "kitty --title ' Bluetooth TUI' bash -c bluetui",
|
||||
"interval": 1,
|
||||
"interval": 3,
|
||||
"min-length": 1,
|
||||
"max-length": 1
|
||||
},
|
||||
@ -224,7 +238,7 @@
|
||||
"return-type": "json",
|
||||
"format": "{}",
|
||||
"on-click": "~/.config/waybar/scripts/system-update.sh up",
|
||||
"interval": 30,
|
||||
"interval": 240,
|
||||
"min-length": 1,
|
||||
"max-length": 1
|
||||
},
|
||||
|
3
.config/waybar/scripts/askpass.sh
Normal file
3
.config/waybar/scripts/askpass.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
rofi -dmenu -password -no-fixed-num-lines -p "Sudo password"
|
12
.config/waybar/scripts/wireguard-status.sh
Executable file
12
.config/waybar/scripts/wireguard-status.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
SERVICE_NAME="wg-quick@wg0"
|
||||
STATUS_CONNECTED_STR='{"text":"", "tooltip":"Tunnel connected."}'
|
||||
STATUS_DISCONNECTED_STR='{"text":"", "tooltip":"Tunnel disconnected"}'
|
||||
|
||||
function status_wireguard() {
|
||||
systemctl is-active $SERVICE_NAME >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
status_wireguard && echo $STATUS_CONNECTED_STR || echo $STATUS_DISCONNECTED_STR
|
16
.config/waybar/scripts/wireguard-toggle.sh
Executable file
16
.config/waybar/scripts/wireguard-toggle.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
SERVICE_NAME="wg-quick@wg0"
|
||||
|
||||
function status_wireguard() {
|
||||
systemctl is-active $SERVICE_NAME >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
function askpass() {
|
||||
rofi -dmenu -password -no-fixed-num-lines -p "Sudo password"
|
||||
}
|
||||
|
||||
status_wireguard && \
|
||||
SUDO_ASKPASS=~/.config/waybar/scripts/askpass.sh sudo -A systemctl stop $SERVICE_NAME || \
|
||||
SUDO_ASKPASS=~/.config/waybar/scripts/askpass.sh sudo -A systemctl start $SERVICE_NAME
|
@ -46,6 +46,7 @@ tooltip label {
|
||||
#idle_inhibitor,
|
||||
#clock,
|
||||
#custom-wifi,
|
||||
#custom-wireguard,
|
||||
#bluetooth,
|
||||
#custom-update,
|
||||
#mpris,
|
||||
@ -267,6 +268,17 @@ tooltip label {
|
||||
color: @hover-fg;
|
||||
}
|
||||
|
||||
/* ────────────────────────────────────────────────────────────────┤ wireguard ├───
|
||||
*/
|
||||
#custom-wireguard {
|
||||
background: @tray;
|
||||
padding: 0 8px 0 5px;
|
||||
}
|
||||
|
||||
#custom-wireguard:hover {
|
||||
color: @hover-fg;
|
||||
}
|
||||
|
||||
/* ────────────────────────────────────────────────────────────┤ bluetooth ├───
|
||||
*/
|
||||
#bluetooth {
|
||||
|
Reference in New Issue
Block a user