Shell script learning-eye protection programming experience

Source: Internet
Author: User
Tags clear screen

After I recently changed Ubuntu, I felt dizzy and eye bloat easily. Because I installed eye protection software on Windows, the screen lock will automatically prompt users to rest their eyes at regular intervals. Google hasn't found an eye-protection software that is easy to use in Linux for a long time, so I wrote a simple version using a script. I 'd like to share it with you.ProgramMembers can pay attention to their bodies. I hope you can give us some advice on program deficiencies.

 

Running environment: it is feasible to test in ubuntu10.04. xlockmore must be installed.

Function Description: The program can automatically lock the screen every n minutes (N can be set by the user) to remind the user to rest his eyes; the pop-up window appears M minutes before the screen lock. the user will be prompted M minutes later (M is set by the user). After the rest, the user enters the password to unlock the screen.


 

#! /Bin <br/> # The program can lock screen automatically to protect your eyes. <br/> # author <br/> # yalishizhude yalishizhude@gmail.com <br/> # History <br/> #2011-10-5 Ver: 1 <br/> # copyright preserved ^-^ <br/> clear <br/> echo "welcome to use closeyoureyes (Beta) "<br/> echo" -- the program can remind you rest eyes every n minutes (N set by you) on rest/N "<br/> Read-P" How often do you want to have a rest? (Default: 50 min) "interval <br/> # Set Default interval time <br/> test-Z $ interval & interval = 50 <br/> echo" interval time: "$ interval <br/> # Set Default rest time <br/> Read-P" How many minute (s) Do you want to be informed in advance? (Default: 1 min) "advance <br/> test-Z $ advance & Advance = 1 <br/> echo" advance time: "$ advance <br/> Inform =$ ($ interval-$ advance); <br/> Read-P" are you sure the settings? (Y/n) (default: Y) "setting <br/> test-Z $ setting & setting =" Y "<br/> 

CodeNote: After the clear screen is displayed, you are prompted to set the rest interval (n minutes) and advance rest reminder (M minutes). If the test check input is empty, the default value is set. After the user determines the settings, use the while statement to start the countdown loop. Then sleep for n-M minutes, run the xterm command to bring up the prompt window. After n minutes, the xlock screen is locked.

Note:

1. Be sure to install the xlockmore software. If you don't know how to install it, Google or xlock will prompt you.

2. Be sure to pay attention to the spaces on both sides of []. It has been shown for a long time since not command did not pay attention to this problem. Therefore, you should pay attention to the details when doing things.


Related Article

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.