summaryrefslogtreecommitdiff
path: root/debian/.local/bin/ethwifi
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
commit28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch)
tree85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/ethwifi
parent8470ff001befcfd0f626dea69a9e76d43aee0511 (diff)
updates
Diffstat (limited to 'debian/.local/bin/ethwifi')
-rwxr-xr-xdebian/.local/bin/ethwifi31
1 files changed, 31 insertions, 0 deletions
diff --git a/debian/.local/bin/ethwifi b/debian/.local/bin/ethwifi
new file mode 100755
index 0000000..26366e9
--- /dev/null
+++ b/debian/.local/bin/ethwifi
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+check_ethernet() {
+ interfaces=$(ip link | awk '/^[0-9]+: e/ {print substr($2, 1, length($2)-1)}')
+ for iface in $interfaces; do
+ ip link show "$iface" | grep -q 'state UP' && return 0
+ done
+ return 1
+}
+
+toggle_wifi() {
+ wifi_status=$(nmcli radio wifi) # Get current Wi-Fi status
+ if [ "$wifi_status" = "enabled" ]; then
+ nmcli radio wifi off
+ notify-send "📡 wifi: OFF"
+ else
+ nmcli radio wifi on
+ notify-send "📡 wifi: ON"
+ fi
+}
+
+# Check Ethernet and toggle Wi-Fi based on its status
+if check_ethernet; then
+ nmcli radio wifi off
+ notify-send "📡 wifi: OFF (Ethernet connected)"
+else
+ toggle_wifi
+fi
+
+# Refresh status bar
+pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"