I wrote a network manager in shell.. kind of

reddit

Basically the title. Ever since I started using arch linux (btw), I've been trying to continually shrink my footprint on my laptop. And network managers are kind of bloatware. All you need to run this is wpa_supplicant and dhcpcd.

What it is

It's a shell script that does the annoying wpa_supplicant sh!t. You know, like having to specify minimal configuration every time you want to scan. Or having the kill the process whenever you want to switch networks. Having to write a whole line of shell whenever you want to connect to a network yadda yadda I'm sick of it. So I made this 🙂

Functionality

Right now, it has two primary functions and one sub-function.

The first is the scan function. Pretty self explanatory. Except here you don't have to manually set a configuration file, exec scan, and then exec scan_results. You just exec # device scan.

# device scan

The second is the connect function. Again, self explanatory; It allows you to connect to networks. Right now, it might only work for WPA but public networks might work as well.. but that's not all my friends. YOU CAN [easily] SAVE A PROFILE. The nomenclature is # device connect [ssid] [passwd] and if you want to save it, you just add save to the end like so # device connect [ssid] [passwd] save [name]. The name is optional and if it stays unset, the config file will be named after the ssid.

# device connect [ssid] [passwd]

# device connect [ssid] [passwd] save [filename]

Lastly (for now), but certainly not least is the -s flag for the scan function…

Are you tired of having to reconnect to a network that you've been on? Yes you're too lazy to make a configuration file and now you have to ask for the password (and probably ssid) again. Well I was. And so was my girlfriend. Introducing… -s (search)

# device scan -s

Stick that bad boy at the end of scan like so # device scan -s and it will parse through your wpa_supplicant config files and test if any of them match up with currently available networks…

and then it asks you if you want to connect.

You can also just say "n" and it will continue parsing until you've denied every recognized config or accept one.

Compatibility

You need the coreutils, wpa_supplicant, and dhcpcd. It may or may not work on dmenu. If it works, the scan will be pointless. But it would be cool to connect to a network.

Shortcomings

I would imagine a lot of things. This small step basically covers my daily network needs. But I don't manage any servers or know anything about networking. The code is also not looking suuuuupppeeerrr hot since I've been up two nights in a row working on it. Also, it has to be run in root as of right now.

In terms of what happens if you f up your nomenclature… idk. It will probably just return some wpa_supplicant errors. But yeah the whole root thing is not ideal.

Future plans

Probably configuring ip is at the top of the list. I want to be able to specify and interface. In the future, I may just grep it from ip by default. Also, more wpa_cli functionality. Additionally, I need to figure out the alias commands in wpa_cli. I may do my bluetooth in the same .sh.

Final thoughts

I'm at the end thinking what if everyone has a bunch of shell scripts and I'm just another brick in the wall. But I just thought it was cool. I hope you guys do to. If anyone likes it, I can definitely post a more revised version of the script. Have a goo day.

submitted by /u/xhitcramp
[link] [comments]