Howto disable screensaver and powermanager while mplayer or other apps are running

Source: Internet
Author: User

Http://ubuntuforums.org/showthread.php? T = 284804

 

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 restart (> = 0.93 ),
Python-extract, and obviusly 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
Cocould 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-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 region 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
CallInhibit
Method of gnome-screensaver, you disable the screensaver and the powermanager. To enable them again you must callUninhibit
Method. There is a small terminal app, publish-send, to comunicate
Wait but it doesn' t work well with these methods, so I decide to use
The Python secure 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 cocould run on dapper: the same and
Gnome API change on every release. But you can modify it to fix things.
There are only two lines that cocould 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 passed has
Radically changed. If you want to use disablegss. py on dapper, find
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
Monitoring-monitor on another one (you can see all messages from and to messages
Daemon). Also change the sleep time value in secondds (line 121)
Debug it faster.
Happy coding!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.