自制Linux 终端 锁屏防窃助手
2016-07-02 15:39
459 查看
很多时候我们不能一直守护在自己的电脑旁边,而且有些文件并不想让别人知道。那么这时候来个锁屏,是再合适不过的了。今天分享一个自制的锁屏工具,如下。
Shell语言 : 我使用的是默认的Bash Shell
其他小工具 :
fortune:系统随机的从语库中选出一句英文成语。
cowsay : 在终端界面上显示出一个奶牛的语句框,配合管道连接上fortune,效果完美!
由于静态文本没办法显示程序执行过程中的动态效果,所以直接看解锁界面吧
当我们输入不正确的密码的时候,系统会提示输入错误,以及一个幽默的“警告”
当我们密码输入正确的时候,如下:
:-)
准备
操作系统 : 我这里是ElementaryOS虚拟机 + XShell 远程登录工具Shell语言 : 我使用的是默认的Bash Shell
其他小工具 :
fortune:系统随机的从语库中选出一句英文成语。
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 $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? A: That's the Law of Spline | \ Demand. / ----------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
当我们密码输入正确的时候,如下:
___________________________ / \ \ Please enter unlock code: / --------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || Hello mark,Today is 06:35:05
结语
代码还是很简单的,仅仅用到了shell脚本语法的几个小命令。希望我这个脚本能抛砖引玉,打开你的思路,做出更好的锁屏小脚本!:-)
相关文章推荐
- 每天一个linux命令(29)--Linux chmod命令
- CentOS 7.x NAT模式上网配置1
- X server:linux 图形界面原理
- 使用libevent编写Linux服务
- CentOS5.6 安装RabbitMQ
- 玩转树莓派之零----了解树莓派
- CentOS配置网易163 yum源
- Linux内核---18.platfrome_device与platform_driver的注册过程分析
- Linux内核---17.platform_device的添加过程
- Linux内核---16.启动分析4uboot与内核的参数传递
- Linux下g++编译与使用静态库和动态库
- Linux下如何配置samba服务器?
- Linux内核---15.启动分析3之arch/arm/kernel/head.S
- Linux内核---14.启动分析2之arch/arm/kernel/head.S
- Linux内核---13.启动分析1之arch/arm/kernel/head.S
- Linux内核---12.S3C6410平台中SD启动详细分析
- Linux内核---11.关于结构体对齐
- linux下管道问题
- 聊聊Linux 五种IO模型
- Linux内核---10.obj-y中将.c编译为.o流程