1

I need to know if an application is running and is visible to the user or if is running but minimized (not visible to the user)

I am able to get the pid of my application with pgrep studio but I cannot figure out how to solve the problem described above.

I tried also to get more info with ps -O -pid 5439 but it seems that I cannot get the info I need

appersiano
  • 111
  • 3

1 Answers1

1

There is no information in the process list, about windows. The windowing system is separate from the process management system. Process management is done by Linux (the kernel). Windowing is done by X11 or Wayland, as a normal user process.

There is a way to ask the windowing system, for a list of all windows, their name, whether visible, and other info. This will probably be what you need. (I can't remember how).

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
  • ok so there is no an unique way to do this and make it portable to all os – appersiano Jul 25 '19 at 14:03
  • Did I say that. I think there will be libraries, that will abstract this for a few systems (MS, X11, Wayland, MacOS). Also I think unique and portable have exactly opposite meanings. – ctrl-alt-delor Jul 25 '19 at 14:06
  • My fault, sorry. For other MacOS user this can be a solution https://gist.github.com/timpulver/4753750 – appersiano Jul 25 '19 at 14:13