|
天天坐在电脑前的朋友要每隔一段时间活动一下了,不然身体会变得越来越差。下面的shell脚本可以每隔一段时间来提醒你。
#!/bin/bash
# Usage: ./break.sh mins 2>1 1>/dev/null
function time_stop
{
n=1
while ((n<60))
do
sleep ${min}
((n+=1))
done
}
min=$1
while true
do
time_stop
info="$USERNAME\n ${min} minutes have past\nYou need to take a break!\n为了健康,休息一下,活动一下胳膊,脖子,腰部"
note="info"
Xdialog --title $note --beep --msgbox "${info}" 15 50
Xdialog --title $note --beep --inputbox "休息一下吧!\n Take a break[y/n]?" 10 30 2>tmp$$
input=`cat "tmp$$"|sed -n '$p'`
case ${input} in
e) break;;
y) continue;;
n) gnome-screensaver-command -l; continue;;
*) Xdialog --title $note --no-buttons --infobox "invalidate input!" 4 20;continue;;
esac
done
rm tmp$$
使用方法:
首先将上述代码保存为break.sh ,然后在SHELL终端中找到该文件所在处,然后输入./break.sh 30 2>1 1>/dev/null &
其中的“红色30”可以改为你想要被提醒的时间,这样每到30分钟,系统就会提醒你该休息放松一下啦!
[ 本帖最后由 star2523 于 2010-4-28 23:35 编辑 ] |
|