告诉 mplayer 阻止屏幕保护程序在播放时启动

告诉 mplayer 阻止屏幕保护程序在播放时启动

我知道 mplayer 有一些心跳设置,但我不记得它是什么,有人可以告诉我吗?

另一件烦人的事情过去可以正常工作,但后来不再是默认的了

答案1

mplayer可以切换-heartbeat-cmd为每 30 秒运行一次命令,但正如手册页所述:

这可能会被“滥用”来禁用不支持正确 X API 的屏幕保护程序

禁用屏幕保护程序的实际开关是-stop-xscreensaver;你应该先尝试一下

答案2

mplayer -stop-xscreensaver对我不起作用(Debian wheezy; xscreensaver=5.15-3, xfce4=4.8.0.3, mplayer=2:1.0~rc4.dfsg1+svn34540-1+b2) - 屏幕保护程序在电影期间仍然打开。我编写了一个屏幕保护程序抑制工具xscreensaver-inhibit和一个 mplayer 包装器playxscreensaver-inhibit对于像 youtube 这样的其他东西很有用,所以我在面板上放了一个快捷方式。

$HOME/bin/xscreensaver-inhibit如下:

#!/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"
# UPDATE Dec 2018 this command seems to have stopped working after upgrading to Debian Stretch.
        # DISPLAY=:0 xdg-screensaver reset
# Replaced with this command which is working for me,
# though if you do not use xscreensaver you might need something else.
        DISPLAY=:0 xscreensaver-command -deactivate
        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如下:

#!/bin/sh

xscreensaver-inhibit on

DISPLAY=:0 mplayer -fs "$@"

xscreensaver-inhibit off

我加入了,DISPLAY=:0这样即使我通过 SSH 登录,电影也会在本地活动显示器上播放。play也是我的文件管理器中所有电影文件的默认处理程序。

请注意,如果您已sox安装,则可能需要调用其他内容。/usr/bin/playsoxplay

您可以为您不希望屏幕保护程序中断的其他全屏应用程序编写类似的包装器。

xscreensaver-inhibit适用于我尝试过的所有桌面环境、Linux 和屏幕保护程序。如果你得到了xdg-screensaver: command not found,就跑apt-get install xdg-utils

2018 年 12 月更新将主命令从 更改xscreensaver-inhibitxdg-screensaver-xscreensaver-command未在所有 DE、Linux、屏幕保护程序上进行测试。青年MMV

答案3

对我来说是--stop-screensaver

当使用 --stop-xscreensaver 时,mplayer 警告我:选项 --stop-xscreensaver 已替换为 --stop-screensaver,并且将来可能会被删除。

Debian & mpv 0.23.0 (C) 2000-2016 mpv/MPlayer/mplayer2 项目

相关内容