如何使用zenity

时间:2017-12-21 23:49:31

标签: bash shell audio find mp3

我写了关于计划提醒的脚本,我希望我能播放我之前选择的音频。我的意思是我的程序变量 声音 用.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 ");

1 个答案:

答案 0 :(得分:1)

您有2个地方需要在代码中进行更改:

  1. 更改find mp3文件的方式:

    sounds=$(find <path_to_mp3_directory> -type f -name "*.mp3" | zenity --list --column "choose sounds")
                   ^^^^^^^^^^^^^^^^^^^^^^#this must be edited to your needs
    
  2. 在代码末尾调用您最喜欢的MP3播放器,如果需要,您需要事先安装它。检查平台上可用的内容并使用软件包管理器进行安装

    #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
    
  3. 您的代码变为:

    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.