I am working on a script I can run to debloat various Linux distros to remove unnecessary prepackaged software based on a persons varying use cases. However there are lots of processes, particularly in the graphical environment, which might be performing some important or expected role which isn't obvious just by looking at top or the installed package list. I've been able to diagnose some of these programs just by simple trial and error, removing a program and seeing what breaks, but this is time consuming and the results aren't always accurate. Sometimes these programs are also nested within processes being run by other programs, such as your file manager popping up when you download a file in Firefox so you can decide where you want to save it.
I want to know is there a program that will identify what application owns a given window being focused on screen? To go back to the Firefox example, when I go to download a file and the file manager pops up I'd want to know what application if giving me the file manager, not just that this overall process is owned by Firefox. Ideally it would be helpful to know what application own various elements of the graphical environment simply by hovering over them. For example if I hover over the wifi applet on my panel that let's me select a network, how would I identify that this program is "nm-applet" rather than just the main networkmanager program thats actually carrying out the process I'm running?
As I said I've tried reverse engineering to identify what is what but its not efficient. If anyone knows of methods to try or programs that would just do this for me it'd be a big help.