WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Using dmenu to load extensions  (Read 9447 times)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Using dmenu to load extensions
« Reply #15 on: January 12, 2016, 12:45:32 AM »
Hmmm

well this works for me so I think you can ditch the ugly sed  :p
Code: [Select]
for f in /usr/local/tce.installed/* ; do echo ":: ${f##*/}"; done | sort -bf

Code: [Select]
:: squashfs-tools
:: sstrip
:: submitqc
:: ttf-bitstream-vera
:: udev-extra
:: udev-lib
:: usbutils
:: wbar
:: wget
:: xdg-utils
:: Xlibs
:: Xorg-7.7-lib
:: Xprogs
:: Xvesa
:: xzgv
:: zsync

Which I think is the objective..?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Using dmenu to load extensions
« Reply #16 on: January 12, 2016, 07:22:11 AM »
Thanks but nope. The main objective is to show a list of loadable extensions to choose from. In addition, instead of leaving out those already loaded, show them too but with some kind of indication (f.e. "::").
This is especially helpful for checking if a certain extension is loaded without having to know if it is present.
Then, for readability and my personal preference, the list should be sorted like humans do.
Not:
:: X.tcz
:: a.tcz
:: b.tcz
:: z.tcz
c.tcz
x.tcz
y.tcz

But:
:: a.tcz
:: b.tcz
c.tcz
:: X.tcz
x.tcz
y.tcz
:: z.tcz

If I could get  sort  to ignore ":: " that would certainly be preferable over the additional  sed . But meh.. couldn't get it to work. Anyway, the script doesn't behave like a sprinting snail anymore. Doing a little extra work 500 times is way faster than 500*500 times. q:

Still, if you can think of anything to bump me in the right direction, I'd be the last who complains.
Download a copy and keep it handy: Core book ;)

Offline mocore

  • Hero Member
  • *****
  • Posts: 633
  • ~.~
Re: Using dmenu to load extensions
« Reply #17 on: January 12, 2016, 06:45:38 PM »
Anything like this ?
"view info.lst and display already downloaded + loaded extentions" http://forum.tinycorelinux.net/index.php/topic,13056.msg71819.html#msg71819

show a list of loadable extensions to choose from. In addition, instead of leaving out those already loaded, show them too but with some kind of indication (f.e. "::").

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Using dmenu to load extensions
« Reply #18 on: January 13, 2016, 12:35:14 AM »
Interesting. I'm happy with my dmenu script now but an additional dmenu apps browser might be nice. Thanks.
Download a copy and keep it handy: Core book ;)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Using dmenu to load extensions
« Reply #19 on: January 13, 2016, 02:27:55 AM »
Quote
If I could get  sort  to ignore ":: " that would certainly be preferable over the additional  sed . But meh.. couldn't get it to work.
Please don't misunderstand, I luv sed.  Sed is awesome but I've found there are much faster methods in repetitive tasks

Let me to give a hint,  use sort earlier.. :p

Though I didn't time it, this executed really fast
Code: [Select]
cd /etc/sysconfig/tcedir/optional
tczs=$(ls *.tcz | sort -bf)
for f in $tczs ; do [ -e "/usr/local/tce.installed/${f%.*}" ] && echo ":: $f" || echo "$f"; done


Of course I had to test the theory
Code: [Select]
:: unzip.tcz
...
v4l-dvb-4.2.7-tinycore64.tcz
vlc.tcz
:: wbar.tcz
:: webkitgtk4.tcz
wget.tcz
wireless-4.2.7-tinycore64.tcz
wireless_tools.tcz
wpa_supplicant-dbus.tcz
x264.tcz
:: xcursor-themes.tcz
:: xf86-input-evdev.tcz
:: xf86-video-vesa.tcz
Xfbdev.tcz
:: xkeyboard-config.tcz
:: Xlibs.tcz
:: Xorg-7.7-3d.tcz
:: Xorg-7.7-bin.tcz
:: Xorg-7.7-lib.tcz
:: Xorg-7.7.tcz
:: Xorg-fonts.tcz
:: xorg-server.tcz
:: Xprogs.tcz
:: zip.tcz

