国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

自制Linux終端鎖屏工具

2024-09-01 13:48:03
字體:
來源:轉載
供稿:網(wǎng)友

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

準備
 •操作系統(tǒng) : 我這里是ElementaryOS虛擬機 + XShell 遠程登錄工具
 •Shell語言 : 我使用的是默認的Bash Shell
 •其他小工具 : 
        ?fortune:系統(tǒng)隨機的從語庫中選出一句英文成語。
        ?cowsay : 在終端界面上顯示出一個奶牛的語句框,配合管道連接上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 $inforead mypasswordecho "Screen will locked in 7 seconds!"sleep 7clear#!/bin/bash#scriptname:locktty#writed by :javalee#script start...reset;clear #清除屏幕info="Please input the password you will use later!"cowsay $inforead mypasswordecho "Screen will locked in 7 seconds!"sleep 7clear#加上這個倒記時的小東東,;)trapper () { #建立個函數(shù)trap ' ' 2 3 20 #忽略CTRL+C CTRL+/ CTRL+Z信號}while : #進入死循環(huán)dotrapper #調用函數(shù)printf "/n/n/n/n/n/n/n/n/t/t/tPlease enter unlock code:" | cowsaystty -echo  #屏蔽輸入的字符read inputcase $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 3clearcontinue ;;  #否則,繼續(xù)循環(huán)esacdone

運行演示

程序運行開始:

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í)行過程中的動態(tài)效果,所以直接看解鎖界面吧
當我們輸入不正確的密碼的時候,系統(tǒng)會提示輸入錯誤,以及一個幽默的“警告”

 ___________________________
/                           /
/ 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 |
                ||     ||

當我們密碼輸入正確的時候,如下:

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

結語

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


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 洛川县| 中方县| 铁力市| 靖宇县| 白山市| 竹北市| 肇源县| 柳河县| 巢湖市| 上饶市| 黎川县| 乌鲁木齐县| 吴堡县| 年辖:市辖区| 托克逊县| 马龙县| 蒙阴县| 图片| 凤台县| 布尔津县| 泸水县| 嫩江县| 南溪县| 定兴县| 大庆市| 夏邑县| 博湖县| 二手房| 全椒县| 灵宝市| 武穴市| 明光市| 鸡泽县| 法库县| 锡林浩特市| 万州区| 综艺| 平湖市| 天津市| 屏东市| 衡阳市|