-
-
Save trygveaa/b52a9f365e1b36b0e31fa17b2bf0f1d3 to your computer and use it in GitHub Desktop.
Wrapper around wpa_cli for less typing
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/bash | |
wpa_cli='wpa_cli -i wlp2s0' | |
if [ -z "$1" ]; then | |
$wpa_cli status | |
elif [ "$1" == "c" ]; then | |
$wpa_cli | |
elif [ "$1" == "l" ]; then | |
$wpa_cli list_networks | |
elif [ "$1" == "d" ]; then | |
$wpa_cli disconnect | |
elif [ "$1" == "r" ]; then | |
$wpa_cli reassociate | |
elif [ "$1" == "s" ]; then | |
$wpa_cli scan_results | |
$wpa_cli scan | |
wpa_block_scan /var/run/wpa_supplicant/wlan0 | |
$wpa_cli scan_results | |
elif [ "$1" == "e" ]; then | |
$wpa_cli list_networks | tail -n+2 | awk '{print $1}' | xargs -n1 $wpa_cli enable_network | |
elif [ "$1" == "w" ]; then | |
{ $wpa_cli status; ip a; } | perl -e 'use strict; my $s; while (<>) { if (/wpa_state=(.)/) { $s = $1; } elsif (/scope global/) { $s = "U" } } print "$s\n"' | |
elif [ -z "$2" ]; then | |
id=$($wpa_cli add_network | tail -n1) | |
$wpa_cli set_network $id key_mgmt NONE | |
$wpa_cli set_network $id ssid "\"$1\"" | |
$wpa_cli enable_network $id | |
else | |
id=$($wpa_cli add_network | tail -n1) | |
$wpa_cli set_network $id key_mgmt WPA-PSK | |
$wpa_cli set_network $id proto RSN | |
$wpa_cli set_network $id group CCMP TKIP | |
$wpa_cli set_network $id ssid "\"$1\"" | |
$wpa_cli set_network $id psk "\"$2\"" | |
$wpa_cli enable_network $id | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment