UCI menu


Forum: Programming and Scripting
Topic: UCI menu
started by: mikshaw

Posted by mikshaw on Aug. 14 2006,19:23
I've been playing with < dwm > quite a lot the last couple of weeks, and enjoying it much. The dmenu utility (a stripped-down version of wmiimenu) is very cool when mixed with a little scripting.

This is a little script that will list *.uci files using dmenu or wmiimenu (included with wmii.uci), and run mydsl-load on the selected item.  If it's already mounted it will be listed with "(M)".

It could easily be extended to use other types of extensions, but since I use *.uci 99.94% of the time I didn't bother =o)

Code Sample
#!/bin/bash

cd $HOME/mydsl/optional #change to location of *.uci files

for i in *.uci; do
grep -q "\/$i " /etc/mtab
[ "$?" == "0" ] && i="${i}(M)"
[ -n "$UCI_LIST" ] &&  UCI_LIST="$UCI_LIST,$i" ||  UCI_LIST="$i" #this check might be unnecessary
done

UCI_FILE=`echo "$UCI_LIST" | tr ',' '\n' | dmenu` #or wmiimenu
[ -n "$UCI_FILE" ] && mydsl-load ${UCI_FILE%(M)}


EDIT: updated dwm link.
NOTE: dmenu has recently been added to the myDSL repository. The package includes a heavily tweaked (and improved, imo) version of this script.

Posted by mikshaw on Aug. 14 2006,20:46
Minor tweaks....
Code Sample
#!/bin/bash

cd $HOME/mydsl/optional
for i in *.uci; do
grep -q "\/$i " /etc/mtab
[ "$?" == "0" ] && i="${i}(M)"
UCI_LIST=`echo -e "$UCI_LIST\n$i"`
done

UCI_FILE=`echo "$UCI_LIST" | grep -v ^$ | dmenu`
[ -n "$UCI_FILE" ] && mydsl-load ${UCI_FILE%(M)}

grep -v ^$ removes the initial blank line...not vital, but looks cleaner.  I'm hoping to  set the UCI_LIST variable so the blank isn't there to begin with, but only if I can do it while keeping commands and bytes to a minimum.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.