Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (Not For Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (Not For Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Thread Tools Search this Thread Display Modes
Old 21st January 2012, 04:08 PM
mikeym Offline
Registered User
Join Date: Oct 2011
Posts: 139
HOWTO: Inhibit Gnome-Screensaver when Flash is fullscreen in Gnome 3


This is a quick script I wrote to inhibit gnome-screensaver when Flash is in fullscreen. I had to write it because I realised that existing scripts to inhibit the screensaver from gnome 2 no longer worked and in fact it was impossible to convert them (I tried) to gnome 3 as they were written in Bash.

Anyway, put the following in $HOME/bin/flash-screensaver-inhibitor.py

#!/usr/bin/python -u
# #######################################
# Inhibit Screensaver in Flash in Gnome 3
# By mikey
# Contact abc.mikey (at) googlemail.com
# NOTE the -u switch in the hashbang that 
#      turns on unbuffered stdout for 
#      debuging

from Xlib.display import Display
from Xlib import X, error
from time import sleep
import dbus

# Check we are still connected, by sending NoOp to X
def X_session_connected(display):
  except error.ConnectionClosedError:
    return False
  return True

bus = dbus.SessionBus()
proxy = bus.get_object ('org.gnome.SessionManager', '/org/gnome/SessionManager')
sessionManager = dbus.Interface (proxy, 'org.gnome.SessionManager')
cookie = 0
display = Display()
root = display.screen().root
count = 0

while X_session_connected(display):
  count += 1
  # Poll approx once every minute; 30 * 2 seconds
  if count == 30:
    count = 0
    ret = root.get_full_property(display.intern_atom('_NET_ACTIVE_WINDOW'), X.AnyPropertyType)
    if ret is not None:
      windowID = ret.value[0]
      if windowID != 0:
        window = display.create_resource_object('window', windowID)
        title = window.get_wm_name()
        winclass = window.get_wm_class()
        print 'Active Window: ', title, ' ; ', winclass
        if title == 'exe' and 'Exe' in winclass:
          if cookie == 0:
            print 'Inhibiting Gnome Screensaver'
            cookie = sessionManager.Inhibit ("flash-screensaver-inhibitor.py", 0, "Flash fullscreen override", 8)
          if cookie != 0:
            print 'Uninhibiting Gnome Screensaver'
            cookie = 0
        print 'Root window active'

# NOTE usefull command to show if screensaver is inhibited:
# dbus-send --session --dest=org.gnome.SessionManager --type=method_call --print-reply --reply-timeout=20000 /org/gnome/SessionManager org.gnome.SessionManager.IsInhibited uint32:8
And make it executable with chmod +x $HOME/bin/flash-screensaver-inhibitor.py

And copy the following into $HOME/.config/autostart/flash-screensaver-inhibitor.desktop

[Desktop Entry]
Exec=sh -c "$HOME/bin/flash-screensaver-inhibitor.py &> /dev/null"
Name[en_US]=Flash Screensaver Inhibitor
Name=Flash Screensaver Inhibitor
Comment[en_US]=Inhibit screensaver when viewing Flash
Comment=Inhibit screensaver when viewing Flash
You can then disable it later if you like using the Startup Applications dialogue: gnome-session-properties

If you need to debug for any reason, try changing /dev/null to a desired log file from gnome-session-properties

That's it!

Fix: Fixed a stupid mistake that allowed the screensaver to still activate. Now inhibits properly.

Last edited by mikeym; 23rd January 2012 at 12:57 AM. Reason: Script fix
Reply With Quote
Old 13th August 2012, 11:23 PM
jazzer Offline
Registered User
Join Date: May 2004
Location: Ontario, Canada
Posts: 64
Re: HOWTO: Inhibit Gnome-Screensaver when Flash is fullscreen in Gnome 3

Thank you for this script!

I know there exists a couple different extensions for gnome3 that will do this, but I feel this should be done automatically wherever it can be done.

One thing I will note your line:

if title == 'exe' and 'Exe' in winclass:
I had to replace it with this to get it to work,

if title == 'plugin-container' and 'plugin-container' in winclass:
This was the only way it would inhibit the blanking of the screen using Firefox 14. The only other thing I am going to try and debug is that it seems to stop running on it's own. I haven't yet spent the time to find the problem. I will update this when I find the solution.

Many thanks!
Reply With Quote
Old 17th August 2012, 07:43 PM
jazzer Offline
Registered User
Join Date: May 2004
Location: Ontario, Canada
Posts: 64
Re: HOWTO: Inhibit Gnome-Screensaver when Flash is fullscreen in Gnome 3

Ok. All I can say is it's failing on an unhandled exception. I haven't had time to debug it any further and don't really remember python well enough to figure out more.

I've gone back (for now) of using an extension in gnome3 to inhibit the blanking of the screen.
Reply With Quote

flash, fullscreen, gnome, gnome 3, gnome-screensaver, gnomescreensaver, howto, inhibit

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
gnome inhibit applet missing from Fedora 14 ? megaloman Using Fedora 0 16th November 2010 06:20 PM
F13: gnome-mplayer does not start in fullscreen borispr Using Fedora 7 6th September 2010 05:04 PM
gnome inhibit applet missing from 12? leftoflexo Using Fedora 2 19th April 2010 10:19 PM
HowTo: gnome guy wants to build statically linked Qt application (for flash drive) fwelland Using Fedora 9 14th November 2008 05:16 PM
Adding the xscreensaver batch & customizing screensaver options in gnome-screensaver Firewing1 Guides & Solutions (Not For Questions) 27 14th July 2006 11:09 PM

Current GMT-time: 20:51 (Tuesday, 19-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat