mOdUlAr
This commit is contained in:
parent
b2e7765b13
commit
e742d169c2
@ -6,30 +6,42 @@ if [[ $XDG_SESSION_TYPE != "x11" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
get_tg_window_id(){
|
get_tg_window_id(){
|
||||||
tg_window_id=$(wmctrl -lx | grep telegram-desktop | awk '{print $1}')
|
tg_window_id=$(wmctrl -lx | grep telegram-desktop | awk '{print $1}')
|
||||||
}
|
}
|
||||||
|
|
||||||
get_mouse_location(){
|
get_mouse_location(){
|
||||||
mouse_xy=$(xdotool getmouselocation --shell)
|
mouse_xy=$(xdotool getmouselocation --shell)
|
||||||
mouse_x=$(printf "%s\n" "$mouse_xy" | grep X= | cut -d= -f2)
|
mouse_x=$(printf "%s\n" "$mouse_xy" | grep X= | cut -d= -f2)
|
||||||
mouse_y=$(printf "%s\n" "$mouse_xy" | grep Y= | cut -d= -f2)
|
mouse_y=$(printf "%s\n" "$mouse_xy" | grep Y= | cut -d= -f2)
|
||||||
}
|
}
|
||||||
|
|
||||||
return_mouse(){
|
return_mouse(){
|
||||||
xdotool mousemove $mouse_x $mouse_y
|
xdotool mousemove $mouse_x $mouse_y
|
||||||
|
}
|
||||||
|
|
||||||
|
lock_tg(){
|
||||||
|
xdotool windowactivate --sync $tg_window_id key ctrl+l
|
||||||
|
}
|
||||||
|
|
||||||
|
readpin(){
|
||||||
|
tgpin=$(cat ~/.local/.tgpin.txt)
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock_tg(){
|
||||||
|
xdotool windowactivate --sync $tg_window_id key $tgpin Return
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" == "lock" ]; then
|
if [ "$1" == "lock" ]; then
|
||||||
get_tg_window_id
|
get_tg_window_id
|
||||||
get_mouse_location
|
get_mouse_location
|
||||||
xdotool windowactivate --sync $tg_window_id key ctrl+l
|
lock_tg
|
||||||
return_mouse
|
return_mouse
|
||||||
elif [ "$1" == "unlock" ]; then
|
elif [ "$1" == "unlock" ]; then
|
||||||
get_tg_window_id
|
get_tg_window_id
|
||||||
get_mouse_location
|
get_mouse_location
|
||||||
tgpin=$(cat ~/.local/.tgpin.txt)
|
readpin
|
||||||
xdotool windowactivate --sync $tg_window_id key $tgpin Return
|
unlock_tg
|
||||||
return_mouse
|
return_mouse
|
||||||
else
|
else
|
||||||
echo "Invalid argument. Please use 'lock' or 'unlock'."
|
echo "Invalid argument. Please use 'lock' or 'unlock'."
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user