Wed, 13 Apr 2016 18:34:43 +0200 Mike Burns <mike+open...@mike-burns.com> > On 2016-04-13 15.31.36 +0200, Erling Westenvik wrote: > > On Wed, Apr 13, 2016 at 09:37:53AM +0000, Mike Burns wrote: > > > I hooked some shell scripts up with zenity to make a wifi GUI. > > > > > Interesting. Care to share the code somewhere? Maybe it could evolve > > into a port/package? > > I'll share the code, but it has some caveats:
It's a starting point for all programs, feedback helps a lot. > - I made this for my laptop and my use cases. You're very interested in it, which is what it takes indeed. > - I hate automation. Just design correct to be susceptible to automation is enough. Programs evolve into filters and interfaces to other programs. > - It's not very good. The future is open, if you keep your interest in it, buckle up. > - The GUI gives no feedback after you select the access point. Minor convenience details, you'll have more iterations with it. > Feel free to turn it into anything you'd like. Thanks a bunch, please keep it up (don't listen to crappy talk). > Attached is a man page for wifi(1), the wifi script itself, and wifi-gtk > which makes use of the wifi script. Run it as 'doas wifi-gtk -C $HOME/.wifi', > where $HOME/.wifi is your wifi config (see the attached man page). > > === > wifi.1: > === > > .Dd $Mdocdate$ > .Dt WIFI 1 > .Os > .Sh WIFI > .Nm wifi > .Nd connect to OpenBSD wifi > .Sh SYNOPSIS > .Nm progname > .Fl C Ar config > .Fl i Ar iface > .Ar nickname > .Sh DESCRIPTION > The > .Nm > utility connects to the wifi on the interface > .Ar iface > according to the > .Ar nickname > as read from > .Ar config . > .\" .Sh ENVIRONMENT > .\" For sections 1, 6, 7, and 8 only. > .Sh FILES > The configuration file follows a simple format: > .Pp > .Dl nickname: ifconfig-options autoconfiguration > .Pp > These three values are as follow: > .Bl -tag -width Ds > .It Va nickname > The name of the wifi network, to be passed to the > .Nm > program. > .It Va ifconfig-options > Options for > .Xr ifconfig 1 , > such as > .Li nwid > and > .Li wpakey . > .It Va autoconfiguration > Either > .Li dhcp > for DHCP or > .Li rtsol > for IPv6 autoconf. > .El > .Sh EXIT STATUS > The exit status of > .Nm > is the same as the exit status of the > .Pa /etc/netstart > program. > .Sh EXAMPLES > .Pp > .Dl sudo wifi -C ~/.wifi -i iwn0 home > .Pp > .\" .Sh DIAGNOSTICS > .\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only. > .Sh SEE ALSO > .Xr ifconfig 1 , > .Xr hostname.if 5 > .\" .Sh STANDARDS > .\" .Sh HISTORY > .Sh AUTHORS > .An "Mike Burns" Aq mike+open...@mike-burns.com > .\" .Sh CAVEATS > .\" .Sh BUGS > > === > wifi: > === > > #!/bin/sh > > usage() { > echo usage: wifi -C config -i iface nickname > exit 64 > } > > args=`getopt "C:i:" $*` > > if [ $? -ne 0 ]; then > usage > fi > > set -- $args > > while [ $# -ne 0 ]; do > case "$1" in > -C) > config="$2" > shift; shift > ;; > -i) > iface="$2" > shift; shift > ;; > --) > shift > to_connect="$@" > break > ;; > esac > done > > if [ -z "$config" -o -z "$iface" -o -z "$to_connect" ]; then > usage > fi > > file="/etc/hostname.$iface" > dhcp_cfg=$(sed -ne "/^${to_connect}:.*dhcp/s/.*: *\(.*\) *dhcp/\1/p" > "$config") > rtsol_cfg=$(sed -ne "/^${to_connect}:.*rtsol/s/.*: *\(.*\) *rtsol/\1/p" > "$config") > > if [ -z "$dhcp_cfg" -a -z "$rtsol_cfg" ]; then > echo "Could not find '$to_connect' in $config" >&2 > exit 1 > fi > > echo "# Autogenerated by wifi(1)" > "$file" > echo "# Connection name: '${to_connect}'" >> "$file" > > if [ -n "$dhcp_cfg" ]; then > echo "$dhcp_cfg" >> "$file" > echo dhcp >> "$file" > fi > > if [ -n "$rtsol_cfg" ]; then > echo "$rtsol_cfg" >> "$file" > echo rtsol >> "$file" > fi > > exec sh /etc/netstart > > === > wifi-gtk > === > > #!/bin/sh > > if [ $# -ne 2 ]; then > echo usage: wifi-gtk -C config > exit 64 > fi > > config="$2" > > nwid=$(sed -ne 's/\(.*\):.*/\1/p' "$config" | zenity --list --title Wifi > --column nwids) > > if [ -n "$nwid" ]; then > exec /home/mike/.bin/wifi -C "$config" -i iwn0 "$nwid" > fi