diff --git a/wg_on_start b/wg_on_start index 92d14d8..18376fc 100644 --- a/wg_on_start +++ b/wg_on_start @@ -24,8 +24,11 @@ export TEXTDOMAINDIR="/usr/share/locale" WG_WDIR="/home/$USER/.config/wg_nmcli/" # Pfad wg Icons WG_PIC="/home/$USER/.icons/" +IFS=$'\n' WG_START=( $(cat ${WG_WDIR}onstart.txt) ) +nmcli connection up "$WG_START" +nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> ${WG_WDIR}onstart.txt +ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') - ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') &> ${WG_WDIR}onstart.txt case $LANG in de_DE.UTF-8) OPEN=öffnen ;; @@ -37,6 +40,7 @@ WG_PIC="/home/$USER/.icons/" --text-align=center --no-buttons --auto-close \ --timeout 1 \ --text=$""$ACTIVE" powered" + # autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind IFS=$'\n' lines=( $(cat ${WG_WDIR}tunnel.txt) ) nmcli con mod "$lines" connection.autoconnect no @@ -47,6 +51,7 @@ WG_PIC="/home/$USER/.icons/" else chmod -x /home/"$USER"/.local/bin/wg_on_start fi + yad --notification \ --image="${WG_PIC}wg-vpn.png" \ --icon-size=32 --no-middle \ @@ -54,6 +59,7 @@ WG_PIC="/home/$USER/.icons/" --menu="Wire-G $OPEN!/sbin/wire_g |$ACTIVE stop!/sbin/wg_stop" \ --command="menu" & + # Schreib die pid von Notify in pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}') echo $pid > ${WG_WDIR}for-kill_pid.txt diff --git a/wire_g b/wire_g index 0d2d28b..5ff0d33 100755 --- a/wire_g +++ b/wire_g @@ -37,7 +37,9 @@ ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ ############################################################################################################ wg_notify(){ - ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') &> ${WG_WDIR}onstart.txt + + nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> ${WG_WDIR}onstart.txt + ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') case $LANG in de_DE.UTF-8) OPEN=öffnen ;;