added passcode setup if not found

This commit is contained in:
Shihaam Abdul Rahman 2023-08-20 12:24:56 +05:00
parent 709079c3e5
commit 0c092f7ab7
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636

View File

@ -23,16 +23,20 @@ lock_tg(){
xdotool windowactivate --sync $tg_window_id key ctrl+l xdotool windowactivate --sync $tg_window_id key ctrl+l
} }
readpin(){ read_passcode(){
if [[ ! -f ~/.local/.tgpin.txt ]]; then if [[ ! -f $HOME/.local/.tgpasscode ]]; then
echo "Error: PIN file not found!" echo "Error: PIN file not found!"
exit 1 echo "Enter Telegram local passcode seperated characters by space"
echo "If passcode is 1234, then enter 1 2 3 4 "
read -p "Enter passcode: " PASSCODE
echo $PASSCODE > $HOME/.local/.tgpasscode
echo Telegram Passcode saved at: $HOME/.local/.tgpasscode
fi fi
tgpin=$(cat ~/.local/.tgpin.txt) tgpasscode=$(cat $HOME/.local/.tgpasscode)
} }
unlock_tg(){ unlock_tg(){
xdotool windowactivate --sync $tg_window_id key $tgpin Return xdotool windowactivate --sync $tg_window_id key $tgpasscode Return
} }
if [ "$1" == "lock" ]; then if [ "$1" == "lock" ]; then
@ -41,7 +45,7 @@ if [ "$1" == "lock" ]; then
lock_tg lock_tg
return_mouse return_mouse
elif [ "$1" == "unlock" ]; then elif [ "$1" == "unlock" ]; then
readpin read_passcode
get_tg_window_id get_tg_window_id
get_mouse_location get_mouse_location
unlock_tg unlock_tg