mv Artist.mp3 ring.mp3这么简单 。
下面需要解决的就是修改时机和随即性两个问题 。我这里显然是一个在后台不断循
环运行的Shell脚本,当短信息或者来电时,系统会启动alterprocss这个进程,这个脚
本自然能检测的这个进程相关信息,并修改相应的铃声文件 。至于随机性,其实来电本
身就是随机事件,这里只用了一个伪随即方法,即根据来电的时间信息,进行铃声文件
选择 。
三、脚本文件全内容
001#!/bin/bash
002
003
004#当前路径
005Path_Current=/mmc/mmca1/soft/ring
006
007#日志文件
008File_Log=$Path_Current/log.txt
009
010#来电铃声目录
011if [ ! -f $Path_Current/ring.txt ]
012then
013echo /mmc/mmca1/Music/Game > $Path_Current/ring.txt
014fi
015Path_Ring=`cat $Path_Current/ring.txt`
016
017#短信息铃声目录
018if [ ! -f $Path_Current/msg.txt ]
019then
020echo /mmc/mmca1/Music/Game > $Path_Current/msg.txt
021fi
022Path_Message=`cat $Path_Current/msg.txt`
023
024#固定来电消息文件目录
025if [ ! -f $Path_Current/default.txt ]
026then
027echo /mmc/mmca1/Music/Ring > $Path_Current/default.txt
028IsReset=1
029else
030IsReset=0
031fi
032Path_Default=`cat $Path_Current/default.txt`
033
034
035#系统预定义短信最长秒
036if [ ! -f $Path_Current/maxmessage.txt ]
037then
038echo "15" > $Path_Current/maxmessage.txt
039fi
040Var_MsgMaxSec $Path_Current/maxmessage.txt`
041
042#指定的短消息铃声
043Default_MessageFile=$Path_Default/message.mp3
044#指定的电话铃声
045Default_RingFile=$Path_Default/ring.mp3
046
047
048#指令集
049File_Busybox=/mmc/mmca1/tmp/busybox
050#临时处理配置的文件
051File_Sed=$Path_Current/tmpsed.txt
052#临时文件大声
053File_TmpRingLoud=$Path_Current/tmpRingLoud.pts
054#临时文件轻声
055File_TmpRingSoft=$Path_Current/tmpRingSoft.pts
056
057#临时进程文件
058File_TmpProcess=$Path_Current/tmpgrep.txt
059
060
061#临时可供随机的文件列表
062FileList_Tmp=filelist.txt
063
064#系统大声的配置文件
065File_RingLoud=/ezxlocal/download/appwrite/setup/RingLoud.pts
066#系统轻声的配置文件
067File_RingSoft=/ezxlocal/download/appwrite/setup/RingSoft.pts
068
069
070echo "====== Random Ring ======" >> $File_Log
071echo `$File_Busybox date` " : Start" >> $File_Log
072
073
074if [ "$IsReset" = "1" ]
075then
076
077echo `$File_Busybox date` " : Create New PtsFile" >> $File_Log
078
079#生成新的配置文件
080echo "#!/bin/sed -f" > $File_Sed
081echo "/AlertRingTone1/ c" >> $File_Sed
082echo "AlertRingTone1 = $Default_RingFile" >> $File_Sed
083echo "/AlertRingTone2/ c" >> $File_Sed
084echo "AlertRingTone2 = $Default_RingFile" >> $File_Sed
085echo "/AlertTextMsg/ c" >> $File_Sed
086echo "AlertTextMsg = $Default_MessageFile" >> $File_Sed
087
088#echo $File_Sed " " $File_RingLoud
089$File_Sed $File_RingLoud > $File_TmpRingLoud
090$File_Sed $File_RingSoft > $File_TmpRingSoft
091
092cp -f $File_TmpRingLoud $File_RingLoud
093cp -f $File_TmpRingSoft $File_RingSoft
094
095fi
096
097#$File_Busybox renice -20 $$
098echo $$ > $Path_Current/proc.txt
099
100echo `$File_Busybox date` " : ProcessID " $$ >> $File_Log
101
102while
103
104do
105
106ProcID_Alert=`pidof alertprocess`
107
108if [ "$ProcID_Alert" = "" ]
109then
110
111echo "Runing ..."
112sleep 1s
113
114else
115
116echo `$File_Busybox date` " : AlertProcessID " $ProcID_Alert >> $File_Log
117
118ps -ef | grep ".mp3" | grep -v grep > $File_TmpProcess
119
120if grep "ring.mp3" $File_TmpProcess | grep -v grep
121then
122HaveSession="PHONE"
123echo `$File_Busybox date` " : Have Phone " >> $File_Log
124fi
125
126if grep "message.mp3" $File_TmpProcess | grep -v grep
推荐阅读
- 华为watch GT3系列外观怎么样?华为watch GT3系列外观介绍
- W579导通讯录的一点感受
- E680系列 Linux手机DIY.Shell应用扩展二.自动生成播放列表
- 曝红米note11/pro未搭载骁龙778g note10系列延续
- ryzen 6000系列处理器跑分曝光 基准测试超过英特尔GPU
- 苹果iPhone 15系列或引入USB 4技术:传输更快更稳
- E680g使用小体会
- 关于E6及E680系列手机的IP设置
- 曝小米12系列升级50MP三主摄:12月发布
- 黑莓72系列手机初使用之联机应用篇
