Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old October 26th, 2006   #1
crazy___cow
5 Cups of Ubuntu
 
crazy___cow's Avatar
 
Join Date: Jun 2006
Location: Italy
Beans: 29
HOWTO disable screensaver and powermanager while mplayer or other apps are running

I have written a small python daemon to disable gnome-screensaver and gnome-powermanager while certain specified apps are running.
It works quite well on Ubuntu Edgy. It requires dbus (>= 0.93), python-dbus, and obviously gnome-screensaver and gnome-powermanager (on gnome 2.16).
The idea is simple: I have seen how Totem is working, and I emulate its behavior with a small python daemon.
To install it just copy "disablegss.py" in /usr/local/bin, fix its execute permissions and create a simple config file in your homedir "~/.disablegss". In this config file add every application name that could stop gnome-screensaver, one for each line. Example:

Code:
mplayer
gmplayer
vlc
wxvlc
xine
gxine
Please notice you must insert the name of the app how you can see it on 'ps aux': for example if you want to add firefox, you must write a line with "/usr/lib/firefox/firefox-bin".
Now just launch disablegss.py on a terminal or simply add it on your session!
You can change the config file on fly (I check if someone modify it), adding or removing apps without restarting it.


HOW IT WORKS
Unfortunately the dbus and gnome development documentation are a bit outdated, so I have read totem sources to view which methods are called to stop gnome-screensaver and gnome-powermanager. The idea is if you call the Inhibit method of gnome-screensaver, you disable the screensaver AND the powermanager. To enable them again you must call the UnInhibit method. There is a small terminal app, dbus-send, to comunicate with dbus but it doesn't work well with these methods, so I decide to use the python dbus interface. This is my first program in python so please tell me if something is wrong or not well coded!
Every 60 secs the daemon check if there are apps running that are also present in the config file. If it's true, the screensaver is disabled. If someone change the config file, the daemon read it again.
I don't think that this small daemon could run on Dapper: the dbus and gnome API change on every release. But you can modify it to fix things. There are only two lines that could be problematic:

Line 38: cookie = dev.Inhibit(myprogram, 'Disabled by DisableGSS Daemon')
Line 49: dev.UnInhibit(cookie)

These two methos are different on gnome 2.14 on Dapper. Also dbus has radically changed. If you want to use disablegss.py on Dapper, find the right methods (try to see dapper totem sources) and feel free to change what you want!
To do debug, I suggest you to launch disablegss.py on a terminal and dbus-monitor on another one (you can see all messages from and to dbus daemon). Also change the sleep time value in seconds (line 121) to debug it faster.
Happy coding!
Attached Files
File Type: gz disablegss.tar.gz (1.6 KB, 1199 views)
crazy___cow is offline   Reply With Quote
Old October 26th, 2006   #2
wolf202
Just Give Me the Beans!
 
wolf202's Avatar
 
Join Date: Sep 2005
Location: Winnipeg, MB, Canada
Beans: 49
Ubuntu 6.10 Edgy
Send a message via AIM to wolf202 Send a message via MSN to wolf202 Send a message via Skype™ to wolf202
Re: HOWTO disable screensaver and powermanager while mplayer or other apps are runnin

great, will try it after I update, this problem has plagued me under windows and the vlc devs have ignored the bugs I have submitted.

-wolf
__________________
Proud to be registered Linux user #422854

wolf202 is offline   Reply With Quote
Old October 29th, 2006   #3
nyarla33
First Cup of Ubuntu
 
Join Date: Jun 2006
My beans are hidden!
Re: HOWTO disable screensaver and powermanager while mplayer or other apps are runnin

Thank you very much. Works fine for me.
nyarla33 is offline   Reply With Quote
Old October 31st, 2006   #4
iggee85
5 Cups of Ubuntu
 
Join Date: Jul 2005
Beans: 24
Re: HOWTO disable screensaver and powermanager while mplayer or other apps are runnin

