LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 718 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 09:34 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration