55 lines
2.0 KiB
Bash
Executable File
55 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# NetworkManager dispatcher helper: run Sxmo network hooks as the X session
|
|
# user. The dispatcher runs as root; keeping status files user-owned avoids
|
|
# breaking sxmo_status.sh, dmenu and the status bar after a network event.
|
|
set -u
|
|
|
|
DEVICE="${1:-}"
|
|
ACTION="${2:-}"
|
|
[ -n "$DEVICE" ] && [ -n "$ACTION" ] || exit 0
|
|
|
|
export HOME=/home/user
|
|
export USER=user
|
|
export LOGNAME=user
|
|
export SHELL=/bin/ash
|
|
export XDG_RUNTIME_DIR=/run/user/10000
|
|
export XDG_CONFIG_HOME=/home/user/.config
|
|
export XDG_CACHE_HOME=/home/user/.cache
|
|
export XDG_DATA_HOME=/home/user/.local/share
|
|
export XDG_STATE_HOME=/home/user/.local/state
|
|
export SXMO_WM=dwm
|
|
export SXMO_STATE=/run/user/10000/sxmo.state
|
|
export SXMO_STATUS_NAME=default
|
|
export DISPLAY=:0
|
|
export PATH="/home/user/.local/bin:/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin"
|
|
|
|
TYPE="$(nmcli -g GENERAL.TYPE device show "$DEVICE" 2>/dev/null || true)"
|
|
[ -n "$TYPE" ] || TYPE=unknown
|
|
|
|
case "$ACTION" in
|
|
up|vpn-up)
|
|
sxmo_hook_network_up.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
|
|
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
|
|
;;
|
|
down|vpn-down)
|
|
sxmo_hook_network_down.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
|
|
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
|
|
;;
|
|
pre-up|vpn-pre-up)
|
|
sxmo_hook_network_pre_up.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
|
|
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
|
|
;;
|
|
pre-down|vpn-pre-down)
|
|
sxmo_hook_network_pre_down.sh "$DEVICE" "$TYPE" >/dev/null 2>&1 || true
|
|
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
|
|
;;
|
|
connectivity-change|dhcp4-change|dhcp6-change|dns-change)
|
|
sxmo_hook_statusbar.sh network "$TYPE" "$DEVICE" >/dev/null 2>&1 || true
|
|
;;
|
|
*) exit 0 ;;
|
|
esac
|
|
# Feed the flip's external panel with the same main network indicators the
|
|
# status bar shows. No-op on non-flip targets and when the cover daemon is off.
|
|
/usr/bin/bananarchy-cover-event.sh network >/dev/null 2>&1 || true
|
|
exit 0
|