You are not logged in.

#1 2012-06-10 23:41:47

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Dead-simple bashscript wifi connector

I've been a wicd user for quite some time and it has generally worked very well for me.  However, it does seem to do an aweful lot, and I wasn't sure I needed all that.  This abundance of features also made it a little slower than I liked.  Recently, too, when wicd first starts, it "rescans" for networks several times before it allows me to finally connect to any of the discovered networks.  I have seen other users mention this last concern too.[1]

Other recent wifi issues caused me to have to get used to the 'manual' methods of connecting.  I really started preferring the manual methods, except for the fact that there was a lot of repetition of the same steps every time I wanted to connect.  This seemed like a perfect job for a simple script.  And so I created my new wifi script.

To use just type `wifi`.  You'll be given a list of available networks.  Enter the number for your choice.  If it is an unsecured network, then you are done.  If you choose a secure network (highlighted in red in the list) and if that network hasn't been set up via "wpa_passphrase" then wifi will inform you of the error and tell you how to fix it: run "wifi new <ssid> <passphrase>".  This will configure wpa_supplicant for that network* then it will give you the list with the option to connect to that secure network.

*Note: This only does the most basic wpa_supplicant.conf set up from wpa_passphrase.  If more is needed that will (currently) have to be done manually, but only once per network.  I may improve this, or perhaps not, as I don't mind manually configuring the file once for each new network.

"Wifi" was written for a 256 color terminal.  If you don't have a 256 color terminal, then change/delete the escape color codes.

UPDATE: Get it at the link in my signature.

[1]: An example of this problem with a potential solution for anyone who wants to stick with wicd.  I checked my wicd config, and it apparently stored info on every network I had ever connected to - it was a HUGE file.

Last edited by Trilby (2012-06-25 17:52:03)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#2 2012-06-11 01:43:32

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,725
Website

Re: Dead-simple bashscript wifi connector

Trilby wrote:

Feel free to let me know how this can/should be improved.

I have a few syntactic remarks. You can drop the quote inside double-brackets:

if [[ $foo == new ]]
then

You can also use

[[ -z $foo ]]

instead of

[[ $foo == "" ]]

Offline

#3 2012-06-11 02:03:10

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

Thanks.  I made those changes, added a bit in the awk script to highlight the currently active AP if there is one, and added a a few (minimal) comments.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#4 2012-06-11 05:43:20

Iranon
Member
Registered: 2011-06-11
Posts: 146

Re: Dead-simple bashscript wifi connector

Very nice. I've always done this pseudo-manually (braindead script without prompts), because I felt the graphical tools were overkill. This adds everything I've been missing occasionally.

Offline

#5 2012-06-11 07:57:09

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

OK, I ditched the wifi-themer, and just put variables in for the colors.  Actually I used wifi-themer to insert variable names for me, then I just defined the variables at the top of 'wifi'.  I've added a second theme, or you can easily create your own.

Find the newest version on my github.  Next week I'll start testing it more on secured networks.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#6 2012-06-15 17:01:01

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

Just tested this on a secure network and it failed miserably.  Luckily the major problems were just foolish mistakes and were easy to fix.  This is now working on a couple secure wireless networks for me and the updates are on git.

One known remaining issue is that it will not associate with unsecure networks with spaces in the name (essid).  Spaces in names for secure networks are fine as this is handled in a different part of the script.  I know what needs change to fix this, but I haven't gotten to it yet - stay tuned.

edit: typos - same type of crap that made the script fail! wink

edit2: ESSIDs with spaces should now work, but this needs some testing.

Last edited by Trilby (2012-06-15 17:58:33)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#7 2012-06-24 12:49:44

mloskot
Member
From: London, United Kingdom
Registered: 2012-06-01
Posts: 86
Website

Re: Dead-simple bashscript wifi connector

Trilby,

Thanks for this really useful utility.

Since I installed Arch weeks ago, I've been using my own script wraping all the steps outlined in the Wireless Setup, section Manual setup. Your script does the same, but in nice and clear yet flexible way.

It's a must-use for everyone who likes the manual setup but without manual management of /etc/wpa_supplicant.conf files.


Mateusz Loskot | github | archlinux-config
Arch (x86-64) | ThinkPad T400  | Intel P8600| Intel i915
Arch (x86-64) | ThinkPad W700 | Intel T9600 | NVIDIA Quadro FX 2700M

