Fedora Linux Support Community & Resources Center

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

Forgot Password? Join Us!

Guides & Solutions (No 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
Prev Previous Post   Next Post Next
  #1  
Old 21st January 2012, 03:08 PM
mikeym Offline
Registered User
 
Join Date: Oct 2011
Posts: 131
linuxchrome
HOWTO: Inhibit Gnome-Screensaver when Flash is fullscreen in Gnome 3

Hi,

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

Code:
#!/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):
  try:
    display.no_operation()
    display.sync()
  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)
        else:
          if cookie != 0:
            print 'Uninhibiting Gnome Screensaver'
            sessionManager.Uninhibit(cookie)
            cookie = 0
      else:
        print 'Root window active'
  sleep(2)



# 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

Code:
[Desktop Entry]
Type=Application
Exec=sh -c "$HOME/bin/flash-screensaver-inhibitor.py &> /dev/null"
Hidden=false
X-GNOME-Autostart-enabled=true
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; 22nd January 2012 at 11:57 PM. Reason: Script fix
Reply With Quote
 

Tags
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 05: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 04:16 PM
Adding the xscreensaver batch & customizing screensaver options in gnome-screensaver Firewing1 Guides & Solutions (No Questions) 27 14th July 2006 11:09 PM


Current GMT-time: 15:43 (Wednesday, 23-07-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

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