« Last Edit: January 13, 2016, 02:36:40 AM by coreplayer2 »

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Using dmenu to load extensions
« Reply #20 on: January 13, 2016, 05:30:08 PM »
First, I'm sure I'm not misunderstanding you. Tools like sed are great but the less tools the better.
Second, I luv you. You made sed obsolete for me. (: time shows the same results but the code is looking faster. (;

Code: [Select]
#!/bin/sh
[ -e "/usr/local/tce.installed/dmenu" ] || tce-load -i dmenu >/dev/null 2>&1

EXT="*.tcz"
OPT="-i -xs -c -b -w 300 -h 300 -y 19 -nb #0D0D0C -nf #D4D0C8 -sb #050503 -sf #FFB000"

cd /etc/sysconfig/tcedir/optional
#TCZS="$(for f in $EXT ; do X="${f%.*}" && [ -e "/usr/local/tce.installed/$X" ] && echo " $X" || echo "$X" ; done | sort -bf | sed 's/ /:: /')"
TCZS=$(ls $EXT | sort -bf)
TCZS=$(for f in $TCZS ; do [ -e "/usr/local/tce.installed/${f%.*}" ] && echo ":: $f" || echo "$f"; done)

TCZ="$(echo "$TCZS" | dmenu -p "$EXT" $OPT 2>/dev/null)" \
&& tce-load -i "$TCZ" &

Download a copy and keep it handy: Core book ;)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Using dmenu to load extensions
« Reply #21 on: January 17, 2016, 04:42:18 PM »
Hey mocore, thanks! I've implemented downloading and parsing info.lst .

Code: [Select]
#!/bin/sh

INST="/usr/local/tce.installed"
[ "$(which dmenu)" ] || [ -e "$INST/dmenu" ] || tce-load -i dmenu >/dev/null 2>&1 || { echo "dmenu not available."; exit 1; }

EXT="*.tcz"
OPTS="-b -w 300 -h 300 -y 19"
LST="info.lst"
DIR="/tmp"
INFO="$DIR/$LST"

while getopts wila OPTION
do
case ${OPTION} in
w) WGET=TRUE ;;
i|l) LOAD=TRUE ;;
a) ALL=TRUE ;;
esac
done

cd /etc/sysconfig/tcedir/optional
if [ "$WGET" ]; then
OPTS="$OPTS -nb #0D0D0C -nf #D4D0C8 -sb #050503 -sf #689ACF"
if [ ! -e "$INFO" ]; then
echo "Downloading $LST ..." | dmenu -p "$EXT" $OPTS 2>/dev/null &
. /etc/init.d/tc-functions
getMirror
wget -P "$DIR" "$MIRROR/$LST"
[ "$?" == 0 ] || { killall dmenu 2>/dev/null; echo "Failed!" | dmenu -p "$EXT" $OPTS 2>/dev/null; exit 1; }
fi
if [ "$ALL" ]; then
MENU="$(for f in $(ls $EXT | sort -fu - ${INFO}); do X="${f%.*}"; [ ! -e "$f" ] && X="+ $X" || { [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; }; echo "$X"; done)"
else
MENU="$(for f in $(cat ${INFO}); do X="${f%.*}"; [ ! -e "$f" ] && X="+ $X" || { [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; }; echo "$X"; done)"
fi
if [ "$LOAD" ]; then
CMD='xterm -T "Download and Load $TCZ" -e $SHELL -c "tce-load -w $TCZ && tce-load -i $TCZ; $SHELL"'
else
CMD='xterm -T "Download $TCZ" -e $SHELL -c "tce-load -w $TCZ; $SHELL"'
fi
else
OPTS="$OPTS -nb #0D0D0C -nf #D4D0C8 -sb #050503 -sf #FFB000"
MENU="$(for f in $(ls $EXT | sort -f); do X="${f%.*}"; [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; echo "$X"; done)"
CMD='tce-load -i $TCZ'
fi

