Focus Notifier Is a KWin script, service, and tool allowing access to information about the currently focused window.
This works for KDE only, and works across Wayland and X11.
This was intended to facillitate scripting with tools such as ydotool. (e.g. this will allow you to fire different input with ydotool depending on which program is in focus.)
This is available through the KDE store and should be able to be installed through the "Get New Scripts" button in "Window Management -> KWin Scripts" in the system settings. You may also install the kwin script manually by downloading this folder and placing it in ~/.local/share/kwin/scripts/
.
Once installed, it should be enabled through the "Window Management -> KWin Scripts" view in the system settings.
Once installed and enabled, navigate to ~/.local/share/kwin/scripts/
and run the install.sh file. This will install the service and the activewindow
command.
To uninstall, navigate to ~/.local/share/kwin/scripts/
run the uninstall.sh file, and disable and possibly delete the KWin script through the "Window Management -> KWin Scripts" view in the system settings.
Once installed, you should be able to run the command activewindow
.
activewindow
has the following subcommands:
help
get
-
pid
(the process ID)
-
pname
(the process name)
-
name
(the window name)
-
class
(the window class)
-
caption
(the window's titlebar text, if applicable)
The KWin script listens to when focus is changed. It sends this information over DBus, which is then listened to by the listener script, which is run as a systemd service. The listener script stores this information in temp files, which can then be retrieved using the activewindow
command.