Shell脚本
#!/bin/bash
i=0
if [ "$1"!="" ]; then
t=25*60
else
t=5*60
fi
while ((i < t))
do
sleep 1
((i+=1))
m=$(((t-i)/60))
s=$((t-m*60-i))
echo -en "$m:$s \r"
done
if [ "$1"!="" ]; then
notify-send "喝口水吧!"
else
notify-send "开始干活了!"
fi
Bat脚本
@echo off
set /p flag=是否开始干活(y/n)?:
if %flag%=="y" (
set /a t = 25*60
) else (
if %flag%=="n" (
set /a t = 5*60
) else (
msg * "输入格式错误"
exit
)
)
timeout /t %t% /nobreak
if %flag%=="y" (
msg * /time:5 "休息一下!"
) else (
if %flag%=="n" (
msg * "开始干活!"
)
)