Is there a way to create a new instance of whatever window is active through a shortcut?
I.e. launch a new terminal, open a new firefox window etc, but without configuring the shortcut for each app (which might not always be possible)
Is there a way to create a new instance of whatever window is active through a shortcut?
I.e. launch a new terminal, open a new firefox window etc, but without configuring the shortcut for each app (which might not always be possible)
I actually thought of doing something like this in the past, since KWin already knows the pid of each window it is possible to get the executable of said pid by reading the contents of /proc/PID/cmdline
.
So there are multiple possible ways to do this, one could be to use kdotool:
$(cat /proc/$(kdotool getactivewindow getwindowpid)/cmdline)
Or a QML KWin script that uses DataSource
with engine: "executable"
, I am currently writing one
There is a catch with these approaches though, when manually running an executable like that it doesn’t use any of the arguments or environment variables specified in the desktop entry file, including the ones you add manually in the KDE menu editor. For this same reason it will not work for applications running under flatpak for example.
A possible alternative to running the raw command could be to figure out the location of the desktop entry from the KWin window.desktopFileName
which returns just the entry name without path e.g org.kde.kate
then launch the actual desktop entry