ESPL: Extremely Simple Program Launchbar

Walter Dnes waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Thu Dec 27 20:09:28 UTC 2007


  I apologize if this is a dup, the original seems not to have gotten
through.

  Thanks to those who replied to my question about simple menuing.  I
eventually settled on xmessage.  What got me going originally, was a
note on the pypanel homepage that the program was no longer under
development.  This got me looking for another launchbar program.  There
are several around.  Unfortunately, they all seem to want to pull in 90%
of the GNOME libs or 90% of the KDE libs, or a ton of Perl from CPAN.
All I wanted was a program launcher on the bottom of the screen, where I
could click a button, and launch a program.

  I go so annoyed that I ended up writing my own launchbar program...
consisting of 18 lines worth of bash script!  Hence the name "espl"
(Extremely Simple Program Launchbar). I went about the process in a
backwards manner.  First, I made a sample ~/.esplrc config file...

AbiWord /usr/bin/abiword
Firefox /usr/bin/firefox -P default
Freecell /usr/games/bin/xfreecell
GIMP /usr/bin/gimp
GoogleSearch /usr/bin/firefox -P default http://www.google.com
gnumeric /usr/bin/gnumeric
xterm /usr/bin/xterm -bg black -fg cyan -fn -*-fixed-medium-*-*-*-*-200-*-*-*-*-iso8859-1

  The layout consists of a text label *WITH NO EMBEDDED BLANKS*, followed by a
program, and any required parameters.  Next, I wrote a script to process
the file...


#!/bin/bash
commandline="xmessage -geometry +0-0 -buttons EXIT:1"
commandarray[1]=exit
buttonpointer=2
while read xlabel xcommand
do
  commandarray[${buttonpointer}]=${xcommand}
  commandline="${commandline},${xlabel}:${buttonpointer}"
  buttonpointer=$(( ${buttonpointer} + 1 ))
done < ~/.esplrc
commandline="${commandline} -file /dev/null"
commandpointer=0
while [[ ${commandpointer} != 1 ]]
do
  ${commandline}
  commandpointer=${?}
  eval ${commandarray[${commandpointer}]} &
done

  The script reads ~/.esplrc, adds a label and returnvalue to the
xmessage commandline, and populates commandarray with the commands and
parameters.  Clicking on button N returns a value of N, which is used to
select commandarray[N] for launching.  xmessage exits immediately after
returning "${?}".  The script launches the selected command in the
background, and loops to launch another invocation of xmessage.  Note
that return code 1 is reserved for errors.  I associate it with the
"EXIT" button, so that an error will cause an exit.  Here's my .xinitrc


#!/bin/bash
/usr/bin/bbkeys &
/usr/bin/xterm -bg black -fg cyan -geometry 50x10+0+0 -fn -*-fixed-medium-*-*-*-*-200-*-*-*-*-iso8859-1 &
/usr/bin/xterm -bg black -fg cyan -geometry +0+0 -fn -*-fixed-medium-*-*-*-*-200-*-*-*-*-iso8859-1 &
~/bin/espl &
exec /usr/bin/blackbox > ~/.blackbox.log 2>&1

  This was intended as proof-of-concept, but it actually works quite
well.  On the todo list are things like...
- getting it to ignore lines beinning with "#", i.e. comments
- allowing to use a different config file
- fancy colours

-- 
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
I'm not repeating myself
I'm an X Window user...  I'm an ex-Windows-user
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list