Toggle between auto and manual rotation from cli

As the title says, I’m looking for a way to reversibly switch systemsettingsDisplay & MonitorOrientation between Automatic and Manual, preferably without root requirements.
I’ve tried disabling iio-sensors-proxy.service but that requires switching back to laptop mode to get auto rotation to work again in tablet mode after reenabling
I’ve also tried qdbus6 org.kde.kded6 /modules/kscreen org.kde.KScreen.setAutoRotate false (suggested here, german topic) but that doesn’t work as qdbus cannot find a /modules/kscreen object

Have you tried using kscreen?

I’ve looked into kscreen-config and kscreen-doctor and it seemed to me that kscreen-doctor doesn’t have the option and kscreen-config is just to read the current configuration

Here’s what I found:

# Disable auto-rotate
kwriteconfig6 --file kwinrc --group Wayland --key AutoRotateScreen false
qdbus6 org.kde.KWin /KWin reconfigure

# Re-enable auto-rotate
kwriteconfig6 --file kwinrc --group Wayland --key AutoRotateScreen true
qdbus6 org.kde.KWin /KWin reconfigure

Test it to see if it works?

If it does you can write a toggle script

#!/bin/bash
current=$(kreadconfig6 --file kwinrc --group Wayland --key AutoRotateScreen)

if [ "$current" = "false" ]; then
    kwriteconfig6 --file kwinrc --group Wayland --key AutoRotateScreen true
    notify-send "Auto-rotate enabled"
else
    kwriteconfig6 --file kwinrc --group Wayland --key AutoRotateScreen false
    notify-send "Auto-rotate disabled"
fi

qdbus6 org.kde.KWin /KWin reconfigure

kscreen-doctor will support it in 6.7

this does not work, though it also doesn’t throw any errors, so I don’t know why

Is there already a scheduled release date for this?

Yes, in about two months: Schedules/Plasma 6 - KDE Community Wiki

Oh, shame. Well at least kscreen-doctor will support it soon.