• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: X11 with XDariwin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: X11 with XDariwin


  • Subject: Re: X11 with XDariwin
  • From: "David Orlovich" <email@hidden>
  • Date: Fri, 31 Jan 2003 21:31:26 +1300

On Friday, January 31, 2003, at 05:47 PM, Justin Triplett wrote:

Hey, Thanks a lot, that's a pretty good idea. Just for the sake of learning though, I understand the if-else statement, but what is the first line doing and what is the "fi" and the end?

well I'm just a novice too - but "just for the sake of learning" I tried to work it out:


looks like an object called xdar is defined by "xdar="

to work out what's in xdar, the first command is ps (process status).

"ps xo command" gives a list of apps that are running (and it seems others run in the login session even if not running now).

I couldn't find in man ps what the "xo" bit means...

Anyway, the output of ps is piped to a grep command which searches files (or in this case the input from the ps command) for the text "XDarwin.app".

The next command tricked me for a bit. "grep -v grep" basically eliminates any lines that are fed to it that contain the text "grep" (grep -v does the opposite of grep, so instead of finding lines with the search text, it finds lines without the search text). It seems that one of the processes running that contains the text "XDarwin.app" is the grep that was just executed, so that process is a red herring and you don't want to know about that one (it doesn't indicate XDarwin is running, just that you're searching for it)

Anyway ... the remaining lines with XDarwin.app in it are counted by "wc -l" (wc -l simply counts lines!)

So ... the output of that first line will be 0 if XDarwin.app is not running, and (I presume) 1 if it is running. I can't test this since I wiped XDarwin and am currently using X11.app from Apple. interestingly is returns 2 from the wc:
/Applications/X11.app/Contents/MacOS/X11 -psn_0_917505
/Applications/X11.app/Contents/MacOS/X11 --xquartz-be-xinit -noreset -auth /Use


Anyway, the if/else/fi loop checks the value of xdar. If it's 1, it means XDarwin is running, so it can start blackbox, if not (else) it starts quartz-wm. The fi signals the end of the if loop.

Gee that was fun... Cheers, David.




xdar="`ps xo command | grep XDarwin.app | grep -v grep | wc -l`"

if [ $xdar -eq 1 ]; then
        exec blackbox
else
        exec quartz-wm
fi
---

(i'm sure there are better ways of telling whether XDarwin is running, but...)


Justin Triplett email@hidden http://diablonet.net/~decrypt/ _______________________________________________ x11-users mailing list | email@hidden Help/Unsubscribe: http://www.lists.apple.com/mailman/listinfo/x11-users Do not post admin requests to the list. They will be ignored.
_______________________________________________
x11-users mailing list | email@hidden
Help/Unsubscribe: http://www.lists.apple.com/mailman/listinfo/x11-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: X11 with XDariwin
      • From: Toby Peterson <email@hidden>
References: 
 >Re: X11 with XDariwin (From: Justin Triplett <email@hidden>)

  • Prev by Date: Re: X11 with XDariwin
  • Next by Date: Re: .xinitrc doesnt work well with ratpoison
  • Previous by thread: Re: X11 with XDariwin
  • Next by thread: Re: X11 with XDariwin
  • Index(es):
    • Date
    • Thread