API to get application info

Is there a way to get additional application info for a PID, other than the executable path and command line args? Ideally an application name or identifier, or GUI window title. Or even just whether it has a GUI window attached to it or not. I’d like to use that to scan a process tree and distinguish headless binaries from GUI applications.

!1970 unfortunately broke my current implementation and I’m looking for alternatives.

On macOS, I’m using NSRunningApplication, which gives me things like the app name, app icon, etc.

Hello, if you need to use restricted shell functionality the suggested way to do that now would be to create a shell extension. That way the user can explicitly enable/disable that functionality on demand. Tracking any kind of high level information via PIDs does not really work so well on Linux and definitely won’t work from within a PID namespaced sandbox.

So the only way to achieve this is using restricted shell functionality?

If you are trying to get information from the shell about windows that are not owned by your application, then yes, that functionality is considered privileged and is restricted by the shell for security reasons.

Edit: I think there was some discussion about this in flatpak that was related to what you are talking about: Add a portal to see currently open windows · Issue #304 · flatpak/xdg-desktop-portal · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.