added telegram lock/unlock script

This commit is contained in:
Shihaam Abdul Rahman 2023-08-20 11:21:03 +05:00
parent 7192a961e9
commit 1c9b6cd94a
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636

31
scripts/tginput.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
get_tg_window_id(){
tg_window_id=$(wmctrl -lx | grep telegram-desktop | awk '{print $1}')
}
get_mouse_location(){
mouse_xy=$(xdotool getmouselocation --shell)
mouse_x=$(printf "%s\n" "$mouse_xy" | grep X= | cut -d= -f2)
mouse_y=$(printf "%s\n" "$mouse_xy" | grep Y= | cut -d= -f2)
}
return_mouse(){
xdotool mousemove $mouse_x $mouse_y
}
if [ "$1" == "lock" ]; then
get_tg_window_id
get_mouse_location
xdotool windowactivate --sync $tg_window_id key ctrl+l
return_mouse
elif [ "$1" == "unlock" ]; then
get_tg_window_id
get_mouse_location
tgpin=$(cat ~/.local/.tgpin.txt)
xdotool windowactivate --sync $tg_window_id key $tgpin Return
return_mouse
else
echo "Invalid argument. Please use 'lock' or 'unlock'."
exit 1
fi