40 lines
1.0 KiB
Bash
Executable File
40 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
export LC_ALL=POSIX LANG=POSIX; . "${HOME}/.owl4ce_var"
|
|
|
|
type -p ip iwgetid &>/dev/null || exec echo 'Install iproute2/wireless-tools!'
|
|
|
|
if iwgetid "$INT_WIFI" &>/dev/null; then
|
|
if [ -n "$(iwgetid "$INT_WIFI" | grep -oP '"\K[^"]+')" ]; then
|
|
if ip addr show "$INT_WIFI" | grep -Fqo 'inet'; then
|
|
status="$(iwgetid "$INT_WIFI" --raw)"
|
|
icon=''
|
|
else
|
|
status="No IP address (${INT_WIFI})"
|
|
icon=''
|
|
fi
|
|
else
|
|
status="Disconnected"
|
|
icon=''
|
|
fi
|
|
elif ip link show "$INT_ETH" &>/dev/null; then
|
|
if ip addr show "$INT_ETH" | grep -Fqo 'inet'; then
|
|
status="$(ip addr show "$INT_ETH" | grep -oP 'inet \K[^/]+' | sed 1q) (${INT_ETH})"
|
|
icon=''
|
|
else
|
|
status="No IP address (${INT_ETH})"
|
|
icon=''
|
|
fi
|
|
else
|
|
status="Network interface not found (${INT_ETH}/${INT_WIFI})"
|
|
icon=''
|
|
fi
|
|
|
|
case ${1} in
|
|
status) exec echo "$status"
|
|
;;
|
|
icon) exec echo "$icon"
|
|
;;
|
|
esac
|
|
|
|
exit ${?}
|