killall dmenu 2>/dev/null
TCZ="$(echo "$MENU" | dmenu -p "$EXT" -i -xs -c $OPTS 2>/dev/null)" \
&& (TCZ="$(echo "$TCZ" | sed 's_[+|::|@]__g')" ; eval ${CMD}) &

Download a copy and keep it handy: Core book ;)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Using dmenu to load extensions
« Reply #22 on: February 27, 2016, 03:18:32 PM »
Using "+" (plus sign) to indicate downloadable extensions is not a good idea - those characters get removed from the string before it's shipped to  tce-load  but there are actually extensions that have a "+" in their file name (f.e. dvd+rw-tools.tcz). Now using "<".

Code: [Select]
#!/bin/sh

INST="/usr/local/tce.installed"
[ "$(which dmenu)" ] || [ -e "$INST/dmenu" ] || tce-load -i dmenu >/dev/null 2>&1 || { echo "dmenu not available."; exit 1; }

EXT="*.tcz"
OPTS="-b -w 300 -h 300 -y 19"
LST="info.lst"
DIR="/tmp"
INFO="$DIR/$LST"

while getopts wila OPTION
do
case ${OPTION} in
w) WGET=TRUE ;;
i|l) LOAD=TRUE ;;
a) ALL=TRUE ;;
esac
done

cd /etc/sysconfig/tcedir/optional
if [ "$WGET" ]; then
OPTS="$OPTS -nb #0D0D0C -nf #D4D0C8 -sb #050503 -sf #689ACF"
if [ ! -e "$INFO" ]; then
echo "Downloading $LST ..." | dmenu -p "$EXT" $OPTS 2>/dev/null &
. /etc/init.d/tc-functions
getMirror
wget -P "$DIR" "$MIRROR/$LST"
[ "$?" == 0 ] || { killall dmenu 2>/dev/null; echo "Failed!" | dmenu -p "$EXT" $OPTS 2>/dev/null; exit 1; }
fi
if [ "$ALL" ]; then
MENU="$(for f in $(ls $EXT | sort -fu - ${INFO}); do X="${f%.*}"; [ ! -e "$f" ] && X="< $X" || { [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; }; echo "$X"; done)"
else
MENU="$(for f in $(cat ${INFO}); do X="${f%.*}"; [ ! -e "$f" ] && X="< $X" || { [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; }; echo "$X"; done)"
fi
if [ "$LOAD" ]; then
CMD='xterm -fg gold -bg black -g 80x9 -T "Download and Load: $TCZ" -e $SHELL -c "tce-load -w $TCZ && tce-load -i $TCZ; $SHELL"'
else
CMD='xterm -fg gold -bg black -g 80x9 -T "Download: $TCZ" -e $SHELL -c "tce-load -w $TCZ; $SHELL"'
fi
else
OPTS="$OPTS -nb #0D0D0C -nf #D4D0C8 -sb #050503 -sf #FFB000"
MENU="$(for f in $(ls $EXT | sort -f); do X="${f%.*}"; [ -e "$INST/$X" ] && X=":: $X"; [ -L "$f" ] && X="$X @"; echo "$X"; done)"
CMD='xterm -g 80x9 -T "TCE-Load: $TCZ" -e tce-load -i $TCZ'
fi

### If running  tce-load  from  /etc/sysconfig/tcedir/optional , copy2fs.flg will be ignored!
#cd --

killall dmenu 2>/dev/null
TCZ="$(echo "$MENU" | dmenu -p "$EXT" -i -xs -c $OPTS 2>/dev/null)" \
&& (TCZ="$(echo "$TCZ" | sed 's_[<|::|@]__g')" ; eval ${CMD}) &

Download a copy and keep it handy: Core book ;)