服务器 
首页 > 服务器 > 浏览文章

自制Linux终端锁屏工具

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

很多时候我们不能一直守护在自己的电脑旁边,而且有些文件并不想让别人知道。那么这时候来个锁屏,是再合适不过的了。今天分享一个自制的锁屏工具,如下。

准备
 "color: #800000"> "color: #800000"> "htmlcode">

#!/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
#加上这个倒记时的小东东,;)

trapper () { #建立个函数
trap ' ' 2 3 20 #忽略CTRL+C CTRL+\ CTRL+Z信号
}
while : #进入死循环
do
trapper #调用函数
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 ;;  #输入正确,挑出循环回到命令行
*)echo "Do not check my files,please! See as follows:"
sleep 3
clear
continue ;;  #否则,继续循环
esac
done

运行演示

程序运行开始:

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


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

由于静态文本没办法显示程序执行过程中的动态效果,所以直接看解锁界面吧
当我们输入不正确的密码的时候,系统会提示输入错误,以及一个幽默的“警告”

 ___________________________
/                           \
\ 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"color: #800000"> ___________________________
/                           \
\ Please enter unlock code: /
 ---------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
         Hello mark,Today is 06:35:05

结语

代码还是很简单的,仅仅用到了shell脚本语法的几个小命令。希望我这个脚本能抛砖引玉,打开你的思路,做出更好的锁屏小脚本!

上一篇:win2003服务器安全设置完全版(脚本之家补充)
下一篇:Nginx启动常见错误及解决方法
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网