cmus와 인터페이스하는 쉘 스크립트를 작성하고 notify-send를 사용하여 트랙 정보를 알려줍니다. 지금은 작동하지 않습니다. 주로 xargs가 notify-send에 2 개의 인수를 전달하지 않기 때문입니다. 그것은 단지 하나를 보내고 나는 이유를 알 수 없습니다. 올바른 출력을 얻기 위해 sed로 생각할 수있는 모든 작업을 수행했지만 작동하지 않습니다. 또한 두 개의 인수와 함께 notify-send를 사용하면 작동하므로 notify-send에 문제가 없다고 생각합니다.
cmus-remote -Q의 출력은 다음과 같습니다.
status paused
file /home/dennis/music/Coheed And Cambria/GOODAP~1/05 Crossing the Frame.mp3
duration 207
position 120
tag artist Coheed & Cambria
tag album Good Apollo I'm Burning Star IV Volume One: From Fear Through the Eyes of Madness
tag title Crossing the Frame
tag date 2005
tag genre Rock
tag tracknumber 5
tag albumartist Coheed & Cambria
set aaa_mode all
set continue true
set play_library true
set play_sorted false
set replaygain disabled
set replaygain_limit true
set replaygain_preamp 6.000000
set repeat false
set repeat_current false
set shuffle true
set softvol false
set vol_left 100
set vol_right 100
내 코드는 끔찍합니다. 셸 스크립팅을 배우기 시작했습니다. 정말 죄송합니다.
#!/bin/sh
#
# notify of song playing
info="$(cmus-remote -Q)"
title="`echo "$info" | grep 'tag title' | sed "s/'//g" | sed 's/tag title \(.*\)/'\''\1'\''/g'`"
artist="`echo "$info" | grep 'tag artist' | sed "s/'//g" | sed 's/tag artist \(.*\)/ '\''\1/g'`"
album="`echo "$info" | grep 'tag album ' | sed "s/'//g" | sed 's/tag album \(.*\)/ \1'\''/g'`"
stupid="${title}${artist}$album"
echo "$stupid" | xargs notify-send
xargs
의도 한대로 작동합니다. 각 행은 매개 변수로 사용됩니다. 여러 매개 변수를 원하는 경우 개행 문자로 구분하십시오.
{echo "$title"; echo "$artist"; echo "$album"} | xargs notify-send
즉, 매우 간단한 작업을 너무 많이하고 있습니다.
title="$(echo "$info" | sed -n 's/^tag title //p')"
artist="$(echo "$info" | sed -n 's/^tag artist //p')"
album="$(echo "$info" | sed -n 's/^tag album //p')"
notify-send "$title" "$artist" "$album"
(또 다른 하나 개 잡았다주의 notify-osd
는 Pango가 마크 업 오인 될 수있는 아무것도 탈출 할 필요가 있으므로,이 Pango가를 통해 전달되는 메시지를 보내는이 수단을. <
, >
그리고 &
많은 HTML 및 XML과 마찬가지로, 실제로 위의 시도하지 않습니다. 이것을 처리하기 위해.)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다