Skip to content

Instantly share code, notes, and snippets.

@forthxu
Created January 7, 2015 15:57
Show Gist options
  • Save forthxu/8217a5540336e08bf277 to your computer and use it in GitHub Desktop.
Save forthxu/8217a5540336e08bf277 to your computer and use it in GitHub Desktop.
播放一首音乐然后 叫你起床 连续三遍 都是随机的
#!/bin/bash
#叫床声可以去www.nsjnqc.com找或百度
files_dir='/workspace/work/other/zaoan/';
musics_dir='/workspace/work/other/mp3/';
i=0;
j=0;
files=();
musics=();
for file in $(ls ${files_dir});do
files[$i]=$file;
let "i+=1";
done
for file in $(ls ${musics_dir});do
musics[$j]=$file;
let "j+=1";
done
files_length=${#files[@]};
musics_length=${#musics[@]};
#for ((i=0; i<$files_length; i++));do
# echo ${files[$i]}
#done
#for ((i=0; i<$musics_length; i++));do
# echo ${musics[$i]}
#done
for ((i=0; i<3; i++));do
x=`expr $RANDOM % $musics_length`;
#echo $x;
mplayer ${musics_dir}${musics[$x]};
sleep 5s;
y=`expr $RANDOM % $files_length`;
#echo $y;
mplayer ${files_dir}${files[$x]};
sleep 1m;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment