dotfiles

Cem's Dotfiles
git clone git://git.ckyln.com/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit a7233b2ef6fa143306cf944b7c6bf65fb898baa1
parent 7b75f58140a9edf0ffe0a2764e36d2234dd918aa
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed,  8 Jan 2020 19:09:45 +0300

wpa_add_network: added script

Diffstat:
A.local/bin/wpa_add_network | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/.local/bin/wpa_add_network b/.local/bin/wpa_add_network @@ -0,0 +1,33 @@ +#!/bin/sh + +if [ "$(tty)" = "not a tty" ]; then + getvalue() { VALUE="$(dmenu -p "$1")" ;} + prompt() { [ "$(printf "No\\nYes" | dmenu -i -p "$1")" = "Yes" ] ;} + printf "tty" +else + getvalue() { + printf "$1\n" + read VALUE + } + prompt() { + printf "$1\ny/n: " + read ans + case "$ans" in + [Yy]*) return 0 ;; + *) return 1 ;; + esac + } +fi + +[ -z "$1" ] && getvalue "Please enter the ssid:" && SSID="$VALUE" +[ -z "$SSID" ] && exit 1 + +if prompt "Is the network password protected?" ; then + getvalue "Enter the password" + PASSWORD="$VALUE" + [ -z "$PASSWORD" ] && exit 1 + wpa_passphrase "$SSID" "$PASSWORD" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf +else + printf "network={\n ssid=$SSID\n keymgmt=NONE\n priority=-999\n }\n" | \ + sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf +fi