A reminder script to implement the Timer window in Ubuntu _linux

Source: Internet
Author: User

Simple Bullet Window Effect

First of all, the Internet to check the window in Ubuntu command, found notify-send that the command can meet the requirements

Notify-send ["It's time to rest"] "Drink!" Yawn Move It! "

Window effect

The window effect has, then should be a timer window function

A, cron command to realize the timing of the bomb window

Think of is the cron command, Google a lot of tutorials, no success

Joined in the/etc/crontab.

* * * * * root notify-send ["It's time to rest"] "Drink!" Yawn Move It! "

Also edited with a command.

Crontab-e

The cron service is also started

Server cron Start

It's still not successful.

Finally in an introduction crontab usage blog finally found my crontab script does not execute reason: not set environment variable!

When you define multiple scheduling tasks in a crontab file, you need to specifically set the environment variable, because when we perform a task manually, it is in the current shell environment, and the program can certainly find the environment variable, and the system does not load any environment variables when it performs task scheduling automatically, so You need to specify all the environment variables required for the task to run in the crontab file

Crontab Script

home=/Shell=/bin/bash 0 * * * * * *
notify-send ["Time to Rest"] "Drink!" Yawn Move It! "

That's how it's done.

Second, the Shell script infinite loop implementation

Here's the script:

While:
 do-Sleep 3600 echo-
 time past Notify-send ["Take A Break"] "Drink!" Yawn Move It! "Done

Add this script to the home directory .bashrc , and it starts every time you log in.

Iii. using zenity and notify-send to realize

#!/bin/bash
alarttime=100
while (($alartTime)) do if (
($alartTime!= 100)) # If not 100, it is not a first run, Then pop-up the following prompts
then
notify-send $alartTime "Minutes have arrived, please reset!" "
zenity--info--text" time, please reset! "
fi
alarttime=$ (zenity--entry--title" timed Reminder "--text" Enter reminder time (minutes, will ignore decimal) ")
alarttime=${alarttime%.*} # Ignores numbers after the decimal point entered, such as 4.6 recognized as 4
if (($alartTime > 60) # cannot exceed maximum
then
zenity--info--text "must be less than 60 minutes to exit" 
   
    break
fi
notify-send "successfully set the" $alartTime "minutes, start timing" sleep
$ (alarttime*60))
done
   

The above script uses the notify-send command to pop bubbles on the desktop and uses the zenity command to display the graphics window.
With your own words, the script above can be written a little simpler because error detection is not necessary. But if you want to use it for people who don't understand it, the error detection and processing in my script will be a bit too much.

Summarize

Well, finally completed the Ubuntu pop-up reminder script, this article provides three methods for reference, do not know that we have learned not to hope that the content of this article can be helpful to everyone, if you have questions you can message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.