Created
November 14, 2015 04:05
-
-
Save cameronism/3c7879b63f5c0fa43f50 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/sh | |
# 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 -c 1 | cut -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 | |
sudo rfkill "$ACTION" "$ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Little addition: