Applying window rule via command line

i imported a window rule i created using the window management>window rules. it works fine.

is it possible to create the rule from the terminal? i can create the same rule using the following principle but how do i apply the rule once the file is created?

kwriteconfig6 --file kwinrulesrc --group General --key count “1”

i have used dbus-send --session --type=method_call --dest=org.kde.KWin /KWin org.kde.KWin.reconfigure and qdbus6 org.kde.KWin /KWin reconfigure nether seem to work.

be grateful for any help :slight_smile:

i managed to script the rule so i can create it and apply it so it works

RULE_ID=$(uuidgen)

count=$(kreadconfig6 --file kwinrulesrc --group General --key count --default 0)
new_count=$((count + 1))
kwriteconfig6 --file kwinrulesrc --group General --key count “$new_count”

kwriteconfig6 --file kwinrulesrc --group General --key rules “$RULE_ID”

kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key Description “Window settings for com.libretro.RetroArch”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key noborder --type bool “true”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key noborderrule “2”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key types “1”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key wmclass “retroarch com.libretro.RetroArch”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key wmclasscomplete --type bool “true”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key wmclassmatch “1”

qdbus6 org.kde.KWin /KWin reconfigure

but still have the problem the rule only applies if the plasmashell is running or has ran and be killed, might have to raise a bug on kde?

Might be nicer to use code in the forum.

Using three `~~~` symbols:
~~~
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key noborderrule “2”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key types “1”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key wmclass “retroarch
~~~
Or three \`\`` backticks
```
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key noborderrule “2”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key types “1”
kwriteconfig6 --file kwinrulesrc --group “$RULE_ID” --key wmclass “retroarch 
```

You could return and edit your post, then maybe people might want to read :wink:

You could also HIDE it (as I did) using the + symbol in the editor.