Offline

#8 2012-06-24 12:59:45

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

Thanks, glad it's useful.  I'm still fixing a few bits.  In fact I have yet to push the last fix ... that is to fix what I broke with the second to last fix!  The fix-the-fix will be pushed to get this afternoon.

FYI for anyone who checks in, I have not bothered to set up for WEP.  If anyone uses WEP it wouldn't be to hard, but many assumptions are made for simplicity's sake and so far this has been one of them.

I'll also add dhclient as a configurable alternative to dhcpcd - but that will be for others to test as I don't use dhclient.

Last edited by Trilby (2012-06-24 13:09:52)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#9 2012-06-24 13:12:13

mloskot
Member
From: London, United Kingdom
Registered: 2012-06-01
Posts: 86
Website

Re: Dead-simple bashscript wifi connector

I think, it may be sensible to move the script to its own dedicated Git repo to make it easier to checkout, fork, contribute with pull requests, submit issues, make AUR package, etc.


Mateusz Loskot | github | archlinux-config
Arch (x86-64) | ThinkPad T400  | Intel P8600| Intel i915
Arch (x86-64) | ThinkPad W700 | Intel T9600 | NVIDIA Quadro FX 2700M

Offline

#10 2012-06-25 17:50:08

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

Fixed the errors that I created, added a DHCP variable that is set to dhcpcd by default or can be set to dhclient (untested), and moved it to it's own repo as requested.

New repo is
https://github.com/TrilbyWhite/Wifi


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#11 2012-06-25 18:45:27

mloskot
Member
From: London, United Kingdom
Registered: 2012-06-01
Posts: 86
Website

Re: Dead-simple bashscript wifi connector

Thanks for the update.

BTW, I understand the script requires 256-colors terminals, but I do have *some* colors supported by my framebuffer-enabled TTYs.
Despite, I'm getting TTYs messed every time I run the script:

7442060102_a83fd8ba61_t.jpg

I wonder, is this related to th 256-colors requirement?


Mateusz Loskot | github | archlinux-config
Arch (x86-64) | ThinkPad T400  | Intel P8600| Intel i915
Arch (x86-64) | ThinkPad W700 | Intel T9600 | NVIDIA Quadro FX 2700M

Offline

#12 2012-06-25 19:00:39

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

It could be the colors, or the line drawing characters.

I just added a image of what it should look like with the default colors:
https://github.com/TrilbyWhite/Wifi/blo … r/wifi.png

I could make a more tty-friendly version.  In fact a majority of this script is just for some aesthetics.  The purely functional parts ammount to a dozen lines or so.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#13 2012-06-25 19:22:00

mloskot
Member
From: London, United Kingdom
Registered: 2012-06-01
Posts: 86
Website

Re: Dead-simple bashscript wifi connector

Trilby wrote:

I just added a image of what it should look like with the default colors:
https://github.com/TrilbyWhite/Wifi/blo … r/wifi.png

Yes, when I run the script in console under X11 (e.g. urxvt), everything looks correct.
The only problem is when I run in TTY without X.

Trilby wrote:

I could make a more tty-friendly version.

I was thinking of simpler hack, about detecting if the required features are supported.
If not, the script could simply print error message and give up.

Perhaps check based on this could do the job:

$ tput colors

In my TTYs, it gives 8, what explains the mess smile


Mateusz Loskot | github | archlinux-config
Arch (x86-64) | ThinkPad T400  | Intel P8600| Intel i915
Arch (x86-64) | ThinkPad W700 | Intel T9600 | NVIDIA Quadro FX 2700M

Offline

#14 2012-06-25 19:49:09

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,211
Website

Re: Dead-simple bashscript wifi connector

Well, I did one better.  I started modifying wifi to accomodate tty's, then I realized I was ugly-fying a script I was rather proud of.  Instead I added a different tty-friendly version: wifi_tty which is up on the git repo.  Next time I sit down with this I will put a test in 'wifi' and if it's at a tty it will call wifi_tty instead.

edit: changed name of tty script to be more appropriate.  Also the new wifi with the terminal test is up on git.

Last edited by Trilby (2012-06-27 21:37:52)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

Board footer

Powered by FluxBB