summaryrefslogtreecommitdiffstats
path: root/bin/hush/wifi
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-10-29 03:13:31 -0400
committerJesse Luehrs <doy@tozt.net>2018-10-29 03:13:31 -0400
commit243e280b5fd9527891a58d6578f2e659302908c7 (patch)
tree1443d96e6824c8e04355c2f1fb2c562a9afe2132 /bin/hush/wifi
parentdb8dd3e6140e66db46f309bff9054ba137eb797a (diff)
downloadconf-243e280b5fd9527891a58d6578f2e659302908c7.tar.gz
conf-243e280b5fd9527891a58d6578f2e659302908c7.zip
just use hostnames for this stuff
i don't really want another level of indirection
Diffstat (limited to 'bin/hush/wifi')
-rwxr-xr-xbin/hush/wifi38
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/hush/wifi b/bin/hush/wifi
new file mode 100755
index 0000000..38c70ee
--- /dev/null
+++ b/bin/hush/wifi
@@ -0,0 +1,38 @@
+#!/bin/sh
+set -eu
+set -o pipefail
+
+DEV=wlp3s0
+OPEN=open
+
+if [ -z "${1:-}" ]; then
+ if sudo netctl status $OPEN > /dev/null 2>&1; then
+ sudo netctl restart $OPEN
+ else
+ sudo systemctl restart netctl-auto@$DEV
+ fi
+else
+ case "$1" in
+ open)
+ if [ -n "${2:-}" ]; then
+ sudo sed -i "s/^ESSID=.*/ESSID='${2}'/" "/etc/netctl/${OPEN}"
+ fi
+
+ if sudo netctl status $OPEN > /dev/null 2>&1; then
+ sudo netctl restart $OPEN
+ else
+ sudo systemctl stop netctl-auto@$DEV
+ sudo netctl start $OPEN
+ fi
+ ;;
+ wpa)
+ if ! sudo systemctl status netctl-auto@$DEV > /dev/null 2>&1; then
+ sudo netctl stop $OPEN
+ sudo systemctl start netctl-auto@$DEV
+ fi
+ ;;
+ scan)
+ sudo iw dev $DEV scan | grep SSID | perl -nle 's/^.*SSID: //; print unless $seen{$_}++'
+ ;;
+ esac
+fi