Initial commit
This commit is contained in:
commit
82a76598fa
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.disabled
|
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Auto-disable Wi-Fi
|
||||
|
||||
Script for NetworkManager, which disables Wi-Fi when a wired connection comes up, and enables Wi-Fi when a wired
|
||||
connection comed down.
|
||||
|
||||
### Files
|
||||
* `auto-disable-wifi` should be installed to NetworkManager directory.
|
||||
#### Installation
|
||||
* `install.sh` script copies above script to its destination.
|
||||
|
||||
### TODO
|
||||
* Nothing
|
15
auto-disable-wifi.sh
Normal file
15
auto-disable-wifi.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
wired_interfaces="en.*|eth.*"
|
||||
if [[ "$1" =~ $wired_interfaces ]]; then
|
||||
case "$2" in
|
||||
up)
|
||||
#nmcli radio wifi off
|
||||
rfkill block wifi
|
||||
;;
|
||||
down)
|
||||
#nmcli radio wifi on
|
||||
rfkill unblock wifi
|
||||
;;
|
||||
esac
|
||||
fi
|
20
install.sh
Executable file
20
install.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
run_directory=$(dirname "$0")
|
||||
|
||||
if [ -f $run_directory/.disabled ]; then
|
||||
echo "Installation is disabled. Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Copying script to NetworkManager directory..."
|
||||
sudo cp $run_directory/auto-disable-wifi.sh /etc/NetworkManager/dispatcher.d/99-auto-disable-wifi
|
||||
sudo chown root:root /etc/NetworkManager/dispatcher.d/99-auto-disable-wifi
|
||||
sudo chmod 744 /etc/NetworkManager/dispatcher.d/99-auto-disable-wifi
|
||||
|
||||
if ! command -v rfkill &> /dev/null; then
|
||||
echo "WARNING: rfkill is not installed."
|
||||
fi
|
||||
|
||||
echo "Finished install. Exiting..."
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user