utilies

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 76a47ded01cd89790f1521346b1ddc7486ee7b23
parent af2933adebb0587ea9cd8c6d09244ad279c68edb
Author: Taco-C <perian.forod@gmail.com>
Date:   Thu,  2 Jul 2020 00:19:06 +0200

Add wifi-select

Diffstat:
MREADME.md | 1+
Awifi-select | 25+++++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -10,5 +10,6 @@ A handful of (useful) scripts for unix-like systems. | `ordur` | | Print the time as text. | | `rgc` | | Groff to PDF compiler. | | `update-stagit.sh` | [stagit](https://git.codemadness.org/stagit/file/README.html) | Makes static html pages for all repos in `/srv/git/` into `/srv/http/`, and an index page. | +| `wifi-select` | `rofi` or `dmenu`, NetworkManager | Connect to a wifi with NetworkManager. | | `wiktionaire` | `rofi` or `dmenu`, `surf` or another web browser. | Search for word on Wiktionary from the desktop. | diff --git a/wifi-select b/wifi-select @@ -0,0 +1,24 @@ +#!/bin/sh + +_connect() { + # Gets list of saved configurations. + _saved_nets=`nmcli -f NAME con show | grep -v "^NAME"` + + # Gets available networks. + _ssids=`nmcli device wifi list | grep -v "^IN" | cut -c2- | awk '{print $2}' | grep -v "^--$"` + + # Filter the available networks based on the saved ones, and send to rofi. + _ssid=`echo "$_saved_nets" | grep "$_ssids" | rofi -dmenu` + + [ "$_ssid" = "" ] && exit + + nmcli device wifi connect $_ssid >/dev/null + _notify_current +} + +_notify_current() { + _current=`nmcli device status | grep "^wls3" | awk '{print $4}'` + notify-send "IEEE 802.11b-nettverk" "$_current" --urgency=low +} + +[ "$1" = "-n" ] && _notify_current || _connect+ \ No newline at end of file