음악과 비디오를 재생할 때 시스템이 정지되지 않도록 할 수 있습니까?

음악과 비디오를 재생할 때 시스템이 정지되지 않도록 할 수 있습니까?

내 친구가 비디오나 음악 플레이어를 사용할 때 YouTube 활동을 포함하여 컴퓨터가 일시 중지되지 않도록 설정할 수 있는 패치를 얻을 수 있는지 알고 싶었습니다. 같은 패치라도 상관없을 것 같아요.

그는 Toshiba를 사용하고 있으며 Ubuntu 11.10을 실행하고 있습니다. 나는 HP에 있고 Ubuntu 11.10을 실행하고 있습니다.

답변1

  1. xmacro 설치(sudo apt-get install xmacro)

  2. "myxmacro"라는 파일을 만들고 다음 내용을 제공합니다.

암호:

MotionNotify 90 90 
MotionNotify 120 120

3. "no.idle.sh" 파일을 생성하고 실행 가능하게 만듭니다.

암호:

touch no.idle.sh
chmod +x no.idle.sh

4.4. "no.idle.sh" 파일을 생성하고 실행 가능하게 만듭니다: 암호:

touch no.idle.sh
chmod +x no.idle.sh

다음 내용을 제공하십시오.

암호

    #!/bin/bash
# No.idle.sh prevents GNOME to turn IDLE 
# if there is any sound sent to speakers
# This script requires the package "xmacro"
# (apt-get install xmacro)
###########################################
# This script requires a textfile called "myxmacro"
# with the following (dummy) content:
# ------------ myxmacro ------------
# MotionNotify 90 90 
# MotionNotify 120 120
# ----------------------------------
# You need to fix the path to "myxmacro" in line 31
#
#############################################

# set Log-File
LOG=/home/YOUR_USERNAME/noidle.log
sound=0
silence=0


while true; do
    sleep 1
    Datum=`date +%d.%m.%Y-%H:%M:%S`    

    # check if sound is sent to speaker    
    if pactl list | grep RUNNING > /dev/null; then
        echo "[$Datum] Sound (Ping: $sound)" >> $LOG
        sound=$((sound+1));
        xmacroplay :0 </path/to/myxmacro
        silence=0
    else
        echo "[$Datum] Silence (Ping: $silence)"    >> $LOG
        silence=$((silence+1));
        sound=0
    fi
    #----------------------------------------------------
done

다음을 수행해야 합니다. - 18행에서 로그 파일 경로를 수정합니다.

  • 31번째 줄에서 "myxmacro" 경로를 수정하세요.

    1. GNOME-Startup-Items에 "no.idle.sh" 스크립트를 추가하여 시작할 때마다 no.idle.sh가 실행되도록 하세요.

완료.

스크립트의 기능: 스크립트는 스피커로 전송된 사운드가 있는지 매초 확인합니다(터미널 명령 pactl list | grep RUNNING 사용).

음악이 실행 중이면 마우스 움직임을 시뮬레이션합니다(xmacroplay 사용). 이는 그놈 세션이 유휴 상태로 실행되지 않는 효과가 있습니다(결과적으로 PC가 일시 중지되지 않습니다).

재생되는 음악이 없으면 아무 작업도 수행하지 않습니다(따라서 세션이 유휴 상태로 실행될 수 있으며 그 후에는 일시 중지됩니다).

터미널에 입력하여 음악을 확인하는 스크립트를 볼 수 있습니다.

tail -f /path/to/noidle.log

답변2

내 생각엔 카페인이 화면 보호기가 표시되는 것을 방해한다고 생각합니다(이것이 당신의 뜻이라면).

http://www.webupd8.org/2009/10/caffeine-10-for-linux-released.html

https://launchpad.net/~caffeine-developers/+archive/ppa

https://launchpad.net/caffeine

관련 정보