You are not logged in.

#1 2024-11-23 22:56:30

flyingpenguin
Member
Registered: 2023-10-04
Posts: 7

[SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

Hello. I previously used:

[tv@babydeer ~]$ cat .xinitrc 
xrdb -merge .Xresources

xrandr --output HDMI-2 --mode 1280x720

exec openbox-session
[tv@babydeer ~]$ 

to set the output of my HTPC to the native resolution of the TV. I had this command in .xinitrc. This worked. I am using xinit, openbox, and tint2. However, I had screen tearing issues, so I installed xf86-video-intel, and set the following:

[tv@babydeer ~]$ cat /etc/X11/xorg.conf.d/20-intel.conf 
Section "Device"
  Identifier "Intel Graphics"
  Driver "intel"
  Option "TearFree" "true"
EndSection
[tv@babydeer ~]$ 

That fixed the screen tearing, but then the xinitrc xrandr command stopped working. I realized that the name had changed from HDMI-2 to HDMI2. So I fixed that, but it still won't set the screen resolution automatically in xinit. Here is my new xinitrc:

[tv@babydeer ~]$ cat .xinitrc 
xrdb -merge .Xresources

xrandr --output HDMI2 --mode 1280x720

exec openbox-session
[tv@babydeer ~]$

However, and here's the part that really throws me, I can run the same commands after openbox is up and running, and it works. I can set the screen resolution how I want with the following bash script:

[tv@babydeer ~]$ cat s
#!/bin/bash

xrandr --output HDMI2 --mode 1280x720


[tv@babydeer ~]$

Here is the output of xrandr:

[tv@babydeer ~]$ xrandr
Screen 0: minimum 8 x 8, current 1280 x 720, maximum 32767 x 32767
DP1 disconnected primary (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 connected 1280x720+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080i    60.00 +  59.94  
   1280x720      60.00*   59.94  
   1440x480i     59.94  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       60.00    59.94  
HDMI3 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
[tv@babydeer ~]$

Here is lspci:

[tv@babydeer ~]$ lspci
00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-S GT2 [UHD Graphics 630]
00:08.0 System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model
00:12.0 Signal processing controller: Intel Corporation Cannon Lake PCH Thermal Controller (rev 10)
00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller (rev 10)
00:14.2 RAM memory: Intel Corporation Cannon Lake PCH Shared SRAM (rev 10)
00:14.3 Network controller: Intel Corporation Cannon Lake PCH CNVi WiFi (rev 10)
00:15.0 Serial bus controller: Intel Corporation Cannon Lake PCH Serial IO I2C Controller #0 (rev 10)
00:16.0 Communication controller: Intel Corporation Cannon Lake PCH HECI Controller (rev 10)
00:16.3 Serial controller: Intel Corporation Cannon Lake PCH Active Management Technology - SOL (rev 10)
00:17.0 SATA controller: Intel Corporation Cannon Lake PCH SATA AHCI Controller (rev 10)
00:1b.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #17 (rev f0)
00:1f.0 ISA bridge: Intel Corporation Q370 Chipset LPC/eSPI Controller (rev 10)
00:1f.3 Audio device: Intel Corporation Cannon Lake PCH cAVS (rev 10)
00:1f.4 SMBus: Intel Corporation Cannon Lake PCH SMBus Controller (rev 10)
00:1f.5 Serial bus controller: Intel Corporation Cannon Lake PCH SPI Controller (rev 10)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (7) I219-LM (rev 10)
01:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983
[tv@babydeer ~]$ 

from /proc/cpuinfo:

model name	: Intel(R) Core(TM) i5-8500T CPU @ 2.10GHz

This is a Dell Optiplex 7060 Micro.

Last edited by flyingpenguin (2024-11-27 02:48:34)

Offline

#2 2024-11-24 13:09:19

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,038

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

xf86-video-intel is to old for your videocard. If you do feel it's your only option make sure to add a line to 20-intel.conf so mesa will use the correct driver .

Your .xinitrc is faulty and needs to be changed, see https://wiki.archlinux.org/title/Xinit#xinitrc .

If that doesn't solve the issue, post xorg log.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2024-11-24 14:09:53

flyingpenguin
Member
Registered: 2023-10-04
Posts: 7

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

Thank you for the reply. I would like to use the correct drivers if I can solve screen tearing another way. But as you recommended, I fixed .xinitrc to mostly be a copy of /etc/X11/xinit/xinitrc

[tv@babydeer ~]$ cat .xinitrc
#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

xrandr --output HDMI2 --mode 1280x720

exec openbox-session
[tv@babydeer ~]$ 

And I updated 20-intel.conf:

[tv@babydeer ~]$ cat /etc/X11/xorg.conf.d/20-intel.conf 
Section "Device"
  Identifier "Intel Graphics"
  Driver "intel"
  Option "TearFree" "true"
  Option "DRI" "iris"
EndSection
[tv@babydeer ~]$

Same issue where the resolution is not set automatically in .xinitrc, but I can with the bash script I referenced in the first post.

Here is .local/share/xorg/Xorg.0.log ----->>> https://pastebin.com/zj8qXgej

Thank you for your patience! I've been running Arch on my main machine for a couple years now, but still very much a novice. smile

Last edited by flyingpenguin (2024-11-24 14:11:54)

Offline

#4 2024-11-24 15:05:36

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,038

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

[     7.272] (--) intel(0): Output HDMI2 using initial mode 1920x1080i on pipe 0

[     7.455] (II) intel(0): switch to mode 1920x1080@60.0 on HDMI2 using pipe 0, position (0, 0), rotation normal, reflection none
[     7.470] (II) intel(0): Setting screen physical size to 508 x 285

[    21.957] (II) intel(0): resizing framebuffer to 1280x720
[    21.961] (II) intel(0): switch to mode 1280x720@60.0 on HDMI2 using pipe 0, position (0, 0), rotation normal, reflection none

Are the last 2 lines also present before you run your script to change resolution  ?

Please post your /etc/mkinitcpio.conf .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-11-24 19:12:24

flyingpenguin
Member
Registered: 2023-10-04
Posts: 7

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

No, they are not. As you suspected, when I first boot, those last two lines are not present. I am beginning to suspect some kind of race condition. Is there a better way to set the resolution? Should I be doing it in the xorg configuration?

Here is /etc/mkinitcpio.conf:

[tv@babydeer ~]$ cat /etc/mkinitcpio.conf
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES=(usbhid xhci_hcd)
MODULES=()

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=()

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No RAID, lvm2, or encrypted root is needed.
#    HOOKS=(base)
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS=(base udev autodetect modconf block filesystems fsck)
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS=(base udev modconf block filesystems fsck)
#
##   This setup assembles a mdadm array with an encrypted root file system.
##   Note: See 'mkinitcpio -H mdadm_udev' for more information on RAID devices.
#    HOOKS=(base udev modconf keyboard keymap consolefont block mdadm_udev encrypt filesystems fsck)
#
##   This setup loads an lvm2 volume group.
#    HOOKS=(base udev modconf block lvm2 filesystems fsck)
#
##   This will create a systemd based initramfs which loads an encrypted root filesystem.
#    HOOKS=(base systemd autodetect modconf kms keyboard sd-vconsole sd-encrypt block filesystems fsck)
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr and fsck hooks.
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block filesystems fsck)

# COMPRESSION
# Use this to compress the initramfs image. By default, zstd compression
# is used for Linux ≥ 5.9 and gzip compression is used for Linux < 5.9.
# Use 'cat' to create an uncompressed image.
#COMPRESSION="zstd"
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()

# MODULES_DECOMPRESS
# Decompress loadable kernel modules and their firmware during initramfs
# creation. Switch (yes/no).
# Enable to allow further decreasing image size when using high compression
# (e.g. xz -9e or zstd --long --ultra -22) at the expense of increased RAM usage
# at early boot.
# Note that any compressed files will be placed in the uncompressed early CPIO
# to avoid double compression.
#MODULES_DECOMPRESS="no"
[tv@babydeer ~]$

Offline

#6 2024-11-25 10:27:04

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,038

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

Static monitor configurations can cause issues when the monitor is changed, let's investigate a bit more.

The i915 kernel module for your card is loaded early, so should be initialised fully before X starts.

Are you using some type of autologin ?

If yes, append systemd.unit=multi-user.target to force a console login temporarily .
wait a minute to allow things to setlle, then login as user and run startx manually.

Post the log from that attempt .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#7 2024-11-26 09:17:16

seth
Member
Registered: 2012-09-03
Posts: 59,882

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

/etc/X11/xorg.conf.d/10-monitor.conf

Section "Monitor"
  Identifier "HDMI2"
  Option "PreferredMode" "1280x720"
EndSection

I'd say to make sure you don't have any configs in https://wiki.archlinux.org/title/Openbox#Autostart but they'd use the wrong output name and also  there're no previous mode  changes logged.

Please alter your xinitrc

…
xrandr -q > /tmp/xrandr.pre
xrandr --output HDMI2 --mode 1280x720 > /tmp/xrandr.out 2>&1
xrandr -q > /tmp/xrandr.post
exec openbox-session

and check /tmp/xrandr.* about the states around that call

Offline

#8 2024-11-27 02:45:42

flyingpenguin
Member
Registered: 2023-10-04
Posts: 7

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

Okay! Thanks to both of you, I have two working solutions to choose from! Yes, I am using autologin per the wiki I put a drop-in file in systemd's getty folder.

[tv@babydeer ~]$ cat /etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
Environment=XDG_SESSION_TYPE=x11
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin tv %I $TERM
[tv@babydeer ~]$ 

I disabled auto-login, and there was no change. I did create a static X11 configuration as a 10-monitor.conf

[root@babydeer ~]# cat 10-monitor.conf 
Section "Monitor"
    Identifier "HDMI2"
    Option "PreferredMode" "1280x720"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Intel"
    Monitor "HDMI2"
    DefaultDepth 24
    SubSection "Display"
        Depth 24
        Modes "1280x720"
    EndSubSection
EndSection
[root@babydeer ~]# 

That worked! X would automatically start in my desired resolution.

However, curious about what Seth had said, I removed the X11 static configuration, and put xrandr -q >> xrandr.pre/post before and after the xrandr command in .xinitrc. To my surpise, when I rebooted, the resolution was correct! And those "logs" from xrandr -q showed that the resolution did indeed change between outputs. Now, xrandr -q takes a second or so, confirming my suspicions about a race condition. So I put sleep 2 before xrandr in xinit, and it all works like it should!

[tv@babydeer ~]$ cat .xinitrc
#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

sleep 2
xrandr --output HDMI2 --mode 1280x720


exec openbox-session

Interestingly, sleep 1 apparently wasn't enough. I tried that first. Marking this as solved. I'm chalking it up to an unknown race condition. Apparently the kernel mode setting drivers were faster? I may also try wayland and see if I have screen tearing.

Offline

#9 2024-11-27 07:09:50

seth
Member
Registered: 2012-09-03
Posts: 59,882

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

xinitrc runs after the server started.
Since you need to sleep before the randr call it's not some openbox/xdg autostart routine.
The offending call will be

[     7.455] (II) intel(0): switch to mode 1920x1080@60.0 on HDMI2 using pipe 0, position (0, 0), rotation normal, reflection none

(a mode that doesn't even exist, the monitor does FullHD only interlaced)

/etc/X11/xinit/xinitrc.d is off the hook because you initiallly didn't even source it.

=> How do you invoke xinit?

Offline

#10 2024-11-27 12:22:28

flyingpenguin
Member
Registered: 2023-10-04
Posts: 7

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

seth wrote:

=> How do you invoke xinit?

I invoke startx in .bash_profile just like is shown here:

https://wiki.archlinux.org/title/Xinit# … X_at_login

Offline

#11 2024-11-27 17:19:51

seth
Member
Registered: 2012-09-03
Posts: 59,882

Re: [SOLVED] xrandr won't set res in .xinitrc with xf86-video-intel

Do you have other stuff in your .bash_profile?
What if you add the delay there before running startx?

Offline

Board footer

Powered by FluxBB