Global.display.get_focus_window

I am looking for a help of gjs code.
Purpose: I want to get the application name of focused window.
Issue: how can I find the related function? I found something like below, but it doesn’t work. where can I find the tutorial?
global.display.get_focus_window().get_application().get_name();

Thanks for your help!

Do you mean gjs, or is this a question about Cinnamon?

In GNOME, you would do along those lines:

const windowTracker = Shell.WindowTracker.get_default();
const name = windowTracker.focusApp?.get_name(); // may be undefined if no window has focus

Hi @fmuellner , Thanks for your prompt reply and exact answer! It works very well for me.
Besides, if possible, could you please give me some suggestion and recommendation about the gjs study? So, I can find function and object that I need.

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