diff --git a/wg_stop b/wg_stop
index 507318e..4c3f697 100755
--- a/wg_stop
+++ b/wg_stop
@@ -7,17 +7,17 @@
wg_wdir="/home/$a_user/.config/wg_nmcli/"
wg_pic="/home/$a_user/.icons/"
#Damit wird der inhalt von /home/$a_user/.config/wg_nmcli/.tunnel.txt in ein Array gespeichert
- IFS=$'\n' lines=( "$(cat "${wg_wdir}.tunnel.txt")" )
+ IFS=$'\n' lines=( "$(cat ${wg_wdir}.tunnel.txt)" )
#echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
wert=$"*_*"
for wert in "${lines[@]}"
do
# rm /home/$a_user/.config/wg_nmcli/.tunnel.txt # falls Wireguard nicht richtig funktioniert hier die # wegnehmen
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
- nmcli connection down "$wert" &> "${wg_wdir}.stop.txt"
- if disable=$(grep -i '"deaktiviert"\|"disabled"' "${wg_wdir}.stop.txt")
+ nmcli connection down $wert &> ${wg_wdir}.stop.txt
+ if disable=$(grep -i 'deaktiviert\|disabled' ${wg_wdir}.stop.txt)
then
- notify-send --icon="${wg_pic}wg-stop.png" "$wert Connection disconnected."
+ notify-send --icon=${wg_pic}wg-stop.png "$wert Connection disconnected."
pkill yad
fi
diff --git a/wire_g b/wire_g
index 416e298..5dfd623 100755
--- a/wire_g
+++ b/wire_g
@@ -11,7 +11,7 @@ wg_wdir="/home/$a_user/.config/wg_nmcli/"
wg_pic="/home/$a_user/.icons/"
# Wireguard tunnel auslesen mit grep nur Wireguard zeigen
# mit sed alles nach dem ersten Leerzeichen bis Zeilenende weggeschneiden und .tunnel.txt schreiben
-nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > "${wg_wdir}.tunnel.txt"
+nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${wg_wdir}.tunnel.txt
# Variable der verfügbaren Tunnelanzeige für Yad
tunnel=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
# Variable der aktiven Tunnelanzeige für Yad
@@ -26,15 +26,15 @@ wg_notify(){
a_user=$(whoami)
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
wg_pic="/home/$a_user/.icons/"
- notify-send --icon="${wg_pic}wg-vpn.png" "$active powered"
+ notify-send --icon=${wg_pic}wg-vpn.png "$active powered"
# autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind
- nmcli con mod "$active" connection.autoconnect no
+ nmcli con mod $active connection.autoconnect no
# ab hier beginnt yad notify
#Pipe erstellen
PIPE="$HOME/.pipe.tmp"
- rm "$PIPE" > /dev/null 2>&1
- mkfifo "$PIPE"
- exec 3<> "$PIPE"
+ rm $PIPE > /dev/null 2>&1
+ mkfifo $PIPE
+ exec 3<> $PIPE
#Yad Dialog erstellen
yad --notification --listen --command=wire_g --icon-size=32 --no-middle <&3 &
#Menüeinträge definieren
@@ -60,18 +60,18 @@ import_wg(){
wgconf=$(yad --file --separator=" \n" \
--button="OK" --button="Cancel" \
--width=1200 --height=800 \
- --window-icon="${wg_pic}wg-import.png" \
+ --window-icon=${wg_pic}wg-import.png \
--title="Wireguard .conf Select file")
if [ "$?" = "0" ]
then
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
- if [ -n "$active" ]
+ if [[ -n $active ]]
then
wg_stop
- nmcli connection import type wireguard file "$wgconf" > "${wg_wdir}.tmp.txt"
+ nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt
wg_notify
else
- nmcli connection import type wireguard file "$wgconf" > "${wg_wdir}.tmp.txt"
+ nmcli connection import type wireguard file $wgconf > ${wg_wdir}.tmp.txt
wg_notify
fi
fi }
@@ -87,34 +87,34 @@ remove(){
wg_pic="/home/$a_user/.icons/"
wg_wdir="/home/$a_user/.config/wg_nmcli/"
tunnel=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
- nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> "${wg_wdir}.wg_noactive.txt"
- active=$(cat "${wg_wdir}.wg_noactive.txt")
+ nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' &> ${wg_wdir}.wg_noactive.txt
+ active=$(cat ${wg_wdir}.wg_noactive.txt)
selection=$(yad --no-click --list --height=300 --width=60 \
--title="Wire-G Trash" --center \
--fixed --buttons-layout=center \
--button="OK" --button="Cancel" \
- --separator="" --window-icon="${wg_pic}wg-trash.png" \
- --borders=8 --column 'Delete' "$tunnel")
+ --separator="" --window-icon=${wg_pic}wg-trash.png \
+ --borders=8 --column 'Delete' $tunnel)
if [ "$?" = "0" ]
then
- nmcli connection delete "$selection" &> "${wg_wdir}.tmp.txt"
- success=$(grep -i '"erfolgreich gelöscht"\|"successfully deleted"' "${wg_wdir}.tmp.txt")
+ nmcli connection delete $selection &> ${wg_wdir}.tmp.txt
+ success=$(grep -i '"erfolgreich gelöscht"\|"successfully deleted"' ${wg_wdir}.tmp.txt)
if [ "$?" = "0" ]
then
- yad --window-icon="${wg_pic}wg-trash.png" \
- --image-on-top --image="${wg_pic}wg-info.png" \
+ yad --window-icon=${wg_pic}wg-trash.png \
+ --image-on-top --image=${wg_pic}wg-info.png \
--text="Your tunnel $selection was successfully deleted.\n" \
--text-align=center --button="OK" --title "Wire-G Trash" \
--fixed --center --buttons-layout=center --borders=8 --center
else
- yad --window-icon="${wg_pic}wg-trash.png" \
- --image-on-top --image="${wg_pic}wg-info.png" \
+ yad --window-icon=${wg_pic}wg-trash.png \
+ --image-on-top --image=${wg_pic}wg-info.png \
--text="Oh something went wrong.\nPlease delete tunnel in the network manager." \
--text-align=center --button="OK" --title "Wire-G Trash" \
--fixed --center --buttons-layout=center --borders=8 --center
fi
- if [ "$selection" = "$active" ]
+ if [ $selection = $active ]
then
pkill wire_g
pkill yad
@@ -128,12 +128,12 @@ export -f remove
#funktion for active tunnel a stop
up_or_down(){
active=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
- if [ -z "$active" ]
+ if [[ -z $active ]]
then
- yad --image-on-top --image="${wg_pic}wg-info.png" \
- --text="There is no active tunnel that you could stop.\n" \
- --text-align=center --button="OK" --title "Wire-G" \
- --fixed --center --buttons-layout=center --borders=8 --center
+ yad --image-on-top --image=${wg_pic}wg-info.png \
+ --text="There is no active tunnel that you could stop.\n" \
+ --text-align=center --button="OK" --title "Wire-G" \
+ --fixed --center --buttons-layout=center --borders=8 --center
else
wg_stop
@@ -159,9 +159,9 @@ more(){
--fixed --borders=8 --close-on-unfocus \
--buttons-layout=center \
--button=Import:"bash -c import_wg" \
- --button="Wire-G Stop":up_or_down \
+ --button="Wire-G Stop":"bash -c up_or_down" \
--button="Cancel":1 \
- --separator="" --window-icon="${wg_pic}wg-vpn.png")
+ --separator="" --window-icon=${wg_pic}wg-vpn.png)
}
export -f more
@@ -172,10 +172,10 @@ export -f more
connect(){
- success=$(grep -i '"erfolgreich aktiviert"\|"successfully activated"' "${wg_wdir}.tmp.txt")
+ success=$(grep -i '"erfolgreich aktiviert"\|"successfully activated"' ${wg_wdir}.tmp.txt)
if [ "$?" = "0" ]
then
- nmcli con mod "$selection" connection.autoconnect no
+ nmcli con mod $selection connection.autoconnect no
wg_notify
fi }
@@ -190,26 +190,27 @@ selection=$(yad --no-click --list \
--fixed --buttons-layout=center \
--button="OK" --button="Cancel" \
--button=More:"bash -c more" --button=Remove:"bash -c remove" --separator="" \
- --window-icon="${wg_pic}wg-vpn.png" \
- --borders=8 --image-on-top --image="${wg_pic}wg-active.png" \
+ --window-icon=${wg_pic}wg-vpn.png \
+ --borders=8 --image-on-top --image=${wg_pic}wg-active.png \
--text "Activ Tunnel: $active
----------------------------------------------------------------------------------
If no tunnels are listed,
so they have to import their tunnel beforehand." \
- --column 'Selection' "$tunnel")
+ --column 'Selection' $tunnel)
if [ "$?" = "0" ]
then
- if [ -n "$active" ]
+ if [[ -n $active ]]
then
wg_stop
- nmcli connection up "$selection" &> "${wg_wdir}.tmp.txt"
+ nmcli connection up $selection &> ${wg_wdir}.tmp.txt
connect
else
- nmcli connection up "$selection" &> "${wg_wdir}.tmp.txt"
+ nmcli connection up $selection &> ${wg_wdir}.tmp.txt
connect
fi
fi
############################################ END ##########################################################
+