我写了有关时间表提醒的脚本,希望我能播放以前选择的音频。我的意思是在我的程序中variabel 听起来正在使用.mp3查找文件,但是它不起作用。
请帮帮我。
谢谢
nama=$(zenity --entry --text="Enter your name:" --entry-text " ");
date=$(zenity --calendar --text "choose your event's day" --date-format=%Y-%m-%d);
tang=$(zenity --forms --date-format=`date | awk ¥{print $1 $3,$2,$6}¦ `| time :`date | awk '{print $4}'` );
nambah=$(zenity --forms --ok-label="Done" --cancel-label="Cancel" --height=100 \
--title "Time" \
--text "Input Time(format 24)" \
--add-entry "Input Hours:Minutes:Second");
sounds=$(find | *.mp3 | zenity --list --column "choose sounds");
text=$(zenity --text-info --title "create event" --editable --font=Purisa);
a=1
while (a==1)
do
cekdate="`date '+%Y-%m-%d'`";
cektime="`date '+%H:%M:%S'`";
echo "echo cektime: $cektime"
echo "echo cekdate: $cekdate"
echo "nambah: $nambah"
echo "date: $date"
if [ "$nambah" == "$cektime" -a "$date" == "$cekdate" ]
then
echo -n
d=`echo "Time: $nambah"`
break
fi
done
out=$(zenity --info --text "REMEMBER!! $nama today is $date you have event $d
$text ");
最佳答案
您需要在2个地方进行代码更改:
find
的方式:sounds=$(find <path_to_mp3_directory> -type f -name "*.mp3" | zenity --list --column "choose sounds")
^^^^^^^^^^^^^^^^^^^^^^#this must be edited to your needs
#play your music with your favorite player : mplayer, ffplay, nvlc, play (sox) or mpg123 (if you do not have the tools: sudo apt-get install mpg123/you favorite mp3 player)
mplayer $sounds #mpg123 $sounds
您的代码成为:
nama=$(zenity --entry --text="Enter your name:" --entry-text " ")
date=$(zenity --calendar --text "choose your event's day" --date-format=%Y-%m-%d)
tang=$(zenity --forms --date-format=`date | awk \{print $1 $3,$2,$6}| `| time :`date | awk '{print $4}'` )
nambah=$(zenity --forms --ok-label="Done" --cancel-label="Cancel" --height=100 \
--title "Time" \
--text "Input Time(format 24)" \
--add-entry "Input Hours:Minutes:Second");
sounds=$(find <path_to_mp3_directory> -type f -name "*.mp3" | zenity --list --column "choose sounds")
text=$(zenity --text-info --title "create event" --editable --font=Purisa)
a=1
while (a==1)
do
cekdate="`date '+%Y-%m-%d'`"
cektime="`date '+%H:%M:%S'`"
echo "echo cektime: $cektime"
echo "echo cekdate: $cekdate"
echo "nambah: $nambah"
echo "date: $date"
if [ "$nambah" == "$cektime" -a "$date" == "$cekdate" ]
then
echo -n
d=`echo "Time: $nambah"`
break
fi
done
out=$(zenity --info --text "REMEMBER!! $nama today is $date you have event $d
$text ")
#play your music with your favorite player : mplayer, ffplay, nvlc, play (sox) or mpg123 (if you do not have the tools: sudo apt-get install mpg123/you favorite mp3 player)
mplayer $sounds # or mpg123 $sounds, etc.
关于bash - 如何使用zenity查找.mp3文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47934235/