power menu, redshift, polybar
This commit is contained in:
26
.config/polybar/scripts/vpn-wireguard-wg/README.md
Normal file
26
.config/polybar/scripts/vpn-wireguard-wg/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Script: vpn-wireguard-wg
|
||||
|
||||
A script that shows the status of a chosen Wireguard connection.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You have to add the `wg` and `wg-quick` command to the `/etc/sudoers` NOPASSWD of your user:
|
||||
|
||||
```ini
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/wg
|
||||
user ALL=(ALL) NOPASSWD: /usr/bin/wg-quick
|
||||
```
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/vpn-wireguard-wg]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/vpn-wireguard-wg.sh
|
||||
interval = 5
|
||||
click-left = ~/polybar-scripts//vpn-wireguard-wg.sh --toggle &
|
||||
```
|
||||
BIN
.config/polybar/scripts/vpn-wireguard-wg/screenshots/1.png
Normal file
BIN
.config/polybar/scripts/vpn-wireguard-wg/screenshots/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
.config/polybar/scripts/vpn-wireguard-wg/screenshots/2.png
Normal file
BIN
.config/polybar/scripts/vpn-wireguard-wg/screenshots/2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
37
.config/polybar/scripts/vpn-wireguard-wg/vpn-wireguard-wg.sh
Normal file
37
.config/polybar/scripts/vpn-wireguard-wg/vpn-wireguard-wg.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
connection_status() {
|
||||
if [ -f "$config" ]; then
|
||||
connection=$(sudo wg show "$config_name" 2>/dev/null | head -n 1 | awk '{print $NF }')
|
||||
|
||||
if [ "$connection" = "$config_name" ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "2"
|
||||
fi
|
||||
else
|
||||
echo "3"
|
||||
fi
|
||||
}
|
||||
|
||||
config="$HOME/wg/wireguard.conf"
|
||||
config_name=$(basename "${config%.*}")
|
||||
|
||||
case "$1" in
|
||||
--toggle)
|
||||
if [ "$(connection_status)" = "1" ]; then
|
||||
sudo wg-quick down "$config" 2>/dev/null
|
||||
else
|
||||
sudo wg-quick up "$config" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ "$(connection_status)" = "1" ]; then
|
||||
echo "#1 $config_name"
|
||||
elif [ "$(connection_status)" = "3" ]; then
|
||||
echo "#3 Config not found!"
|
||||
else
|
||||
echo "#2 down"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user