Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 46

Thread: HOWTO: Disable screen saver while Flash is running

  1. #11
    Join Date
    Sep 2008
    Location
    KCMO area
    Beans
    90

    Re: HOWTO: Disable screen saver while Flash is running

    Well, it is weird. I do have the gnome-screensaver. I have the original script in place. It doesn't seem like it worked right in testing, it definitely seemed as though any interaction using putty was making it less predictable. Even taking that out of the equation, after shutting down firefox, the script properly changes idle_activation_enabled setting back to true, but then the screensaver doesn't seem to come back on.

    Then I gave up with it in that state, next day I noticed the screensaver seems to be working. So I guess it is working.

  2. #12
    Join Date
    Mar 2008
    Beans
    6

    Re: HOWTO: Disable screen saver while Flash is running

    Hi, after much searching of the net/forums/mailinglists/etc, I managed to find a way to determine if the current window is full screen. I haven't tested it extensively, so your results may vary, but I think it's relatively robust. I've also changed some of the variables to make it a bit more generic (and added a test for xine, my default dvd/movie player), and also turned off sleep/hibernate.

    Code:
    #!/bin/bash
    
    # cleanup any bad state we left behind if the user exited while flash was running
    gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
    
    turn_it_off=0
    sleepcomputer0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_computer_ac`
    sleepdisplay0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_display_ac`
    
    while true; do
    	sleep 60
    	SS_off=0
    	
    	# check to see if flashplayer is being used by firefox
    	for pid in `pgrep firefox` ; do
    		if grep libflashplayer /proc/$pid/maps > /dev/null ; then
    			SS_off=1
    		fi
    	done
    	
    	# check to see if xine is being used
    	if pgrep xine > /dev/null; then
    		SS_off=1
    	fi
    
    	# check to see if current application is fullscreen	
    	current_window_id=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d" " -f5`
    	if xprop -id $current_window_id | grep "_NET_WM_STATE_FULLSCREEN" > /dev/null; then
    		SS_off=1
    	fi
    
    	# read current state of screensaver
    	ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`
    	
    	# change state of screensaver as necessary
    	if [ "$SS_off" = "1" ] && [ "$ss_on" = "true" ]; then
    		gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool false
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int 0
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int 0
    		turn_it_off=1
    	elif [ "$SS_off" = "0" ] && [ "$ss_on" = "false" ] && [ "$turn_it_off" = "1" ]; then
    		gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int $sleepcomputer0
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int $sleepdisplay0
    		turn_it_off=0
    	fi
    
    done
    Last edited by rfourie; July 10th, 2009 at 03:37 PM.

  3. #13
    Join Date
    Aug 2007
    Location
    Chicago, IL, USA
    Beans
    1,429
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Disable screen saver while Flash is running

    Thanks, I'll have to give that a try.

  4. #14
    Join Date
    Aug 2007
    Location
    Chicago, IL, USA
    Beans
    1,429
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Disable screen saver while Flash is running

    I gave the new script a try. Unfortunately, it still works whenever flash is running, and not just while in full screen. I'll try to take a look at it and figure out what's wrong.

  5. #15
    Join Date
    Mar 2008
    Beans
    6

    Re: HOWTO: Disable screen saver while Flash is running

    Quote Originally Posted by Thelasko View Post
    I gave the new script a try. Unfortunately, it still works whenever flash is running, and not just while in full screen. I'll try to take a look at it and figure out what's wrong.
    Thelasko, do you mean that it doesn't disable the screensaver when flash is running, or that it doesn't disable the screensaver when the current application is full screen, or both?

  6. #16
    Join Date
    Aug 2007
    Location
    Chicago, IL, USA
    Beans
    1,429
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Disable screen saver while Flash is running

    Quote Originally Posted by rfourie View Post
    Thelasko, do you mean that it doesn't disable the screensaver when flash is running, or that it doesn't disable the screensaver when the current application is full screen, or both?
    No, it works. It's just that I was thinking it would disable the screensaver while flash was running and full screen. However, the script is written so the screensaver is disabled while flash is running or an application is full screen.

    I've made my own modification to the script. It seems to work pretty well, but I'm aware of one bug. It will disable the screensaver if flash is running and any application is full screen.

    Code:
    #!/bin/bash
    
    # cleanup any bad state we left behind if the user exited while flash was running
    gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
    
    turn_it_off=0
    sleepcomputer0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_computer_ac`
    sleepdisplay0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_display_ac`
    
    while true; do
    	sleep 60
    	SS_off=0
    	
    	# check to see if flashplayer is being used by firefox
    	for pid in `pgrep firefox` ; do
    		if grep libflashplayer /proc/$pid/maps > /dev/null ; then
    	# check to see if current application is fullscreen	
    	current_window_id=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d" " -f5`
    	if xprop -id $current_window_id | grep "_NET_WM_STATE_FULLSCREEN" > /dev/null; then
    		SS_off=1
    	fi
    		fi
    	done
    	
    	# check to see if xine is being used
    #	if pgrep xine > /dev/null; then
    #		SS_off=1
    #	fi
    #
    #	# check to see if current application is fullscreen	
    #	current_window_id=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d" " -f5`
    #	if xprop -id $current_window_id | grep "_NET_WM_STATE_FULLSCREEN" > /dev/null; then
    #		SS_off=1
    #	fi
    
    	# read current state of screensaver
    	ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`
    	
    	# change state of screensaver as necessary
    	if [ "$SS_off" = "1" ] && [ "$ss_on" = "true" ]; then
    		gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool false
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int 0
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int 0
    		turn_it_off=1
    	elif [ "$SS_off" = "0" ] && [ "$ss_on" = "false" ] && [ "$turn_it_off" = "1" ]; then
    		gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int $sleepcomputer0
    		gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int $sleepdisplay0
    		turn_it_off=0
    	fi
    
    done
    Also note that I commented out the part about Xine. I don't use Xine so I disabled it. I might change that to work with Miro instead.

  7. #17
    Join Date
    Mar 2008
    Beans
    6

    Re: HOWTO: Disable screen saver while Flash is running

    Oh, cool. This is my first real fix and I'm a bit proud of it...
    I did make it pretty generic for full-screen applications so that no matter what is playing full screen, it disables the screensaver. I might post to other threads about that part of the solution.

  8. #18
    Join Date
    Sep 2006
    Location
    Londinium
    Beans
    590
    Distro
    Ubuntu Studio 9.04 Jaunty Jackalope

    Re: HOWTO: Disable screen saver while Flash is running

    I was trying to adopt it to mplayer so my screen doesn't dim while playing movies but it didn't work. I modified two lines:
    Code:
        for pid in `pgrep mplayer` ; do
            if grep smplayer /proc/$pid/maps > /dev/null ; then
                flash_on=1
    but the screen still dims :/
    ThinkPad R61: C2D 2,1GHz, 4GB ram, NV Quadro, (modded Bios)
    XP 64bit guest, 7 64bit backup OS.

  9. #19
    Join Date
    Sep 2008
    Location
    KCMO area
    Beans
    90

    Re: HOWTO: Disable screen saver while Flash is running

    Two thoughts without looking up anything. Isn't MPlayer case sensitive? Maybe that grep isn't. Can't MPlayer do that with some command line switch?

    Hope that at least gets you googling in the right direction.

  10. #20
    Join Date
    Sep 2006
    Location
    Londinium
    Beans
    590
    Distro
    Ubuntu Studio 9.04 Jaunty Jackalope

    Re: HOWTO: Disable screen saver while Flash is running

    Well, smplayer has such optionin the menus and I was already using it but with no effect. However, yesterday, this option starded to work spontaneously (after a month!) so I don't need the script anymore.
    ThinkPad R61: C2D 2,1GHz, 4GB ram, NV Quadro, (modded Bios)
    XP 64bit guest, 7 64bit backup OS.

Page 2 of 5 FirstFirst 1234 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •