You are not logged in.

#1 2020-04-27 13:33:24

sammmstr
Member
Registered: 2020-04-27
Posts: 10

[SOLVED] GDM can't run xrandr command for HiDPI

Hello all,

I've got a laptop with a WQHD display and I'm trying to get fractional scaling setup in Gnome.  I've followed the instructions from the Wiki and everything is working pretty good except the GDM greeter is huge.

Here is the setup:
- Screen is set to 2560x1440
- Scaling in Gnome is 200
- Both Gnome and GDM are using X11.

I created a script like this to run the `xrandr` command:

/usr/local/bin/scale_internal_display
#!/bin/zsh
# Scale internal display by first argument

INTERNAL_DISPLAY_ID=:1
INTERNAL_DISPLAY_NAME='eDP1'

if [ "$DISPLAY" = "$INTERNAL_DISPLAY_ID" ]
then
	echo "Scaling internal display by $1"
	xrandr --output $INTERNAL_DISPLAY_NAME --scale ${1}x${1}
else
	echo "Won't scale display $DISPLAY"
fi

The contents of `/etc/xprofile`:

#!/bin/zsh
scale_internal_display 1.5

This works and scales the display after I log in.  Even though `/etc/xprofile` is sourced by GDM before showing the greeter.  So to debug this I logged in as the GDM user: `sudo -su gdm` and tried to run the command.  The output indicates the gdm user can't access the display:

No protocol specified
Can't open display :1

I've done some searching and couldn't find any solution.  Some similar issues suggest setting the XAUTHORITY env variable but that is already set, and to the same value for the gdm user as the regular user.

I'm sure someone has ran into this before.  Any explanation as to why this is happening and how I might fix it would be appreciated.

Thanks!

Last edited by sammmstr (2020-04-29 10:16:18)

Offline

#2 2020-04-27 13:37:11

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,381

Re: [SOLVED] GDM can't run xrandr command for HiDPI

GDM has it's own x screen (which is why you use ":1" in your own context instead of the usual "default" :0), and should use :0 and gdm's own xauthority file (don't know where that would be)

Offline

#3 2020-04-27 14:25:03

sammmstr
Member
Registered: 2020-04-27
Posts: 10

Re: [SOLVED] GDM can't run xrandr command for HiDPI

Thank you for the quick response.  I think you set me on the right path but it's till not there yet.  Here is what I did:
- Logged out of all sessions.  GDM greeter is displayed.
- Opened a second console and logged in as root, then `sudo -su gdm`
- Observed that XAUTHORITY and DISPLAY are not set.
- `export XAUTHORITY=/run/user/120/gdm/XAuthority`
- `export DISPLAY=:0`
- Now I can run xrandr, but if I run `xrandr --output eDP1 -scale 1.5x1.5`, but it says `Configure crtc 0 failed`.

Maybe it is becaues I am in another console than the x session?

Offline

#4 2020-04-27 16:32:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,822

Re: [SOLVED] GDM can't run xrandr command for HiDPI

Maybe it is becaues I am in another console than the x session?

Yup.
Run "sleep 5; xrandr --output eDP1 -scale 1.5x1.5" and switch to the TTY w/ DISPLAY :0 within the next 5 seconds. Wait.

Online

#5 2020-04-28 12:00:36

sammmstr
Member
Registered: 2020-04-27
Posts: 10

Re: [SOLVED] GDM can't run xrandr command for HiDPI

seth wrote:

Maybe it is becaues I am in another console than the x session?

Yup.
Run "sleep 5; xrandr --output eDP1 -scale 1.5x1.5" and switch to the TTY w/ DISPLAY :0 within the next 5 seconds. Wait.

@Seth, that worked!  The one-liner for the command is:

XAUTHORITY=/run/user/120/gdm/XAuthority xrandr -d :0 --output eDP1 --scale 1.5x1.5

However, I am only able to get it to work manually from another console with sleep.  Seems to have no effect if I put it in `/etc/xprofile` or add it to `/etc/gdm/Init/Default`.

I guess there is another issue.

Offline

#6 2020-04-28 12:33:41

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,822

Re: [SOLVED] GDM can't run xrandr command for HiDPI

I've no idea how GDM operates but you could lift from https://wiki.archlinux.org/index.php/NVIDIA_Optimus#GDM

Online

#7 2020-04-28 13:12:24

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] GDM can't run xrandr command for HiDPI

In addition to the method described in the optimus article, Gnome documents some sort of scripting functionality for GDM:

https://help.gnome.org/admin/gdm/stable … #scripting

Maybe the xrandr command in the Init/ directory is called too early and the size is reset when the gnome settings daemon starts during the greeter autostart phase.

Last edited by progandy (2020-04-28 13:19:05)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#8 2020-04-28 18:20:20

sammmstr
Member
Registered: 2020-04-27
Posts: 10

Re: [SOLVED] GDM can't run xrandr command for HiDPI

Thanks folks.  I'll check that out and report back.

Offline

#9 2020-04-29 10:12:42

sammmstr
Member
Registered: 2020-04-27
Posts: 10

Re: [SOLVED] GDM can't run xrandr command for HiDPI

Thanks everyone.  The issue is resolved.   I set it up as an autostart .desktop and put it in the two locations from the Optimus setup.

/etc/xdg/autostart/hidpi-internal-display.desktop  (symlink -> /usr/share/gdm/greeter/autostart/hidpi-internal-display.desktop)
-------------------------------------------------------------------------------------------------------------------------------
[Desktop Entry]
Type=Application
Name=HiDPI Scale Internal Display
Exec=sh -c "env - XAUTHORITY=/run/user/120/gdm/Xauthority DISPLAY=:0 xrandr --output eDP1 --scale 1.5x1.5"
NoDisplay=true
X-GNOME-AutoRestart=true
X-GNOME-Autostart-Phase=DisplayServer

Offline

Board footer

Powered by FluxBB