Wow, thanks a lot for this. Solves a really annoying problem with mplayer.
iggee85 is offline   Reply With Quote
Old November 1st, 2006   #5
phoqueyoo
5 Cups of Ubuntu
 
Join Date: Aug 2006
Beans: 24
w00t

Good job.
phoqueyoo is offline   Reply With Quote
Old November 1st, 2006   #6
23meg
Ubuntu QA Team
 
Join Date: Mar 2005
Location: İstanbul
Beans: 5,882
Re: w00t

Thanks for the effort, appreciated.
__________________
"Theoretically, a great number of ideas assures a great number of choices, but such choices are essentially quantitative. This practice is as bewildering as it is wasteful. It discourages spontaneity, encourages indifference, and more often than not produces results which are neither distinguished, interesting, nor effective. In short, good ideas rarely come in bunches." -- Paul Rand, The Politics of Design
23meg is offline   Reply With Quote
Old November 1st, 2006   #7
hikaricore
RIP ~ Fluffy ~ 2006-2008
 
hikaricore's Avatar
 
Join Date: Aug 2006
Location: lewis center, ohio
Beans: 5,732
Kubuntu Development Release
Send a message via ICQ to hikaricore Send a message via AIM to hikaricore Send a message via MSN to hikaricore Send a message via Yahoo to hikaricore
Re: HOWTO disable screensaver and powermanager while mplayer or other apps are runnin

Quote:
Originally Posted by iggee85 View Post
Wow, thanks a lot for this. Solves a really annoying problem with mplayer.
Yay now mplayer + screensaver can't break my damn monitor again (for the third time). Screensaver faded, I attempted to stop it... now that monitor looks like it got coated with 4 coats of clear black no matter what I do, and gamma adjust looks like hell. Broke a monitor at work a similar way, really weird. But enough ranting. Thanks.
hikaricore is offline   Reply With Quote
Old April 3rd, 2007   #8
neymac
A Carafe of Ubuntu
 
neymac's Avatar
 
Join Date: Sep 2005
Location: Saquarema - Brasil
Beans: 145
Kubuntu 9.10 Karmic Koala
Re: w00t

Now, in Feisty Fawn Beta we have in the version MPlayer 2:1.0~rc1-0ubuntu8, the option to Stop XScreenSaver, in Preferences=>Misc of the gmplayer.
It works, but when you press the stop button (of mplayer) appears a error message(of mplayer) in a small window that says: "gnome_screensaver_control" .
Does anyone knows if is possible avoid this message (only occurs when I press the Stop Button of MPlayer, if I close it by pressing the "q" there is no error message)?
neymac is offline   Reply With Quote
Old April 9th, 2007   #9
gtr225
A Carafe of Ubuntu
 
gtr225's Avatar
 
Join Date: Feb 2007
Location: Jersey City, NJ, USA
Beans: 90
Ubuntu 9.04 Jaunty Jackalope
Re: w00t

Thanks a lot for this. This problem was frustrating me for ages and for some time I was forced to use totem. Now I can use VLC all the time and not have to worry about the screen saver popping up. I hope the gnome-screensaver developers will integrate this into the next version of gnome-screensaver or perhaps let users choose what programs need to run in order to halt gss. I would have thought the gss developers would have thought of this already but I guess they want everyone using totem
gtr225 is offline   Reply With Quote
Old May 20th, 2007   #10
Snapper187
First Cup of Ubuntu
 
Join Date: Nov 2005
Beans: 10
Re: w00t

Quote:
Originally Posted by neymac View Post
Now, in Feisty Fawn Beta we have in the version MPlayer 2:1.0~rc1-0ubuntu8, the option to Stop XScreenSaver, in Preferences=>Misc of the gmplayer.
Does Ubuntu use XScreenSaver by default?

I'm still on Edgy and not sure if I changed things, but right now I don't think I use XSS: If I start mplayer with that option (it's already available in Edgy's mplayer package), I get:

xscreensaver_disable: Could not find XScreenSaver window.
Snapper187 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:20 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry