Added wifi click behavior.
This commit is contained in:
parent
f0fd387fbf
commit
aee151dbb9
|
@ -3,7 +3,15 @@
|
|||
"height": 35,
|
||||
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
|
||||
"modules-center": ["sway/window"],
|
||||
"modules-right": ["pulseaudio", "custom/network","backlight", "battery", "clock", "tray", "idle_inhibitor"],
|
||||
"modules-right": [
|
||||
"pulseaudio",
|
||||
"custom/network",
|
||||
"backlight",
|
||||
"battery",
|
||||
"clock",
|
||||
"tray",
|
||||
"idle_inhibitor"
|
||||
],
|
||||
"sway/workspaces": {
|
||||
"disable-scroll": true,
|
||||
"all-outputs": true
|
||||
|
@ -68,9 +76,10 @@
|
|||
"exec": "$HOME/.config/waybar/custom_modules/mediaplayer.py 2> /dev/null"
|
||||
},
|
||||
"custom/network": {
|
||||
"escape" :true,
|
||||
"exec": "$HOME/.config/waybar/custom_modules/wifi.sh 2> /dev/null",
|
||||
"escape": true,
|
||||
"exec": "$HOME/.config/waybar/custom_modules/wifi.sh status 2> /dev/null",
|
||||
"on-click": "rofi-wifi-menu",
|
||||
"on-click-right": "swaymsg exec \"~/.config/sway/scripts/tty-popup tunnel ~/.config/waybar/custom_modules/wifi.sh onclick\"",
|
||||
"restart-interval": 1,
|
||||
"return-type": "json"
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
main(){
|
||||
status(){
|
||||
connected_val="$(iwgetid 1> /dev/null ; echo $?)"
|
||||
if [ $connected_val -eq 255 ]; then
|
||||
if [ "$connected_val" -eq 255 ]; then
|
||||
echo '{"text": "⚠ Disconnected", "class":"disconnected"}'
|
||||
return
|
||||
else
|
||||
wg_val="$(wg 2> /dev/null ; echo $?)"
|
||||
if [ $wg_val -eq 0 ]; then
|
||||
if [ "$wg_val" -eq 0 ]; then
|
||||
echo "{\"text\": \" $(iwgetid -r)\", \"class\":\"connected\"}"
|
||||
else
|
||||
echo "{\"text\": \"聯 $(iwgetid -r)\", \"class\":\"secured\"}"
|
||||
|
@ -15,7 +15,17 @@ main(){
|
|||
fi
|
||||
}
|
||||
|
||||
while true; do
|
||||
main
|
||||
sleep 1
|
||||
done
|
||||
onclick(){
|
||||
wg_val="$(wg 2> /dev/null ; echo $?)"
|
||||
if [ "$wg_val" -eq 0 ]; then
|
||||
echo "Securing Connection"
|
||||
wg-quick up mullvad-us18
|
||||
else
|
||||
echo "Disconnecting tunnel"
|
||||
wg-quick down mullvad-us18
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
onclick|status) $1 ;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue
Block a user