mirror of
https://github.com/Ascyii/scripts.git
synced 2026-01-01 04:44:24 -05:00
Init
This commit is contained in:
19
shell/toggle_wifi.sh
Executable file
19
shell/toggle_wifi.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if an interface name is provided
|
||||
#if [ -z "$1" ]; then
|
||||
# echo "Usage: $0 <interface_name>"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
INTERFACE="wlo1"
|
||||
|
||||
# Parse the interface state from `ip a`
|
||||
STATE=$(ip a show "$INTERFACE" 2>/dev/null | grep -oP '(?<=state )\w+')
|
||||
|
||||
# Check if the interface exists
|
||||
if [ $STATE = "UP" ]; then
|
||||
sudo ip link set $INTERFACE down
|
||||
else
|
||||
sudo ip link set $INTERFACE up
|
||||
fi
|
||||
Reference in New Issue
Block a user