Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: another uci mounter< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Oct. 19 2006,19:04 QUOTE

I made this one simply for aesthetic reasons.  It fits nicely with dwm or wmii, since it uses dmenu or wmiimenu
Code Sample
# uci.dmenu, mikshaw 2006
# Uses dmenu (dwm.suckless.org) to display and [u]mount uci packages

PREFIX="/home/dsl/mydsl" # where are your uci files
DMENU='dmenu -font snap -normbg #000000 -normfg #666666 -selbg #222222 -selfg #888888' # wmiimenu works too
PACKAGELIST=`find $PREFIX/ -name "*.uci"` # find all *.uci files in $PREFIX

showmenu() {
for i in $PACKAGELIST; do
TMPNAME=`basename $i .uci` # shows only the package name for a clean, compact display
if grep "$i " /etc/mtab &>/dev/null; then
 echo "*$TMPNAME" # asterisk on mounted files
else
 echo "$TMPNAME"
fi
done | sort | $DMENU
}

PKG=`showmenu|sed 's/\*//'` # run showmenu() and remove asterisks from stdout
for i in $PACKAGELIST; do # find the selected item string in the list
if [ "`basename $i .uci`" == "$PKG" ]; then FNAME="$i"; break; fi
done
[ -r "$FNAME" ] && mydsl-load "$FNAME"


EDIT: changed it to display only the package name in dmenu, without the filename extension.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Oct. 20 2006,16:46 QUOTE

Code Sample
#!/bin/bash

# uci.dmenu, mikshaw 2006
# Uses dmenu (dwm.suckless.org) to display and [u]mount uci packages
#
# changelog (yyyy.mm.dd)
#  2006.10.20: Added optional check for mydsl boot code and mydsl commandline param
#              Exit if PACKAGELIST is empty
#              Added non-recursive search option
#  2006.10.19: Stripped prefix and suffix from packagename display

PREFIX="/home/dsl/mydsl" # where are your uci files
DMENU='dmenu -font snap -normbg #000000 -normfg #666666 -selbg #222222 -selfg #888888' # wmiimenu works too
NOR=""

for i in $@; do
case $1 in
h|-h|-help|--help)
cat << EOF
 Options:
   -b, b      Use "mydsl=" boot option, if available
   -n, n      No recursive search
   directory  Path to a MyDSL directory
EOF
exit 0
;;
b|-b)
# use "mydsl=" boot option for PREFIX (overrides the PREFIX variable above)
# based on Robert's mydsl code in /etc/init.d/dsl-config, minus the automounting
 source /etc/init.d/dsl-functions
 CMDLINE=`cat /proc/cmdline`
 MYDSL=`getbootparam mydsl`
 MYDSL_DEVICE="${MYDSL%%/*}"
 MYDSL_DIR="${MYDSL#*/}"
 if [ "$MYDSL_DEVICE" = "$MYDSL_DIR" ]; then MYDSL_DIR=""; fi
 find_mountpoint "$MYDSL_DEVICE"
 [ -d "$MOUNTPOINT/$MYDSL_DIR" ] && PREFIX="$MOUNTPOINT/$MYDSL_DIR"
 shift
;;
n|-n)
 NOR=1
 shift
;;
*)
 [ -d "$1" ] && PREFIX="$1"
 shift
;;
esac
done

if [ -n "$NOR" ]; then
FIND="ls $PREFIX/*.uci"
else
FIND="find $PREFIX/ -name *.uci"
fi
PACKAGELIST=`$FIND 2>/dev/null` # find all *.uci files in $PREFIX
#PACKAGELIST=`find $PREFIX/ -name "*.uci" 2>/dev/null` # find all *.uci files in $PREFIX
[ -z "$PACKAGELIST" ]  && exit

showmenu() {
for i in $PACKAGELIST; do
TMPNAME=`basename $i .uci` # shows only the package name for a clean, compact display
if grep "$i " /etc/mtab &>/dev/null; then
 echo "*$TMPNAME" # asterisk on mounted files
else
 echo "$TMPNAME"
fi
done | sort | $DMENU
}

PKG=`showmenu|sed 's/\*//'` # run showmenu() and remove asterisks from stdout
for i in $PACKAGELIST; do # find the selected item string in the list
if [ "`basename $i .uci`" == "$PKG" ]; then FNAME="$i"; break; fi
done
[ -r "$FNAME" ] && mydsl-load "$FNAME"

EDIT: added options for non-recursive search and use of "mydsl=" boot code


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
1 replies since Oct. 19 2006,19:04 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: another uci mounter

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code