bash - 如何使用zenity查找.mp3文件

标签 bash shell audio find mp3

我写了有关时间表提醒的脚本,希望我能播放以前选择的音频。我的意思是在我的程序中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个地方进行代码更改:

  • 更改对mp3文件进行find的方式:
    sounds=$(find <path_to_mp3_directory> -type f -name "*.mp3" | zenity --list --column "choose sounds")
                   ^^^^^^^^^^^^^^^^^^^^^^#this must be edited to your needs
    
  • 在代码末尾调用您喜欢的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
    

  • 您的代码成为:
    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/

    相关文章:

    string - Bash:从字符串中提取(百分比)可变长度数

    shell - 如何从命令输出中获取第二列?

    audio - 在单个 WAV 文件中存储具有不同编码/采样的多个 channel

    java - 循环录音

    windows - Windows 10:使用2个麦克风而不混合输入

    linux - Grep 过滤器不会在第一次匹配时停止

    regex - 无法将否定先行断言应用于 bash 上的 nagios 插件输出

    xml - 使用脚本将文本文件转换为 xml

    shell - root 用户不在远程机器的 shell 脚本中执行命令

    python - 从 python 脚本获取当前 shell 类型