From 1c9b6cd94a6c86212a1671c91c4a76cc7b7065c6 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sun, 20 Aug 2023 11:21:03 +0500 Subject: [PATCH] added telegram lock/unlock script --- scripts/tginput.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/tginput.sh 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