Created
July 20, 2016 17:29
-
-
Save tpenguinltg/ebda5c5b2d8fceedadc3ee923fb3d442 to your computer and use it in GitHub Desktop.
netplugd script to disable wireless on wired connection
This file contains hidden or 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 | |
# | |
# netplug - policy agent for netplugd | |
# | |
# Copyright 2003 Key Research, Inc. | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License, version 2, as | |
# published by the Free Software Foundation. You are forbidden from | |
# redistributing or modifying it under the terms of any other license, | |
# including other versions of the GNU General Public License. | |
# | |
# This program is distributed in the hope that it will be useful, but | |
# WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# General Public License for more details. | |
PATH=/usr/bin:/bin:/usr/sbin:/sbin | |
export PATH | |
wired_dev="enp0s25" | |
wireless_dev="wlp3s0" | |
dev="$1" | |
action="$2" | |
case "$action" in | |
in) | |
if [ "$dev" = "$wired_dev" ]; then | |
# If Ethernet plugged in, disable Wi-Fi | |
/sbin/ip link set "$wired_dev" up | |
exec /sbin/ip link set "$wireless_dev" down | |
fi | |
;; | |
out) | |
if [ "$dev" = "$wired_dev" ]; then | |
# If Ethernet unplugged, enable Wi-Fi | |
/sbin/ip link set "$wireless_dev" up | |
exec /sbin/ip link set "$wired_dev" down | |
fi | |
;; | |
probe) | |
exec /sbin/ip link set $dev up >/dev/null 2>&1 | |
;; | |
*) | |
echo "I have been called with a funny action of '%s'!" 1>&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment