Re: [Evolution] Determining from a Shell script whever evolution is running



Now I wrote a shell script to start up evolution, and it includes
oaf-slay. But as it is, I am afraid to put it into the KDE menu. What if
Evo is already running when I select the item? oaf-slay would kill it...

I may be wrong, but IMHO you need oaf-slay only once, if you want the
same language-setting every time. oaf-slay killed some processes which
still had the old env variables.


So, I'd like to find out within the shell script whether Evolution is
already running. (If so, it should switch to its window or maybe just do
nothing).

Is there any way to find out?

% /sbin/pidof evolution

will answer with the current pid(s) of running evolution, if any. It
even will return a pid, if there is a running evolution for another
user. That means, you get a false positive, if another user is running
evolution remotely. If you are totally sure, this does not happen, you
can use it:

% /sbin/pidof evolution || oaf-slay


If you cannot execute pidof as user or want to make sure the running
evolution belongs to you, you can use:

% ps w -u `id -u` | grep `which evolution` || oaf-slay

Notes:
- The parameter 'w' should not be necessary if executed in a script.
- Commands in backticks ` are executed and substituted by their return
values. This should be safe for all users. Of course you can hardcode
your username (or userid) and /usr/bin/evolution if you are sure they
will never change.


Both commands only will execute oaf-slay if evolution is not running.

If you have questions, feel free to ask or read the man-pages. ;-)

...guenther


-- 
char *t="\10pse\0r\0dtu\0  ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}




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