Run KWin Script from command line with argument?

Hi All,

Is it possible to run a KWin script from the command line and pass it an argument?

In particular I would like to be able to run something like:

kwin-raise-window "title"

and have the window with the matching title (or some other identifying attribute) be focused and raised.

Thanks in advance,


I think you’re looking for ‘wmctrl’.

So then do ‘wmctrl -l’ to list windows…

I had a ‘sleep’ script that closed all open windows and set low volume for before suspending, but I am not sure it still works with Plasma 6 …

window_list=$(wmctrl -l | awk '{print $1}')
for window in $window_list; do
    wmctrl -ic "$window"
done; amixer set Master 10%; systemctl suspend

So find a way to grep and pick one from the list, and act on that.

KWin scripts don’t work like that. You don’t “invoke” them - they are always running. What you can do - if you want to send parameters to a script - is to create an ad-hoc script, load it using the KWin D-Bus interface and then run it using another D-Bus command.

### create /your/script with all the options, then
num=$(qdbus org.kde.KWin /Scripting org.kde.kwin.Scripting.loadScript /your/script)
qdbus org.kde.KWin /$num
sleep 5
qdbus org.kde.KWin /$num org.kde.kwin.Script.stop

See this Stack Exchange answer for the details. (use the newest answer, not the accepted one)

1 Like

Sadly does not exist on wayland/plasma 6. :frowning:

But look at this project I just found! :open_mouth:

1 Like

Thank you so much! kdotool windowactivate ... works perfectly!

1 Like