Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 46

Thread: HOWTO: Disable screen saver while Flash is running

  1. #21
    Join Date
    Nov 2006
    Location
    There and back again
    Beans
    1,097

    Re: HOWTO: Disable screen saver while Flash is running

    This script doesn't detect flash but will suspend the screen saver for KDE 4, disable xorg server blanking, and disable dpms.

    Code:
    #!/bin/bash
    # screenblank - Toggle screen blanking/powersaving/screensaver on/off in KDE 4.
    # Useful for when watching movies...
    
    # Tests for X server blanking / Monitor blanking
    xblanktest=$(xset -q | grep timeout | awk '{printf $2}')
    dpmstest=$(xset -q | grep "  DPMS is Enabled")
    
    if [[ "$xblanktest" -gt 0 ]] || [[ -n "$dpmstest" ]]; then
      # Turn off X blanking, Monitor blanking
      xset s off; xset -dpms
      # Supend screensaver
      echo '#!/bin/bash'  >  /tmp/suspend-dbus-screensaver
      echo 'while :'      >> /tmp/suspend-dbus-screensaver
      echo 'do'           >> /tmp/suspend-dbus-screensaver
      echo 'qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity' \
                          >> /tmp/suspend-dbus-screensaver
      echo 'sleep 119'    >> /tmp/suspend-dbus-screensaver
      echo 'done'         >> /tmp/suspend-dbus-screensaver
      chmod u+x /tmp/suspend-dbus-screensaver
      nohup "/tmp/suspend-dbus-screensaver" &> /dev/null &
      echo " - Disabled screen blanking, powersaving, and screensaver"; else
      # Resume X blanking, Monitor blanking
      xset s on; xset +dpms
      # Resume screensaver
      pkill suspend-dbus
      echo " + Enabled screen blanking and powersaving, and screensaver"
    fi
    
    # Limitations:
    #  Unable to tell if screensaver is active
    #   qdbus org.freedesktop.ScreenSaver /ScreenSaver GetActive  always returns
    #   false
    #  Enables both X server blanking and DPMS even if one is orginally turned off
    Last edited by Gen2ly; August 24th, 2009 at 06:45 PM.

  2. #22
    Join Date
    May 2007
    Beans
    563
    Distro
    Kubuntu 8.04 Hardy Heron

    Re: HOWTO: Disable screen saver while Flash is running

    Quote Originally Posted by Lockheed View Post
    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.
    From the smplayer FAQ:
    21. The screensaver doesn't turn off, why?

    If you use a recent version of MPlayer you may need to add a line like this in your ~/.mplayer/config:
    (gnome)
    heartbeat-cmd="gnome-screensaver-command -p &>/dev/null"
    (kde)
    heartbeat-cmd="dcop kdesktop KScreensaverIface enable false &>/dev/null && dcop kdesktop KScreensaverIface enable true &>/dev/null"
    Please take a look at the MPlayer manpage for more info.
    Developer of SMPlayer.

  3. #23
    Join Date
    Sep 2006
    Location
    Londinium
    Beans
    602

    Re: HOWTO: Disable screen saver while Flash is running

    Quote Originally Posted by rvm4000 View Post
    From the smplayer FAQ:
    I will try that cause the dimming is back again for no apparent reason.
    ThinkPad W500: C2D 2,5GHz, 8GB ram, GPU Intel & ATI, Middleton BIOS, SSD + UltraBay HDD, USB 3.0 ExpressCard, BTRFS + full disk encryption.

  4. #24
    Join Date
    Nov 2005
    Beans
    144

    Re: HOWTO: Disable screen saver while Flash is running

    Hi,

    there's also a new project called Caffeine.

    Best regards,
    Whoopie

  5. #25
    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've been having some trouble with the script not exiting cleanly. Basically, when I close a Flash movie the screen saver remains disabled.

    Does anybody have any suggestions to fix this?

  6. #26
    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

    What is the while loop for? Why does it say "while true" while what is true?

    Edit: Nevermind
    Note the use of the true statement. This means: continue execution until we are forcibly interrupted (with kill or Ctrl+C).
    Last edited by Thelasko; September 30th, 2009 at 03:38 PM.

  7. #27
    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 think I fixed it!

    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 miro > /dev/null; then
    		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
    #
    #	# 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
    #	I think this is the problem.  Some states are not accounted for, so we use else instead
    #	elif [ "$SS_off" = "0" ] && [ "$ss_on" = "false" ] && [ "$turn_it_off" = "1" ]; then
    	else
    		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
    edit: Never mind, this doesn't work at all.
    Last edited by Thelasko; October 8th, 2009 at 04:43 PM.

  8. #28
    Join Date
    Jan 2009
    Location
    Austin, TX
    Beans
    Hidden!
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: Disable screen saver while Flash is running

    Its a manual click, but I use the Inhibit Applet on the Panel. Quick and easy to disable / enable screensaver & sleep.

  9. #29
    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

    If you can get it to work, Hulu Desktop automatically disables the screen saver.

  10. #30
    Join Date
    Oct 2005
    Beans
    7

    Re: HOWTO: Disable screen saver while Flash is running

    doesn't work with google chrome. but it still great script

Page 3 of 5 FirstFirst 12345 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
  •