우분투의 모든 버전을 다른 방식으로 처리해야하기 때문에 지금이 문제에 지쳤습니다.하지만 14.04에서는 더 이상 무엇을해야할지 모르겠습니다.
내 문제 : crontab이 재생할 음악을 선택하는 스크립트를 시작하고, Rhythmbox를 시작하고, 선택한 파일 또는 목록을 재생 대기열에 추가하고 재생하기 때문에 내 PC가 매일 자동으로 시작되어 경고 역할을합니다.
이제 문제는 스크립트가 터미널에서 실행할 때 완벽하게 작동하지만 crontab Rhythmbox로 시작하면 대부분 시작되지 않는다는 것입니다.
내 crontab :
MAILTO=""
XAUTHORITY=~/.Xauthority
DISPLAY=:0.0
# m h dom mon dow command
*/10 * * * * /scripts/copy_loop.sh &
#start alert
50 6 * * 1 /scripts/alert.sh #mo
50 6 * * 2 /scripts/alert.sh #di
50 6 * * 3 /scripts/alert.sh #mi
50 6 * * 4 /scripts/alert.sh #do
50 6 * * 5 /scripts/alert.sh #fr
30 7 * * 6-7 /scripts/alert.sh #sa/so
/script/copy_loop.sh
스크립트가 완벽하게 실행하는 다른 스크립트입니다 (하지만 모두에서 프로그램을 시작하지 않습니다 ...)
경고 스크립트 : #! / bin / bash
logfile="/scripts/log/alert.log"
exec >> $logfile 2>&1
echo "***********************************"
echo "* Start ("`date +'%d.%m.%Y %H:%M'`") as `whoami` *"
echo "***********************************"
#To avoid heart-attacks ;)
amixer set Master 14
echo "Turning monitors on and waiting 5 seconds."
#Force Monitor to turn on (grafik bug!)
xset dpms force on
sleep 5
#how many days should a song be blocked?
days=25
#Create array of music
music=( "Dubstep von Hannes/1-45 The Sound of Dubstep 4 - Mix 1.mp3"
"Purity Ring's Shrines.MP3"
"XXYYXX - XXYYXX (Full Album).MP3"
"Bonobo/Days to Come Disc 1/"
"LIQUID STRANGER - BABYLON OUTCAST (DJ MIX).MP3"
"Wisdom - Beautiful Chillstep.mp3"
"Sizzlebird - Artist Mix.mp3"
"Yann Tiersen - Amelie Soundtrack.mp3"
"chillstep mix 2013 vol.3.mp3"
"Burning Snowflakes Mix.mp3"
"Parov Stelar - Daylight/"
"Parov Stelar - Coco/Disc 1/"
"Parov Stelar - Coco/Disc 2/"
"Seeed/"
"Salvation 2 Hour Best of Chillstep Mix.mp3"
"Lonely Nights Wonderful Chillstep Mix.mp3"
"Caribou - Swim (Full Album).mp3"
"Gorillaz Plastic Beach 2010/"
"Griechenland/Pendulum - Hold Your Colour/"
"Griechenland/Pendulum In Silico/"
"Pendulum - Immersion/"
"Aphex Twin - Selected Ambient Works 85-92.MP3"
"RJD2 - Deadringer (Full Album).MP3"
"SOLAR FIELDS - RANDOM FRIDAY (ALBUM) HQ.MP3"
"Deep Cuts/"
"Silent Shout/"
"Gorillaz/"
"Kosheen/(2002) resist/"
"Dub_Fx/Everythinks A Ripple/"
"Griechenland/B-Complex/"
)
for (( i=0; i < 1; i++ )); do
choose=${music[$(($RANDOM % ${#music[@]}))]}
#check if song is blocked
cat /scripts/alertBlock | grep "$choose" > /dev/null
if [[ $? == 0 ]]; then
#song is blocked
echo "$choose is blocked"
i=-1
fi
done
#write to file, so it can't be played the next given days
lines=`wc -l < /scripts/alertBlock`
#cut the last entry
tail -n $(($days - 1)) /scripts/alertBlock > /scripts/.temp
cat /scripts/.temp > /scripts/alertBlock
echo "$choose" >> /scripts/alertBlock
echo "$choose chosen and added to Block-List"
echo "waiting for Rhythmbox to start"
rhythmbox-client --no-present &
#ok=false
#while [[ $ok == false ]]; do
# rhythmbox-client --check-running
#
# if [[ $? == 0 ]]; then
# ok=true
# else
# ok=false
# fi
#done
sleep 10
echo $choose | grep '/$'
if [[ $? == 0 ]]; then
cd "/home/julian/Music/$choose"
echo "Clearing queue"
rhythmbox-client --clear-queue 2>&1
# To avoid adding pictures and such crap
rhythmbox-client --enqueue *.mp3
rhythmbox-client --enqueue *.wav
rhythmbox-client --enqueue *.ogg
rhythmbox-client --enqueue *.flac
sleep 2
rhythmbox-client --play
else
rhythmbox-client --no-start --play-uri="/home/julian/Music/$choose" 2>&1
fi
echo "Music player started. Have Fun!"
echo "**************************"
echo "* End ("`date +'%d.%m.%Y %H:%M'`") *"
echo "**************************"
기본적으로 스크립트는 모니터를 켜고 (완벽하게 작동) 음량을 조정 (완벽하게 작동)하고 노래를 선택하고 블록 목록에 추가 (완벽하게 작동)하고 리듬 박스를 시작합니다 (메쉬 ... 작동한다면 플레이 큐에 추가 및 사물 너무 작동합니다 ...)
이전 배포판 (12.10 ~ 13.10)에서 Rhythmbox가 시작 (추가 DISPLAY=:0.0 sudo -u julian
또는 시작 rhythmbox-client --no-present
)되었지만 이제는이 모든 것이 더 이상 작동하지 않습니다.
터미널에서 스크립트를 시작할 때 생성되는 로그 파일 :
***********************************
* Start (28.05.2014 07:56) as julian *
***********************************
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 31
Mono: Playback 14 [45%] [-25.50dB] [on]
Turning monitors on and waiting 5 seconds.
RJD2 - Deadringer (Full Album).MP3 chosen and added to Block-List
waiting for Rhythmbox to start
Musicplayer startetd. Have Fun!
**************************
* End (28.05.2014 07:56) *
**************************
리듬 박스가 시작되고 재생됩니다.
crontab에서 시작 :
***********************************
* Start (28.05.2014 06:50) as julian *
***********************************
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 31
Mono: Playback 14 [45%] [-25.50dB] [on]
Turning monitors on and waiting 5 seconds.
Purity Ring's Shrines.MP3 chosen and added to Block-List
waiting for Rhythmbox to start
(rhythmbox-client:5655): GLib-GIO-CRITICAL **: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
Musicplayer startetd. Have Fun!
**************************
* End (28.05.2014 06:50) *
**************************
여기에 오류 메시지가 표시되지만 제거하는 방법을 모르겠습니다.
어떤 도움을 주시면 감사하겠습니다.
편집 : 한 단계 더 깊이 들어가기 : 두 가지 흥미로운 질문이 있습니다.
리듬 박스가 시작되면 다음 두 가지 가능성이 있습니다. 1. 자체 인스턴스에서 실행되므로 표시 rhythmbox-client
되지 않습니다. 2. 캡슐화 된 lightdm / unity 인스턴스에서 실행되므로 키보드의 핫키가 작동하지 않고 닫히면 음악이 재생되지만 killall rhythmbox
어떤 식 으로든 unity를 통해 Rhythmbox를 시작하기 때문에 이를 죽여야합니다 (빠른 -오디오 패널에서도 액세스) 두 번째 인스턴스를 만듭니다.
나는 지금 추측하고 있지만 crontab이 실제로 설정된 사용자의 이름이 아닌 그의 작업을 수행하기 때문에 마지막 두 가지 점이 발생한다고 생각합니다.
어떤 도움이라도 대단히 감사하겠습니다.
편집 2014-06-16 : 더 많은 정보를 가져 오려면 : 14.04에서 그래픽 인터페이스를 시작할 수도없는 것 같습니다.
11 8 * * * gnome-terminal
11 8 * * * DISPLAY=:0.0 gnome-terminal
위의 어느 것도 작동하지 않습니다. 나는 13.04와 13.10에서 이것이 효과가 있다고 확신합니다 ... 그래서 여전히 조사 중입니다 ...
이제이 문제를 해결하기 위해 완전히 다른 방법을 선택했습니다.
스크립트는 이제 crontab의 명령이 접근 할 때까지 fifo 파일로 기다렸다가 작동을 시작합니다. 그 때문에 시작시 스크립트를 시작하고 crontab이 그렇게하도록 지시 할 때 작동하도록 할 수 있습니다. 이제 디스플레이 관리자는 다음과 같이 보이는 crontab이 아닌 스크립트를 시작합니다.
#start alert
50 8 * * 1 echo "start;`whoami`;'`date`'" > /scripts/alert/com_fifo #mo
30 7 * * 2 echo "start;`whoami`;'`date`'" > /scripts/alert/com_fifo #di
...
죄송하지만 일부 기능을 재사용 할 수 있도록 여러 파일로 분할되어 스크립트 게시가 거의 불가능합니다. 기본적으로 다음과 같습니다.
hellNotFrozen=true
com="/scripts/alert/com_fifo"
#clear fifo file
rm $com >/dev/null 2>&1
mkfifo $com
while [[ $hellNotFrozen ]]; do
#read fifo-file - this statement is blocking!
inp=`cat $com` #$inp now holds the text pasted into the com-file
#...do other stuff here
rhythmbox-client --enqueue "/data/Music/$chosenFolder/*"
rhythmbox-client --play
done
모든 답변에 감사드립니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다