How to check if screen saver is running?

I have a script written in bash, which I need to take different route in case screensaver is currently running. This is Linux with Xorg and KDE. Script is called from cron, and it connects to DISPLAY=:0.

Any hint/idea how to check for state of screensaver?


If it is KDE4 you are running, you can use dbus to check if the screen saver is running:

$ qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive


$ qdbus org.kde.screensaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive

This works also for gnome, but they are known for not following FreeDesktop standards, so you have to use:

$ qdbus org.gnome.ScreenSaver /ScreenSaver org.gnome.ScreenSaver.GetActive

Last but not least, you can check whether the standard X screen server is running using XScreenSaverQueryInfo() and checking the state field.

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.