40 lines
898 B
Bash
40 lines
898 B
Bash
#!/usr/bin/env sh
|
|
|
|
get_window_id () {
|
|
ids=$(dash "$TSCRIPTS/get-xprop-from-pid.sh" "$telegram_id")
|
|
|
|
ids=$(echo "$ids" | awk '{print $3}')
|
|
|
|
echo "$ids" |
|
|
while read line
|
|
do
|
|
correct1=$(xprop -id "$line" | grep 'WM_STATE(WM_STATE):')
|
|
correct2=$(xprop -id "$line" | grep 'WM_NAME(STRING) = "Telegram')
|
|
[ -n "$correct1" ] && [ -n "$correct2" ] &&
|
|
[ ${#line} -gt 2 ] && echo "$line" && break
|
|
done
|
|
}
|
|
|
|
telegram-desktop
|
|
|
|
telegram_id=$(pgrep Telegram)
|
|
|
|
iterations=10000
|
|
|
|
i=0
|
|
while [ "$i" -lt $iterations ]
|
|
do
|
|
window_id=$(get_window_id "$telegram_id")
|
|
|
|
if [ -n "$window_id" ]; then
|
|
correct=$(xprop -id "$window_id" | grep "window state: Normal")
|
|
fi
|
|
|
|
[ -n "$correct" ] && break || i=$(( $i + 1 ))
|
|
done
|
|
|
|
if [ "$i" -lt $iterations ]; then
|
|
sleep 0.6
|
|
xdotool key alt+7 && xdotool key Return
|
|
fi
|