HOWTO disable screensaver and powermanager while mplayer or other apps are running
来源:互联网 发布:mac 删除 ds store 编辑:程序博客网 时间:2024/05/20 20:46
http://ubuntuforums.org/showthread.php?t=284804
HOWTO disable screensaver and powermanager while mplayer or other apps are running
Ihave written a small python daemon to disable gnome-screensaver andgnome-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 (ongnome 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 itsexecute permissions and create a simple config file in your homedir"~/.disablegss". In this config file add every application name thatcould stop gnome-screensaver, one for each line. Example:
Please notice you must insert the name of the app how you can seeit on 'ps aux': for example if you want to add firefox, you must writea 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 bitoutdated, so I have read totem sources to view which methods are calledto stop gnome-screensaver and gnome-powermanager. The idea is if youcall the Inhibit method of gnome-screensaver, you disable the screensaver AND the powermanager. To enable them again you must call the UnInhibitmethod. There is a small terminal app, dbus-send, to comunicate withdbus but it doesn't work well with these methods, so I decide to usethe python dbus interface. This is my first program in python so pleasetell me if something is wrong or not well coded!
Every 60 secs the daemon check if there are apps running that are alsopresent 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 andgnome 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 hasradically changed. If you want to use disablegss.py on Dapper, find theright methods (try to see dapper totem sources) and feel free to changewhat you want!
To do debug, I suggest you to launch disablegss.py on a terminal anddbus-monitor on another one (you can see all messages from and to dbusdaemon). Also change the sleep time value in seconds (line 121) todebug it faster.
Happy coding!
It works quite well on Ubuntu Edgy. It requires dbus (>= 0.93),python-dbus, and obviously gnome-screensaver and gnome-powermanager (ongnome 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 itsexecute permissions and create a simple config file in your homedir"~/.disablegss". In this config file add every application name thatcould stop gnome-screensaver, one for each line. Example:
Code:
mplayer
gmplayer
vlc
wxvlc
xine
gxine
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 bitoutdated, so I have read totem sources to view which methods are calledto stop gnome-screensaver and gnome-powermanager. The idea is if youcall the Inhibit method of gnome-screensaver, you disable the screensaver AND the powermanager. To enable them again you must call the UnInhibitmethod. There is a small terminal app, dbus-send, to comunicate withdbus but it doesn't work well with these methods, so I decide to usethe python dbus interface. This is my first program in python so pleasetell me if something is wrong or not well coded!
Every 60 secs the daemon check if there are apps running that are alsopresent 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 andgnome 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 hasradically changed. If you want to use disablegss.py on Dapper, find theright methods (try to see dapper totem sources) and feel free to changewhat you want!
To do debug, I suggest you to launch disablegss.py on a terminal anddbus-monitor on another one (you can see all messages from and to dbusdaemon). Also change the sleep time value in seconds (line 121) todebug it faster.
Happy coding!
- HOWTO disable screensaver and powermanager while mplayer or other apps are running
- HOWTO MPlayer
- How do I disable the screensaver/lock?
- HowTo--mplayer 开发
- Running Android apps using Docker and ARC Welder
- Code insight and other background tasks are disabled.
- Interacting with Other Apps
- PDO报错:Cannot execute queries while other unbuffered queries are active.
- yii General error: 2014 Cannot execute queries while other unbuffered queries are active
- HOWTO Rip Streams With MPlayer
- Install liferay framework and integrate with MySql or other database
- HowTo: iOS Apps - Static analysis
- ORA-03113 And ORA-03114 While Running Utlrp.sql
- Receiving Content from Other Apps
- android-Interacting with Other Apps
- Interacting with Other Apps笔记
- Native Apps are Doomed
- iPhone app rejected Reasons 2.13: Apps that are primarily marketing materials or advertisements will
- js 倒计时
- 人生的第一次面试
- MTK铃声修改方法
- UML软件设计基础(UML图详解)
- 虚心求教
- HOWTO disable screensaver and powermanager while mplayer or other apps are running
- NO.31 Html,Jsp,Rtf中文乱码解决方法大搜集
- 手机操作系统之三国
- 内核中tcp状态
- Oracle TO_DATE,to_char
- java.lang.reflect.Method (java反射机制)
- DirectUI SDK Guider 网址
- 我的人生
- http协议概述