PDA

View Full Version : Start / Quit Screenlet Script


Simon
August 27th, 2007, 05:59 PM
How would I go about writing a script that would quit all screenlets and another to start them all again?

Ideally I want a script that replaces compiz with metacity and quits the screenlets and another to load compiz, emerald and the screenlets but I wouldn't know where to post that, so just the screenlet script will do for now I guess.

The reason for this is that I have to quit compiz to play UT2004. If I leave the screenlets running when I quit compiz, then when I re-activate it, the screenlets move from where I want them and I cannot move them back.

plun
August 27th, 2007, 07:22 PM
There is already a script with fusion-icon.... I cannot understand why this
isnt included in packages :confused:

http://gitweb.opencompositing.org/?p=users/crdlb/fusion-icon;a=summary

I agree about Screenlets and I believe RYX must change this to also let
screenlets-manager handles start/stop instead of session starters for
each screenlet.

Have you tried to use the Widget plugin for disabling screenlets ?

Simon
August 27th, 2007, 08:51 PM
Thank you, now have fusion-icon installed and working :)

Unless I'm missing something, the Widget layer whilst useful doesn't do what I'd need it to do.

When I swap from compiz back to metacity, even if the widget layer is hidden, the screenlets appear on the desktop - ideally I need them to close.

plun
August 27th, 2007, 09:03 PM
Thank you, now have fusion-icon installed and working :)

Unless I'm missing something, the Widget layer whilst useful doesn't do what I'd need it to do.

When I swap from compiz back to metacity, even if the widget layer is hidden, the screenlets appear on the desktop - ideally I need them to close.

OK..... I just tested this and switched to Metacity with fusion-icon and it also breaks the widget plugin...:(

The best way would be to have a function in screenlets-manager > kill all screenlets and start all screenlets

Now they are in Sessions...

I have no idea... maybe RYX or someone else have good ideas how to solve it ... "whise" can perhaps make a new screenlet for this...:):D

rgdg
August 27th, 2007, 09:09 PM
I wrote a little script that toggles between metacity and compiz, and my screenlets stay hidden with metacity and are fine when I restart compiz/

Heres the script. Link a launcher to it and it checks if compiz is running and acts accordingly. replace avant with any other compositing needy programs.


#!/bin/bash
#toggle between compiz and metacity

if ps ax | grep -v grep | grep -v defunct | grep "compiz.real"> /dev/null
then
killall avant-window-navigator;
killall compiz.real;
metacity --replace &
else
compiz --replace &
avant-window-navigator &

fi

Simon
August 27th, 2007, 09:11 PM
I wrote a little script that toggles between metacity and compiz, and my screenlets stay hidden with metacity and are fine when I restart compiz/

Heres the script. Link a launcher to it and it checks if compiz is running and acts accordingly. replace avant with any other compositing needy programs.


#!/bin/bash
#toggle between compiz and metacity

if ps ax | grep -v grep | grep -v defunct | grep "compiz.real"> /dev/null
then
killall avant-window-navigator;
killall compiz.real;
metacity --replace &
else
compiz --replace &
avant-window-navigator &

fi


Not sure what's wrong with mine, but they won't hide when metacity is launched.

Simon
August 27th, 2007, 09:38 PM
How would I go about quiting a screenlet from terminal?

If screenlets only work (properly) with compositing, wouldn't it be possible to stop them loading unless compositing was enabled?

RYX
August 27th, 2007, 10:19 PM
The screenlets also work without compositing, they just look ugly in that case. I will add support for non-composited environments sooner or later, but it will still look ugly anyway (no compositing means crappy 8bit images for the shape :)) ...

To quit a screenlet from the terminal you will need its process id. You can get it like this (using the Clock as example here): ps aux | grep ClockScreenlet.py
(Will return two processes, one of them is the command you entered because it also contains the name)

Then just kill the process with the given id.

Simon
August 27th, 2007, 11:00 PM
Thank you :)

plun
August 27th, 2007, 11:18 PM
Then just kill the process with the given id.

Well... all users are lazy...:p

I have 12 screenlets running...

I just found a nice file within the tmp directory... "screenlets.running"

Take this file and make a kill script....:confused:

To start again its probably easiest with an Ctrl-Alt-Backspace and login again...;)

RYX
August 28th, 2007, 02:13 AM
The recommended way for a script would be to query the list of running screenlets from the system (screenlets.utils.list_running_screenlets()) and then connect to each screenlet's DBus-service and send a quit signal (don't remember if its implemented yet :)) ... It may take a few milliseconds longer, but is the more standard-conform way and better compatible with possible changes in future versions.

But if there is a reliable way of retrieving all PIDs of running screenlets through a script, it may be ok as well ... The command I posted above is not really reliable - it could find much more processes than the two ones it is intended to return.

:)

vadi
August 28th, 2007, 08:31 PM
I don't think that support to have screenlets run without a composite manager is really that necessary... if you want screenlets, you're definitely the type who'd get compiz.

And if it's a newbie that thought that screenlets look cool and found them before Compiz, tell them to get compiz!

bal
July 23rd, 2008, 06:30 PM
Hi!

I know its an old thread, but I found a possible solution from another forum.
The script I use to restart my NowPlaying screenlet:
#!/bin/bash
## Screenlet restart script.

# Find out the process id of the screenlet
# (replace 'NowPlaying' with your desired screenlet):
pid=`ps -ef | grep NowPlaying | grep -v grep | awk '{print $2}'`

# Stop screenlet:
# Without the '-9' it didn't worked for me
kill -9 $pid

# The screenlet start command:
screenletsd --cli run NowPlaying

exit
Hope that helps.
Bye!

some-guy
July 23rd, 2008, 07:24 PM
this should restart them all
#!/bin/bash
## Screenlet restart script.
for myscreenlet in `cat /tmp/screenlets/screenlets.$USER.running`; do
# Find out the process id of the screenlet
pid=`ps -ef | grep $myscreenlet | grep -v grep | awk '{print $2}'`

# Stop screenlet:
# Without the '-9' it didn't worked for me
kill -9 $pid

# The screenlet start command:
screenletsd --cli run `echo $myscreenlet | sed -e s,Screenlet,,`
done; exit