Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Aug 1998 05:26:19 -0400 (EDT)
From:      Kelly Yancey <kbyanc@freedomnet.com>
To:        Joel Ray Holveck <joelh@gnu.org>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: determining an X window ID?
Message-ID:  <Pine.BSD/.3.91.980830052005.10995A-100000@freedomnet.com>
In-Reply-To: <199808300355.WAA05971@detlev.UUCP>

next in thread | previous in thread | raw e-mail | index | archive | help


On Sat, 29 Aug 1998, Joel Ray Holveck wrote:

> >   I have written a fairly short shell script to launch xmcd which first 
> > checks to see if any other cd player is already running and if so, does 
> > not launch another instance of xmcd (for when I click on the wrong thing 
> > :) )
> 
> How does it do this check?
> 

  The old fashioned way...it checks for each of them in the output of ps 
:)

  Actually it's not too bad. I broke it into two loops: the first checks 
for all the X-based cd players (xmcd, xcdplayer, etc), with the hope that 
one day I'll be able to set focus on them. And the second checks for 
command-line cd players (cdplay, cda, etc.)...I don't know what I could 
do if they are running, but it definately isn't to try and start another 
cd player :).

  Below is a copy of the script.

  Kelly Yancey
 ~kbyanc@freedomnet.com~


#!/bin/sh
# This is a script to start xmcd sanely...
# There is no advantage to running multiple copies of xmcd (even if you
# have multiple CD-ROM's and multiple speakers, you only have one set of
# ears. This script checks to see if xmcd is already running and if not,
# then starts a new instance of it. It also checks for cda (the
# command-line version of xmcd). Ideally, one day it will check for more
# cd players too.
#
#  - kbyanc, 8/28/98

# first, we'll check for X-based CD-players with the hopes that one day we
# will be able to set focus to the other CD-player
for check in "xmcd" "workman" "xcdplayer"
do
  if [ `ps -cawx | grep -c -w $check` = 1 ]; then exit; fi  
done

# check for command-line CD-players...
for check in "cda" "cdplay"
do
  if [ `ps -cawx | grep -c -w $check` = 1 ]; then exit; fi  
done

xmcd $@ &



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSD/.3.91.980830052005.10995A-100000>