You are not logged in.

#1 2023-01-02 09:47:36

Enrico1989
Member
Registered: 2018-07-05
Posts: 361

How do I launch xrandr config when starting GNOME via .xinit?

I've had for a long time the following in my /home/ME/.xinitrc

xinput set-prop 11 "libinput Tapping Enabled" 1
exec i3

which is executed when I log in form tty1 virtual console (I don't use a login manager and I'm happy like this). Then, upon i3 starting up, it sets up the screen config according to some logic I've encoded in a bash script, which is executed via /home/ME/.config/i3/config, where I've put this line:

exec_always $HOME/path/to/my/setscreens.sh

Now I've created another user which will use GNOME (because i3 is just impossible for them), so I've put the following in /home/OTHER/.xinitrc

export XDG_SESSION_TYPE=x11
export GDK_BACKEND=x11
exec gnome-session

however, I also want to reduce the resolution. So I started GNOME, decided the desired resolution via Arandr, and exported a file in ~OTHER/.screenlayout/set-screen.sh to apply the setting. The file clearly contains

#!/bin/sh
xrandr --output and so on

and when logging in as OTHER, I can open a termina, run that file, and the resolution does change.

The point is that I'd want that setting to happen when GNOME starts, i.e. when OTHER logs in from the virtual console.

Given the original config file,

export XDG_SESSION_TYPE=x11
export GDK_BACKEND=x11
# before
exec gnome-session
#after

I thought I would insert

exec ~OTHER/.screenlayout/set-screen.sh

at #after, because GNOME has to start first, before I can change the settings, no? However, at https://wiki.archlinux.org/title/Xinit#xinitrc I read that "lines following a command using exec would be ignored", so I think I'm going in the wrong direction.

Last edited by Enrico1989 (2023-01-02 10:45:38)

Offline

#2 2023-01-02 12:24:53

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: How do I launch xrandr config when starting GNOME via .xinit?

I like to use custom .desktop files in ~/.config/autostart/ to run stuff in GNOME because that works for both X11 and Wayland. EDIT: https://specifications.freedesktop.org/ … atest.html

If this is for screen configuration under X then why not use an X.Org configuration file? Seems more appropriate to me.

Last edited by Head_on_a_Stick (2023-01-02 12:31:06)


Jin, Jîyan, Azadî

Offline

#3 2023-01-02 13:36:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: How do I launch xrandr config when starting GNOME via .xinit?

Enrico1989 wrote:

... at #after, because GNOME has to start first, before I can change the settings, no?

No, that's completely incorrect.  It's actually much better to set up the screens before the WM starts.  Otherwise the WM starts, sets everything up, the screen changes, and the WM has to reset everything.  Put the xrandr command in your xintrc at the #before line.

Note that this is true also for your i3 user.  While it can work in the i3 config, it's a little slower / messier as, again, i3 reads the screen size, sets up containers and any bar etc, then gets a screen change event and has to resize everything.  If you set up the screen size first, i3 can just set everything up at the proper size the first time.

Last edited by Trilby (2023-01-02 13:38:35)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2023-01-02 13:54:58

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

Re: How do I launch xrandr config when starting GNOME via .xinit?

Also nb. that nothing after the first "exec" line in the xinitrc is executed.

export XDG_SESSION_TYPE=x11
export GDK_BACKEND=x11
~OTHER/.screenlayout/set-screen.sh
exec gnome-session

Online

#5 2023-01-02 16:20:22

Enrico1989
Member
Registered: 2018-07-05
Posts: 361

Re: How do I launch xrandr config when starting GNOME via .xinit?

seth wrote:
export XDG_SESSION_TYPE=x11
export GDK_BACKEND=x11
~OTHER/.screenlayout/set-screen.sh
exec gnome-session

even with this, the resolution is not adapted.

But if I open a terminal and type ~OTHER/.screenlayout/set-screen.sh and hit enter, the change of resolution does happen.

Offline

#6 2023-01-02 16:25:08

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

Re: How do I launch xrandr config when starting GNOME via .xinit?

It's probably adapted and then overridden by some gnome setting.
Ideally configure it there, otherwise you'll have to go w/ an autostart service (and possibly delay)

Online

#7 2023-09-25 16:45:12

Enrico1989
Member
Registered: 2018-07-05
Posts: 361

Re: How do I launch xrandr config when starting GNOME via .xinit?

seth wrote:

It's probably adapted and then overridden by some gnome setting.

Is there a way to find where this is happening?

otherwise you'll have to go w/ an autostart service (and possibly delay)

you mean systemclt?

Offline

#8 2023-09-25 16:48:22

Enrico1989
Member
Registered: 2018-07-05
Posts: 361

Re: How do I launch xrandr config when starting GNOME via .xinit?

Head_on_a_Stick wrote:

I like to use custom .desktop files in ~/.config/autostart/ to run stuff in GNOME because that works for both X11 and Wayland. EDIT: https://specifications.freedesktop.org/ … atest.html

If this is for screen configuration under X then why not use an X.Org configuration file? Seems more appropriate to me.

Can you give an example of such a config file?

Offline

#9 2023-09-25 19:04:38

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

Re: How do I launch xrandr config when starting GNOME via .xinit?

Online

Board footer

Powered by FluxBB