欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

自制Linux終端鎖屏工具

 更新時(shí)間:2016年08月08日 16:14:38   作者:Marksinoberg  
這篇文章主要為大家詳細(xì)介紹了如何自制Linux終端鎖屏工具,具有一定的實(shí)用性,感興趣的小伙伴們可以參考一下

很多時(shí)候我們不能一直守護(hù)在自己的電腦旁邊,而且有些文件并不想讓別人知道。那么這時(shí)候來個(gè)鎖屏,是再合適不過的了。今天分享一個(gè)自制的鎖屏工具,如下。

準(zhǔn)備
 •操作系統(tǒng) : 我這里是ElementaryOS虛擬機(jī) + XShell 遠(yuǎn)程登錄工具
 •Shell語言 : 我使用的是默認(rèn)的Bash Shell
 •其他小工具 : 
        ◦fortune:系統(tǒng)隨機(jī)的從語庫(kù)中選出一句英文成語。
        ◦cowsay : 在終端界面上顯示出一個(gè)奶牛的語句框,配合管道連接上fortune,效果完美!

 代碼

#!/bin/bash
#scriptname:locktty
#writed by :Marksinoberg
#description : just for protecting our message when we leave away. And we can set the password every time.

reset;clear #清除屏幕
info="Please input the password you will use later!"
cowsay $info
read mypassword
echo "Screen will locked in 7 seconds!"
sleep 7
clear
#!/bin/bash
#scriptname:locktty
#writed by :javalee
#script start...
reset;clear #清除屏幕
info="Please input the password you will use later!"
cowsay $info
read mypassword
echo "Screen will locked in 7 seconds!"
sleep 7
clear
#加上這個(gè)倒記時(shí)的小東東,;)

trapper () { #建立個(gè)函數(shù)
trap ' ' 2 3 20 #忽略CTRL+C CTRL+\ CTRL+Z信號(hào)
}
while : #進(jìn)入死循環(huán)
do
trapper #調(diào)用函數(shù)
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,Today is $(date +%T)\n"
stty echo  
break ;;  #輸入正確,挑出循環(huán)回到命令行
*)echo "Do not check my files,please! See as follows:"
sleep 3
clear
continue ;;  #否則,繼續(xù)循環(huán)
esac
done

運(yùn)行演示

程序運(yùn)行開始:

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


 ______________________________________
/ Please input the password you        \
\     will use later!                  /
 --------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
123
Screen will locked in 7 seconds!

由于靜態(tài)文本沒辦法顯示程序執(zhí)行過程中的動(dòng)態(tài)效果,所以直接看解鎖界面吧
當(dāng)我們輸入不正確的密碼的時(shí)候,系統(tǒng)會(huì)提示輸入錯(cuò)誤,以及一個(gè)幽默的“警告”

 ___________________________
/                           \
\ Please enter unlock code: /
 ---------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
Do not check my files,please! See as follows:
 _________________________________________
/ Q: Why is it that the more accuracy you \
| demand from an interpolation            |
|                                         |
| function, the more expensive it becomes |
| to compute? A: That's the Law of Spline |
\ Demand.                                 /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

當(dāng)我們密碼輸入正確的時(shí)候,如下:

 ___________________________
/                           \
\ Please enter unlock code: /
 ---------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
         Hello mark,Today is 06:35:05

結(jié)語

代碼還是很簡(jiǎn)單的,僅僅用到了shell腳本語法的幾個(gè)小命令。希望我這個(gè)腳本能拋磚引玉,打開你的思路,做出更好的鎖屏小腳本!

相關(guān)文章

最新評(píng)論