-
-
Save matthew-nm/bea59084d72e90448fd60b2fc5f96e5a to your computer and use it in GitHub Desktop.
rfkill-toggle.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage ./rfkill-toggle.sh [IDENTIFIER] | |
# where IDENTIFIER is the index no. of an rfkill switch or one of: | |
# wifi wlan bluetooth uwb ultrawideband wimax wwan gps fm nfc | |
ID=`rfkill list "$1" | head -n 1 | cut -d : -f 1` | |
SOFT="/sys/class/rfkill/rfkill$ID/soft" | |
if [ ! -f "$SOFT" ]; then | |
echo "no such identifier" | |
exit 1 | |
fi | |
ACTION="block" | |
if [ $(cat "$SOFT") -eq 1 ]; then | |
ACTION="unblock" | |
fi | |
rfkill "$ACTION" "$ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked from @cameronism
Updated ID to use head line filter (not byte filter) as well as ":" delimiter for cut.
Updated final command to not use
sudo
.