Linux rest remind

  Today, half of the work, small group suddenly talking about a certain star in the recording "chase me" sudden and unexpected died. This allows everyone raged, but also reflect on their own work when I need to pay attention to rest. Looking for a lap later found a small break on the debian software called: workrave, used after download and install the effect is not very good. Think of itself crontab and notify-send tool, why not write your own it under linux. Having started Here is the code:

#!/usr/bin/bash
#-*- coding: utf-8 -*-  

while :
do
    hour=$(date +%H)
    not1="现在时间:"

    minute=$(date +%M)
    gap=`expr 60 - $minute`
    gaps=`expr $gap \* 60`
    # echo $gap $gaps

    sleep $gaps

    if [ $hour -gt 18 -a $hour -lt 23 ]; then
        sign="晚上好!"
        notify-send ["开心一下"] "$sign $not1 $(date +%H:%M:%S)"
    elif [ $hour -eq 18 ]; then
        sign="傍晚好!"
    elif [ $hour -gt 12 -a $hour -lt 18 ]; then
        sign="下午好!"
        notify-send ["开心一下"] "$sign $not1 $(date +%H:%M:%S)"
    elif [ $hour -eq 12 ]; then
        sign="中午好!"
    elif [ $hour -gt 8 -a $hour -lt 12 ]; then
        sign="早上好!"
        notify-send ["开心一下"] "$sign $not1 $(date +%H:%M:%S)"
    else
        sign="休息时间!"
    fi
done

  Function is probably to remind once every hour, so this time we can drink water, the toilet or stand up and stroll.
  Finally, say, the body is their own, not too overdraft!

Guess you like

Origin www.cnblogs.com/randomcoder/p/11948960.html