Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know mplayer has some heartbeat setting but I don't recall what it is, could anyone tell me?

another one of those annoying things that used to just work and somewhere along the line stopped being default

share|improve this question

2 Answers 2

up vote 4 down vote accepted

mplayer has the switch -heartbeat-cmd to run a command every 30 seconds, but as the man page says:

This can be "misused" to disable screensavers that do not support the proper X API

The actual switch meant to disable screensavers is -stop-xscreensaver; you should probably try that first

share|improve this answer
    
I put -stop-xscreensaver in ~/.mplayer/config when trying to play a video I got this error: Option -stop-xscreensaver needs a parameter at line 2 ideas? –  xenoterracide Aug 28 '10 at 15:47
3  
@xeno Every option in the config file needs to have a value; if it's just a boolean flag, set it equal to true, yes, or 1. You also shouldn't include the - when you're using the config file, so you'll get a warning about an unknown option (it sees your entry for -stop-xscreensaver and looks for the flag --stop-xscreensaver); it should read stop-xscreensaver=true instead –  Michael Mrozek Aug 28 '10 at 18:03
    
now if only I could do the same thing with flash/<video> –  xenoterracide Aug 29 '10 at 14:12
1  
@xenoterracide you can use mplayer to watch flash videos, load the video, look in /tmp and play the video with mplayer :P –  hiena Aug 30 '10 at 12:56

mplayer -stop-xscreensaver does not work for me (Debian wheezy; xscreensaver=5.15-3, xfce4=4.8.0.3, mplayer=2:1.0~rc4.dfsg1+svn34540-1+b2) - the screensaver still comes on during the movie. I wrote a screensaver inhibition tool xscreensaver-inhibit, and an mplayer wrapper play. xscreensaver-inhibit is useful for other things like youtube so I put a shortcut on my panel for it.

$HOME/bin/xscreensaver-inhibit is as follows:

#!/bin/bash
usage () {
    echo "usage: $0 [on|off]"
    echo '    Turns screensaver inhibition on or off.'
    echo '    default: toggle on/off'
    exit 1;
}

if [ -n "$1" ]  ; then
    [ "$1" = "on" -o "$1" = "off" ] || usage
fi

inhibit () {
    while [ -f "$lock" ] ; do
        # echo "$lock exists"
        DISPLAY=:0 xdg-screensaver reset
        sleep 50
    done
    # echo "$lock is gone"
}

lock="/tmp/xsi.lock"

if [ -e "$lock" ] ; then
    echo 'Screensaver currently inhibited.'
    on='on'
else 
    echo 'Screensaver operating normally.'
    on=''
fi

if [ "$1" = "on" ] ; then
    if [ -n "$on" ] ; then
        echo 'Starting screensaver inhibitor anyway.'
    else 
        echo 'Screensaver inhibitor started.'
    fi
    touch "$lock" && inhibit &
fi

if [ "$1" = "off" ] ; then
    if [ -n "$on" ] ; then
        echo 'Screensaver inhibitor(s) stopped.'
    else 
        echo 'Perhaps the screensaver daemon is not running or another program is inhibiting it.'
    fi
    rm -f "$lock"
fi

if [ ! -n "$1" ] ; then
    if [ -n "$on" ] ; then
        echo 'Screensaver inhibitor(s) stopped.'
        rm -f "$lock"
    else 
        echo 'Screensaver inhibitor started.'
        touch "$lock" && inhibit &
    fi
fi

$HOME/bin/play is as follows:

#!/bin/sh

xscreensaver-inhibit on

DISPLAY=:0 mplayer -fs "$@"

xscreensaver-inhibit off

I included DISPLAY=:0 so the movie will play on the local active display even when I am logged in over SSH. play is also the default handler for all movie files in my file manager.

Note that sox provides /usr/bin/play so if you have sox installed, you might want to call play something else.

You can write similar wrappers for your other fullscreen apps that you don't want the screensaver interrupting.

xscreensaver-inhibit works on all DEs, Linuxes, and screensavers on which I have tried it. In case you get xdg-screensaver: command not found, run apt-get install xdg-utils.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.