Self-made Linux Terminal lock screen tool _linux

Source: Internet
Author: User
Tags sleep

Most of the time we can't always be around our computers, and some files don't want anyone to know. So this time to a lock screen, is more appropriate. Today share a homemade lock screen tool, as follows.

Get ready
• Operating system: I am here Elementaryos virtual machine + Xshell Remote Login tool
Shell language: I'm using the default bash Shell
• Other gadgets:
◦fortune: The system randomly selects an English idiom from the library.
◦cowsay: in the terminal interface shows a cow statement box, with the pipe connection on the fortune, the effect is perfect!

Code

#!/bin/bash #scriptname: Locktty #writed By:marksinoberg #description: Just for protecting my message when we leave AWA

Y. And we can set the password every time. Reset;clear #清除屏幕 info= "Please input the password you'll use later!" Cowsay $info read mypassword echo "screen'll lock Ed in 7 seconds! ' sleep 7 clear #!/bin/bash #scriptname: Locktty #writed by:javalee #script start ... reset;clear #清除屏幕 inf o= "Please input the password you'll use later!" Cowsay $info read mypassword echo "screen'll locked in 7 seconds!" SLE EP 7 clear #加上这个倒记时的小东东,;) trapper () {#建立个函数 trap ' 2 3 #忽略CTRL +c ctrl+\ ctrl+z Signal} while: #进入死循环 do trapper #调用函 Number printf "\n\n\n\n\n\n\n\n\t\t\tplease Enter unlock code:" | Cowsay stty-echo #屏蔽输入的字符 Read input case $input in $mypassword) printf "\t\t Hello $USER, * is $ (date +%t) \ n" Stty E  Cho break;; #输入正确, pick out loops back to command line *) echo ' Do not check my files,please!  Follows: "Sleep 3 clear continue;;

 #否则, continue the cycle Esac done

Run Demo

Program Run Start:

mark@mark:~/temp/myscripts$ ./lockscreen.sh


______________________________________
/Please input the password
\ would use later! /
--------------------------------------
\   ^__^
\ (oo) \_______
(__)\       )\/\
|| ----W |
|| ||
123
Screen'll locked in 7 seconds!

Because static text is not able to display the dynamic effect of program execution, so see the unlock interface directly
When we enter an incorrect password, the system prompts for an error and a humorous "warning"

___________________________
/                           \
\ Please enter unlock code:/
---------------------------
\   ^__^
\ (oo) \_______
(__)\       )\/\
|| ----W |
|| ||
Don't check my files,please! as follows:
_________________________________________
/q:why is it this more accuracy
| Demand from a interpolation |
| |
| function, the more expensive it becomes |
| To compute? A:That ' s The Spline |
\ Demand. /
-----------------------------------------
\   ^__^
\ (oo) \_______
(__)\       )\/\
|| ----W |
|| ||

When we enter the correct password, the following:

___________________________
/                           \
\ Please enter unlock code:/
---------------------------
\   ^__^
\ (oo) \_______
(__)\       )\/\
|| ----W |
|| ||
Hello Mark,today is 06:35:05

Conclusion

The code is simple enough to use just a few small commands for the syntax of the shell script. I hope this script can be a good idea, open your mind, make a better lock screen small script!

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.