diff --git a/scripts/tginput.sh b/scripts/tginput.sh new file mode 100755 index 0000000..1764d99 --- /dev/null +++ b/scripts/tginput.sh @@ -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