How can I fetch current monitor orientation while under Wayland? (original) (raw)
November 17, 2024, 12:08am 1
I’m trying to write a bash script that will rotate the screen to the right or left. To do this I need to fetch the current orientation and then increment it. I cannot for the life of me figure out how to fetch this information and it’s making me wonder why we all thought Wayland was so great in the first place.
I DON’T care about setting the orientation. I am doing that via gnome-randr. All I need is to fetch the current orientation.
Sid (Sid) November 17, 2024, 9:41am 2
I’m not an expert here, but there are 2 things.
- Wayland protocol.
- Wayland compositors implementing the protocol.
Mutter is GNOME’s wayland compositor implementation. If screen rotation / orientation is supported by Wayland protocol and works with other implementations (like reference Weston), then this question belongs here. Else, this is probably a question to the Wayland team.
Thanks!
rexendevar (Rexendevar) November 20, 2024, 8:22pm 3
The only leads I had found on this problem involved querying dbus, which is why I put the question here
Sid (Sid) November 21, 2024, 6:48pm 4
If you don’t get a response here, you can try asking in GNOME matrix room.
#gnome-shell:gnome.org
vgaetera (Vladislav Grigoryev) November 28, 2024, 5:45pm 5
While solving a similar problem, I discovered the following:
# Permanent
xmllint --xpath '//rotation/text()' ~/.config/monitors.xml
xmllint --xpath '//flipped/text()' ~/.config/monitors.xml
# Runtime
busctl -j --user call \
org.gnome.Mutter.DisplayConfig \
/org/gnome/Mutter/DisplayConfig \
org.gnome.Mutter.DisplayConfig \
GetCurrentState | jq -r '.data[2][0][3]'
rexendevar (Rexendevar) December 17, 2024, 11:09am 6
that runtime command is exactly what i was looking for, thank you
system (system) Closed January 31, 2025, 11:09am 7
This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.