-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlock.sh
More file actions
39 lines (36 loc) · 745 Bytes
/
lock.sh
File metadata and controls
39 lines (36 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
dir=/home/user/lock.sh
port=35432
key="your otp key here"
while test "$#" -gt 0; do
case "$1" in
-s|--socat)
shift
export socatr="1"
shift
;;
*)
break
;;
esac
done
if [ "$socatr" = "1" ]; then
clear
echo "Starting socat"
socatr=0
socat -u tcp-l:"$port",fork system:"$dir"
else
echo "Locking the screen"
read otp
otplocal=$(oathtool --base32 --totp "$key")
if [ "$otp" = "$otplocal" ]; then
date=$(date)
echo "OTP match locking the screen date: $date"
xdg-screensaver lock
echo "local otp: $otplocal sent otp: $otp"
else
date=$(date)
echo "OTP does not match not locking date: $date"
echo "local otp: $otplocal sent otp: $otp"
fi
fi