11#! /usr/bin/env bash
2- # wg-toggle - Toggle WireGuard configs avec rofi + sudo + notify-send + signal Waybar
2+ # wg-toggle - Toggle WireGuard configs avec rofi + pkexec + notify-send + signal Waybar
33
44CONF_DIR=" /etc/wireguard"
55SIGNAL=10
@@ -10,11 +10,11 @@ ICON_ERROR="dialog-error-symbolic"
1010# Tableau : [config, label, config, label, ...]
1111declare -a configs
1212
13- # Liste des configs via sudo
13+ # Liste des configs via pkexec
1414while read -r file; do
1515 name=$( basename " $file " .conf)
1616 configs+=(" $name " " ${name^} " )
17- done < <( sudo find " $CONF_DIR " -maxdepth 1 -type f -name " *.conf" 2> /dev/null)
17+ done < <( pkexec find " $CONF_DIR " -maxdepth 1 -type f -name " *.conf" 2> /dev/null)
1818
1919if [ ${# configs[@]} -eq 0 ]; then
2020 notify-send -u critical -t 5000 -i " $ICON_ERROR " " Erreur WireGuard" " Impossible de lister les tunnels"
5252
5353# Gestion de la sélection
5454if [[ " $selected " == " Disconnect" ]]; then
55- sudo wg-quick down " $active_iface " && \
55+ pkexec wg-quick down " $active_iface " && \
5656 notify-send -u normal -t 5000 -i " $ICON_DISCONNECTED " " WireGuard" " $active_label désactivé"
5757elif [ -n " $active_iface " ] && [ " $active_iface " = " $config " ]; then
58- sudo wg-quick down " $config " && \
58+ pkexec wg-quick down " $config " && \
5959 notify-send -u normal -t 5000 -i " $ICON_DISCONNECTED " " WireGuard" " $selected désactivé"
6060elif [ -n " $active_iface " ]; then
61- sudo wg-quick down " $active_iface " && sudo wg-quick up " $config " && \
61+ pkexec wg-quick down " $active_iface " && pkexec wg-quick up " $config " && \
6262 notify-send -u normal -t 5000 -i " $ICON_CONNECTED " " WireGuard" " $selected activé"
6363else
64- sudo wg-quick up " $config " && \
64+ pkexec wg-quick up " $config " && \
6565 notify-send -u normal -t 5000 -i " $ICON_CONNECTED " " WireGuard" " $selected activé"
6666fi
6767
0 commit comments