Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 7390  / 2 Years ago, sun, february 13, 2022, 8:52:18

How to know the pid of active (focused) window?



I want to write a script in which it is necessary to know whether the user is actively using a program [browsing internet with somthing say firefox] or doing something else [writing text with something say gedit]



In my case i want to download big files but don't want to hurt browsering speed. so when i browse the active window is of firefox and i want to stop downloading. When i read pdf active window is of pdf reader and i want to resume download. That's it.


More From » window

 Answers
2

Finally I managed to work get the PID of actively focused window with xdotool



xprop -id `xdotool getwindowfocus` | grep '_NET_WM_PID' | grep -oE '[[:digit:]]*$'

[#33111] Sunday, February 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
urvedcaly

Total Points: 171
Total Questions: 118
Total Answers: 124

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
urvedcaly questions
Tue, Nov 8, 22, 19:40, 2 Years ago
Fri, May 26, 23, 15:27, 1 Year ago
Wed, Jan 19, 22, 08:09, 2 Years ago
Thu, May 13, 21, 03:34, 3 Years ago
;