fix: remove duplicate VPN notifications from moonarch-vpn
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 2s
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 2s
nm-applet already sends notifications for VPN state changes. The script's own notify-send calls caused duplicates on every toggle. Closes #4
This commit is contained in:
parent
fdedc8071f
commit
27247a4ffb
@ -10,7 +10,7 @@
|
|||||||
ACTIVE_PREFIX=" "
|
ACTIVE_PREFIX=" "
|
||||||
INACTIVE_PREFIX=" "
|
INACTIVE_PREFIX=" "
|
||||||
|
|
||||||
for cmd in nmcli walker notify-send; do
|
for cmd in nmcli walker; do
|
||||||
command -v "$cmd" >/dev/null 2>&1 || {
|
command -v "$cmd" >/dev/null 2>&1 || {
|
||||||
echo "Error: '$cmd' not found" >&2
|
echo "Error: '$cmd' not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -35,29 +35,17 @@ function extract_connection_name() {
|
|||||||
echo "$result"
|
echo "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Connect a VPN and notify the result.
|
# Connect a VPN.
|
||||||
# Requires nm-applet (or another NM secret agent) for interactive auth.
|
# Requires nm-applet (or another NM secret agent) for interactive auth.
|
||||||
function connect_vpn() {
|
function connect_vpn() {
|
||||||
local connection="$1"
|
local connection="$1"
|
||||||
local feedback
|
nmcli connection up "$connection"
|
||||||
|
|
||||||
if feedback=$(nmcli connection up "$connection" 2>&1); then
|
|
||||||
notify-send "VPN" "Connected to '$connection'"
|
|
||||||
else
|
|
||||||
notify-send -u critical "VPN" "Connection failed: $feedback"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disconnect a VPN and notify the result.
|
# Disconnect a VPN.
|
||||||
function disconnect_vpn() {
|
function disconnect_vpn() {
|
||||||
local connection="$1"
|
local connection="$1"
|
||||||
local feedback
|
nmcli connection down "$connection"
|
||||||
|
|
||||||
if feedback=$(nmcli connection down "$connection" 2>&1); then
|
|
||||||
notify-send "VPN" "Disconnected from '$connection'"
|
|
||||||
else
|
|
||||||
notify-send -u critical "VPN" "Disconnect failed: $feedback"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggle the VPN connection based on its current state.
|
# Toggle the VPN connection based on its current state.
|
||||||
@ -89,7 +77,6 @@ function main() {
|
|||||||
connections=$(list_vpn_connections)
|
connections=$(list_vpn_connections)
|
||||||
|
|
||||||
if [[ -z "$connections" ]]; then
|
if [[ -z "$connections" ]]; then
|
||||||
notify-send "VPN" "No VPN connections configured"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user