免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2525 | 回复: 3
打印 上一主题 下一主题

在家。无聊 发个mplayer bash [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-07-09 10:12 |只看该作者 |倒序浏览
本帖最后由 initrdimg 于 2011-07-09 10:31 编辑

#!/bin/bash
# 作者:罗红江
#原转,转载,请说明出处
#个人博客:http://edsl.8800.org【网通】
#个人技术水平有限。望指教。
function init()
{
if [ -e ~./mplayer_list ];then
touch ~/.mplayer_list
else
touch ~/.mplayer_list
fi
}

function p_list()
{
URL=`cat ~/.mplayer_list|xargs zenity --width=400 --height=600 --list --column="list" --hide-header --text="" "清空列表" `  #读取文件

case $URL in
"清空列表"
echo "">~/.mplayer_list
menu
;;
""
menu
;;
*)
play "$URL" 1
;;
esac

}

function play()
{
##############################加路径############################################
fgrep -w "$1"  ~/.mplayer_list   #去重复列表
if (( $?>0 ));then
       if [ -z "$1"  ];then                #是否为空路径
           menu
       elif (( $2 == 2));then
           #echo -e '"'"$1"'"'>>~/.mplayer_list #加路径到文件里
               zenity --warning  --text="无法同时加载多个文件到播放列表"
       else
            echo -e "'""$1""'">>~/.mplayer_list #加路径到文件里
       fi
      
fi
#########################################################################

ps -A|grep mplayer
   if (($?<1 ));then
      pkill -9 mplayer
   fi
if (( $2 == 2 ));then
     mplayer -framedrop $1 &
      p_list
else      
     
mplayer -framedrop "$1" &
          p_list
fi



}

function menu()
{

action=`zenity --width=400 --height=350 --list --column="Movie" --hide-header --text="" "手动输入文件" "打开单个文件" "打开多个文件" "播放列表" "退出" `

case ${action} in

"手动输入文件" )
URL=`zenity --width=400 --height=200 --entry --text="输入文件路径及名字"`
play "$URL" 1
;;

"打开单个文件" )
URL=`zenity --file-selection  --separator=" "  `
play "$URL" 1
;;
"打开多个文件" )
URL=`zenity --file-selection  --separator=" " --multiple `
play "$URL" 2
;;
"播放列表"
p_list
;;
"退出"
pkill -9 mplayer
exit
;;
esac
}

init
menu




--------------------------------------这是一个小游戏------------------------------------------------------------------------------
init()
{
clear
declare -x a b c d money chang change time first=0 two=0 three=0 four=0
black='\E[30;47m'
red='\E[31;400m'
green='\E[32;400m'
yellow='\E[33;400m'
blue='\E[34;400m'
magenta='\E[35;400m'
cyan='\E[36;400m'
white='\E[37;400m'
reset=`tput sgr 0`
house=",~(Y)Q>"
sum=100
start1=0
rand=0
sleep 1
a=1
b=2
c=3
d=4
win1=0
win2=0
win3=0
win4=0
money=1000
clear
input
}

input()
{
echo you have MONEY:'$'$money
first=0
two=0
three=0
four=0
read -p "input money:" change
if (($change > $money));then
echo "YOU not enough money!"
input
fi
read -p "input choice house[1,2,3,4]:" chang
if (($chang > 0 && $chang <=4));then
:
else
echo "Not have you choice NO.!"
input
fi

clear

tput cup 1 0 ;echo "=============================================================================================================================="
tput cup 3 0 ;echo "=============================================================================================================================="
tput cup 5 0 ;echo "=============================================================================================================================="
tput cup 7 0 ;echo "=============================================================================================================================="
tput cup 9 0 ;echo "=============================================================================================================================="
tput cup 12 24 ;echo -e "=======you moneymoney=========NO.1:<$white$first$reset>===NO.2:<$red$two$reset>===NO.3:<$blue$three$reset>===NO.4:<$cyan$four$reset>========"
tput cup 2 0 ;echo ">"
tput cup 4 0 ;echo ">"
tput cup 6 0 ;echo ">"
tput cup 8 0 ;echo ">"
time=0
sleep 1
start
}

drew1()
{
((win1=$win1+$1))
tput cup 2 $win1
echo -e -n $white $house;tput sgr0
sleep 0.3
first=$win1
if (( $win1 >= 100 ));then
time=100
win1=0
win2=0
win3=0
win4=0
start $win1 $a
fi
}

drew2()
{
((win2=$win2+$1))
tput cup 4 $win2
echo -n -e $red $house;tput sgr0
sleep 0.3
two=$win2
if (( $win2 >= 100 ));then
time=100
win1=0
win2=0
win3=0
win4=0
start $win2 $b
fi
start
}

drew3()
{
((win3=$win3+$1))
tput cup 6 $win3
echo -n -e $blue $house;tput sgr0
sleep 0.3
three=$win3
if (( $win3 >= 100 ));then
time=100
win1=0
win2=0
win3=0
win4=0
start $win3 $c
fi
}

drew4()
{
((win4=$win4+$1))
tput cup 8 $win4
echo -n $house
sleep 0.3
four=$win4
if (( $win4 >= 100 ));then
time=100
win1=0
win2=0
win3=0
win4=0
start $win4 $d
fi
}

start()
{
times=$1
winer=$2
while true
do
if (( $time >= 99 ))
then
break
fi
clear
tput cup 1 0 ;echo "============================================================================================================================== [ff]"
tput cup 3 0 ;echo "==============================================================================================================================[1]"
tput cup 5 0 ;echo -e "====================================================$green Time:<`date +%T`>$reset =========================================================[2]"
tput cup 7 0 ;echo "==============================================================================================================================[3]"
tput cup 9 0 ;echo "==============================================================================================================================[4]"
tput cup 12 20 ;echo -e "=======Have money$money-$change))$=========NO.1:<$white$first$reset>===NO.2:<$red$two$reset>===NO.3:<$blue$three$reset>===NO.4:<$cyan$four$reset>========"
rand1=$RANDOM
rand2=$RANDOM
((curent=$rand1 % 4 + 1))
((winerr=$rand2 % 10 + 1 ))
case $curent in
1)
drew1 $winerr
drew2 0
drew3 0
drew4 0
;;
2)
drew2 $winerr
drew1 0
drew3 0
drew4 0
;;
3)
drew3 $winerr
drew1 0
drew3 0
drew4 0
;;
4)
drew4 $winerr
drew2 0
drew3 0
drew1 0;;
esac
((i++))
done
over $winer
}

over()
{
if (( $money > 0));then
{ if [[ $chang == $1 ]];then
{
((money=$money + $change * 2 ))
clear
echo "WINER锛侊紒锛?moneychange" $1"ff" "you have $money "
sleep 3
input
}
else
{
((money=$money-$change))
clear
echo "you lose!" $change $1"ff" "you have $money"
sleep 3
if (( $money > 0 ));then
input
fi
}
fi
}
else
clear
dialog --pause "YOU LOSE" 10 30 3
bash main.sh
exit
fi
}
init

论坛徽章:
0
2 [报告]
发表于 2011-07-09 10:17 |只看该作者
支持一个!

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
3 [报告]
发表于 2011-07-09 12:40 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
4 [报告]
发表于 2011-07-10 11:41 |只看该作者
用代码段框起来嘛……看了格式就不想看了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP