rickybrent / gnome-randr-py

Fork of https://gitlab.com/Oschowa/gnome-randr/
1 stars 3 forks source link

Cant rotate screen #1

Open VietTralala opened 1 year ago

VietTralala commented 1 year ago

Hi, I am trying to programmatically rotate my screen with the command: python gnome-randr.py --output HDMI-1 --rotate left

However I get the following message:

new monitor configuration:
logical monitor 0:
x: 0 y: 0, scale: 1.0, rotation: left, primary: no
associated physical monitors:
    HDMI-1 1920x1080@60,000

Traceback (most recent call last):
  File "/home/viet/Downloads/gnome-randr.py", line 860, in <module>
    dc_iface.ApplyMonitorsConfig(config_info.serial,
  File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: Config is missing primary logical

Do you know what went wrong?

rickybrent commented 1 year ago

Hi! It looks like you don't have a primary monitor set. I haven't encountered that before, but am not sure it's a bug -- Gnome is likely treating it as primary since it's the only one, and that may be the correct behavior...

I suspect running python gnome-randr.py --output HDMI-1 --primary --rotate left will work, could you give it a try?

VietTralala commented 1 year ago

Thanks for the quick response! I tried your suggested command and it rotated my HDMI-1 screen. However I actually use my other screen (DP-1) as the primary one in normal orientation and your command deactivated the DP-1 screen. So I thought I specify the second screen as well:

python gnome-randr.py --output DP-1 --rotate normal --primary --output HDMI-1 --rotate left

Since I sometimes want to switch my HDMI-1 from normal orientation to left portrait mode while leaving the DP-1 screen in normal orientation.

However this resulted in:

new monitor configuration:
logical monitor 0:
x: 0 y: 0, scale: 1.0, rotation: left, primary: no
associated physical monitors:
    HDMI-1 1920x1080@60,000

Traceback (most recent call last):
  File "/home/viet/Downloads/gnome-randr.py", line 860, in <module>
    dc_iface.ApplyMonitorsConfig(config_info.serial,
  File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: Config is missing primary logical
rickybrent commented 1 year ago

No problem -- and that is odd ... I wonder why DP-1 doesn't show in the associated physical monitors list? I am currently traveling so won't be able to test multiple monitors myself for a bit, but I've used it to rearrange monitors before with --right-of and --left-of, and that looks right.

Do you happen to have "Workspaces on primary display only" set?

VietTralala commented 1 year ago

I am using dynamic workspaces on all displays. Maybe this info helps: Output of python gnome-randr.py --current:

max-screen-size: 0x0
layout-mode: logical
global-scale-required: no
supports-mirroring: yes
supports-changing-layout-mode: no

logical monitor 0:
x: 2560 y: 0, scale: 1.0, rotation: left, primary: no
associated physical monitors:
    HDMI-1 BenQ GW2250H

logical monitor 1:
x: 0 y: 243, scale: 1.0, rotation: normal, primary: yes
associated physical monitors:
    DP-1 PHL 275E1

DP-1 PHL PHL 275E1 0x00000404
    2560x1440   74.97      59.95*+                           [x1.0+, x2.0, x3.0]
    1920x1080   60.00      59.94      50.00                  [x1.0+, x2.0]
    1680x1050   59.95                                        [x1.0+, x2.0]
     1440x900   59.89                                        [x1.0+]
    1280x1440   59.91                                        [x1.0+, x2.0]
    1280x1024   75.02      60.02                             [x1.0+]
     1280x960   60.00                                        [x1.0+]
     1280x720   60.00      59.94      50.00                  [x1.0+]
     1024x768   75.03      70.07      60.00                  [x1.0+]
      800x600   75.00      72.19      60.32      56.25       [x1.0+]
      720x576   50.00                                        [x1.0+]

HDMI-1 BNQ BenQ GW2250H H8C06474019
    1920x1080   60.00*+    59.94      50.00       [x1.0+, x2.0]
    1680x1050   59.95                             [x1.0+, x2.0]
     1600x900   60.00                             [x1.0+]
    1280x1024   60.02                             [x1.0+]
     1280x960   60.00                             [x1.0+]
     1280x800   59.81                             [x1.0+]
     1280x720   60.00      59.94      50.00       [x1.0+]
     1024x768   60.00                             [x1.0+]
     1024x576   60.01                             [x1.0+]
      800x600   60.32                             [x1.0+]
      720x576   50.00                             [x1.0+]

And I also had to slightly change a line 165 in the script to account for floating number with a , instead of . as decimal separator (German language vs English):

 def mode_id_to_vals(mode_id):
     w, h_rate = mode_id.split('x')  
     h, rate = h_rate.split('@')   
     return (int(w), int(h), float(rate.replace(',','.'))) # <--- this was changed

But I don't think this is important here right?

mamaoi commented 1 year ago

Same issue, I have 2 monitor 'mirrored', I can't keep 1 monitor --rotate normal and the other --rotate inverted, with xrander I could.

python3 gnome-randr.py --output HDMI-1 --rotate normal --primary --output DP-1 --rotate inverted
new monitor configuration:
logical monitor 0:
x: 0 y: 0, scale: 1.0, rotation: inverted, primary: yes
associated physical monitors:
    DP-1 1920x1080@60
    HDMI-1 1920x1080@60

no changes made

Yes, I can rotate monitors, but the command affect only the monitor DP-1 no really matter about HDMI-1, all commands given to HDMI-1 are compleately ignored. It seems that in order to rotate monitors into 'mirror-mode', none of xrandr features can be usable, probably wayland not allow it.