DragonFly BSD
DragonFly users List (threaded) for 2005-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Starting a program from a command line versus clicking an icon.

From: Oliver Fromme <check+ilodic00rsiztgx5@xxxxxxxxxx>
Date: 23 Aug 2005 13:39:00 GMT

Michael Schuh <michael.schuh@xxxxxxxxx> wrote:
 > walt <wa1ter@xxxxxxxxxxxxx>:
 > > I've written a little C program named rlc which generates
 > > random color strings like 'rgb:a5/b3/f1' which I can use
 > > like this to start xterm:
 > > 
 > > xterm -bg `rlc` (gives a random-light-colored background)
 > > 
 > > This works great when I type the command from an xterm
 > > window -- but it fails when I click on a gnome or xfce
 > > icon containing the same command.
 > > 
 > > Any idea why those two methods of starting a program
 > > don't produce the same result?
 > my first shot (not really tested, but my goldfinger say's :-D)
 > the backquotes around rlc......

Right.  When typed in an xterm, the line is parsed by the
shell, including the backticks which are special syntax of
a shell.  I don't use gnome, but I guess it doesn't pass
the command to a shell for execution, but just uses execve()
or similar.

 > to workaraund you can try little shell-script.
 > ----8<-----
 > #!/bin/sh
 > xterm -ls +sb -bg `rlc` $@
 > ---->8----

May I improve on that a bit?

#!/bin/sh -
exec xterm -ls +sb -bg `rlc` "$@"

The "exec" prevents a useless shell process hanging around
until the xterm exits, and the quotes around "$@" are
required to make it work correctly with arguments that
contain spaces.  Without quotes, $@ and $* behave the same.

Personally, I also use "-sl 10000" to get 10,000 lines of
scrollback history.  My xterm wrapper script also sets the
font size depending on the display width, so I can fit two
xterms (with 80 columns each) beside each other.

Best regards

PS:  For those interested, this is my xterm wrapper script:

#!/bin/sh -

if [ -z "$DISPLAY" ]; then
        echo "Sorry, \$DISPLAY is not set."
        exit 1

WIDTH=$(xwininfo -root | awk '/Width:/{print $2}')

if [ -z "$WIDTH" ]; then
        echo "Sorry, my \$DISPLAY doesn't work ($DISPLAY)."
        exit 1

if   [ $WIDTH -gt 1440 ]; then FONT=9x15bold
elif [ $WIDTH -gt 1280 ]; then FONT=8x13bold
elif [ $WIDTH -gt 1120 ]; then FONT=7x13bold
elif [ $WIDTH -gt  960 ]; then FONT=6x13
else                           FONT=5x8   # Ugh!

exec /usr/X11R6/bin/xterm -fn "$FONT" -sl 10000 "$@"

Oliver Fromme -- Bunsenstr. 13 -- 81735 Muenchen -- Germany

``All that we see or seem is just a dream within a dream.''
(E. A. Poe)

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]