txt Dateien umbenannt und kleine fixes

This commit is contained in:
Désiré Werner Menrath 2023-11-16 17:27:05 +01:00
parent b25e076046
commit 209f8b732f

26
wire_g
View File

@ -25,8 +25,8 @@ WG_WDIR="/home/$USER/.config/wg_nmcli/"
# Pfad wg Icons # Pfad wg Icons
WG_PIC="/home/$USER/.icons/" WG_PIC="/home/$USER/.icons/"
# Wireguard TUNNEL auslesen mit grep nur Wireguard zeigen # Wireguard TUNNEL auslesen mit grep nur Wireguard zeigen
# mit sed alles nach dem ersten Leerzeichen bis Zeilenende weggeschneiden und .TUNNEL.txt schreiben # 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 # Variable der verfügbaren TUNNELanzeige für Yad
TUNNEL=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//') TUNNEL=$(nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//')
# Variable der aktiven TUNNELanzeige für Yad # Variable der aktiven TUNNELanzeige für Yad
@ -38,29 +38,29 @@ ACTIVE=$(nmcli connection show --active | grep -iPo "(.*)(wireguard)" | sed 's/
wg_stop(){ wg_stop(){
#Dieser befehl ist notwendig da nach dem import (erster Start) gestartete Tunnel nicht in der .tunnel Datei stehen. #Dieser befehl ist notwendig da nach dem import (erster Start) gestartete Tunnel nicht in der .tunnel Datei stehen.
nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${WG_WDIR}.tunnel.txt nmcli connection show | grep -iPo "(.*)(wireguard)" | sed 's/ .*//' > ${WG_WDIR}tunnel.txt
#Damit wird der inhalt von /home/$USER/.config/wg_nmcli/.tunnel.txt in ein Array gespeichert #Damit wird der inhalt von /home/$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) #echo ${lines[0]} #Damit wird der Inhalt ausgelesen. (Index angeben)
VALUE=$"*_*" VALUE=$"*_*"
for VALUE in "${lines[@]}" for VALUE in "${lines[@]}"
do do
# hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert # hier wird die Ausgabe von nmcli für die auswertung in die .stop.txt gespeichert
nmcli connection down "$VALUE" &> ${WG_WDIR}.stop.txt nmcli connection down "$VALUE" &> ${WG_WDIR}.stop.txt
if disable=$(grep -i 'deaktiviert\|deactivated' ${WG_WDIR}.stop.txt) if DISABLE=$(grep -i 'deaktiviert\|deactivated' ${WG_WDIR}.stop.txt)
then then
yad --image-on-top --image=${WG_PIC}wg-info.png \ yad --image-on-top --image=${WG_PIC}wg-info.png \
--undecorated --borders=8 --skip-taskbar \ --undecorated --borders=8 --skip-taskbar \
--text-align=center --no-buttons \ --text-align=center --no-buttons \
--timeout 2 --timeout-indicator=bottom \ --timeout 2 --timeout-indicator=bottom \
--text=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span> <b>disconnected</b></span>" --text=$"<span color='#0fad0a'><b>"$VALUE" Connection</b></span><span>" "<b>disconnected</b></span>"
fi fi
done done
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}Notify_PID.txt) ) IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) )
kill $lines kill $lines
} }
################################# END ################################################################## ############################################################################################################
############################################################################################################ ############################################################################################################
wg_notify(){ wg_notify(){
@ -78,7 +78,7 @@ wg_notify(){
--undecorated --borders=8 --skip-taskbar \ --undecorated --borders=8 --skip-taskbar \
--text-align=center --no-buttons --auto-close \ --text-align=center --no-buttons --auto-close \
--timeout 2 --timeout-indicator=bottom \ --timeout 2 --timeout-indicator=bottom \
--text=$"<span color='#0fad0a'><b>"$ACTIVE"</b></span> <span><b>powered</b></span>" & --text=$"<span color='#0fad0a'><b>"$ACTIVE"</b></span>" "<span><b>powered</b></span>" &
# autoconnect wird hier abgeschalten damit auch neu importierte nach einem Systemneustart nicht aktiv sind # 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
@ -91,8 +91,8 @@ wg_notify(){
--command="menu" & --command="menu" &
# Schreib die pid von Notify in # Schreib die pid von Notify in
pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}') pid=$(ps aux | grep yad | grep -v grep | awk '{print $2}')
echo $pid > ${WG_WDIR}Notify_PID.txt echo $pid > ${WG_WDIR}for-kill_pid.txt
IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}Notify_PID.txt) ) IFS=$'\n' lines=( $(awk '{print $2}' ${WG_WDIR}for-kill_pid.txt) ) # awk '{print $2}' heist, zeig mir nur die zweite Nummer an
} }
@ -193,7 +193,7 @@ up_or_down(){
# funktion end # funktion end
############################################################################################################ ############################################################################################################
############################################################################################################ ############################################################################################################
# function button "more" # function button "about"
about(){ about(){