LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > Whaling the FOSS
User Name
Password

Notices


The experiences of an Australian student who uses Linux.

Cover all topics from shell scripts to monopolies and reviews to political comments.
Rate this Entry

Better than an xmessage choice window

Posted 04-23-2010 at 08:05 PM by William (Dthdealer)

Regarding my earlier post about .xinit scripts

This is my current setup, probably a better option. I simply pass options as what I want to execute or just run startx without any options for my normal session including window manager.

Code:
#!/bin/sh

# Anything to run only once and beforehand
xmodmap "/home/whales/.Xmodmap"
xbattbar -s acpi_xbattbar -t 3 &
~/script/shell/dayfortune &

if [ -z $1 ]
then
        # Start normal session
        exec .fluxbox/startup
        # Script ends before this comment as the EXEC command kills after completion
fi



# Pass any options of this script
$1 $2 $3 $4 $5 $6 $7 $8 $9

exit $?
Breaking it down

if [ -z $1 ]
Checks whether anything is passed to the startx command. $1 is the first thing passed, so if I wrote startx tremulous then $1 would have the content 'tremulous'. For all consecutive options passed, the number increases, putting this in the format startx $1 $2 $3 $4 $5 etc.

The [ and ] characters are shorthand for the test shell command. See the manpage for details on it.

Here the -z option checks whether the string ( $1 ) is zero-length. If it is, then the user has just written startx without any options. Else it goes on.

# Pass any options of this script
$1 $2 $3 $4 $5 $6 $7 $8 $9

Here the options after startx are executed. For example if I wrote startx tremulous --anoption value the $1,$2 and $3 variables would substitute in ' tremulous --anoption value ' and execute it as if I had written in in a terminal, but in Xorg.
Views 1219 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 03:00 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration