View previous topic :: View next topic |
Author |
Message |
megalodon n00b
Joined: 19 Jun 2021 Posts: 19 Location: Rio de Janeiro, Brazil
|
Posted: Sat Jun 19, 2021 3:18 am Post subject: [SOLVED] Openbox autostart doesn`t run xrandr |
|
|
Hi all,
This is my first post here, and guys I need your help. I start Openbox via startx, autostart runs, but xrandr doesn`t. I tried sleep 2 && and also doesn`t help.
But if I try manually sh .config/openbox/autostart it runs as expected:
- set resolution to external display
- move external display to the left
Code: |
# ~/.xinitrc
exec dbus-launch --exit-with-session openbox-session
|
Code: |
#~/.config/openbox/autostart
xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 &
urxvt &
# also tried this, in both cases urxvt start
#urxvt &
#xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 &
# or this
#sleep 2 && xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 &
#(sleep 2 && xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1) &
|
Code: |
# /etc/portage/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-march=native -Os -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
USE="X elogind -systemd -gnome -kde -sendmail"
# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
MAKEOPTS="-j6"
GRUB_PLATFORMS="efi-64"
|
Code: |
#uname -a
Linux thunderstorm 5.10.27-gentoo-x86_64 #1 SMP Sat Jun 12 11:33:58 -03 2021 x86_64 Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz GenuineIntel GNU/Linux
|
/etc/xdg/openbox/{autostart,environment} have no code.
# EDIT:
Following recommendations, I switched from xrandr to Xorg Multiple Monitor.
Last edited by megalodon on Sun Jun 20, 2021 4:18 pm; edited 1 time in total |
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 2964 Location: Edge of marsh USA
|
Posted: Sat Jun 19, 2021 3:52 am Post subject: |
|
|
Interesting. I'm using OpenBox. How about:
Code: | #~/.config/openbox/autostart
urxvt &
sleep 10
xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 &
|
or:
Code: | #~/.config/openbox/autostart
urxvt &
sleep 10
xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1
|
ADDED: Also, Try (adding --sh-syntax):
Code: | #.xinitrc
dbus-launch --sh-syntax --exit-with-session openbox-session
|
_________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
Ralphred Guru
Joined: 31 Dec 2013 Posts: 499
|
Posted: Sat Jun 19, 2021 5:37 am Post subject: |
|
|
If you are having trouble with the timing of a command, it's best to wrap it and have the wrapper only exit when it's successful xrandr-wrapper.sh: | #!/bin/bash
limit=20
until /usr/bin/xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 || [[ limit -lt 1 ]]
do
sleep 1
(( -- limit ))
done |
~/.config/openbox/autostart: | urxvt &
xrandr-wrapper.sh & |
That will try and run your xrandr command every second for 20 seconds until it succeeds.
Mind you, setting LeftOf in xorg.conf seems simpler... |
|
Back to top |
|
|
megalodon n00b
Joined: 19 Jun 2021 Posts: 19 Location: Rio de Janeiro, Brazil
|
Posted: Sun Jun 20, 2021 1:04 am Post subject: |
|
|
figueroa wrote: | Interesting. I'm using OpenBox. How about:
Code: | #~/.config/openbox/autostart
urxvt &
sleep 10
xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 &
|
or:
Code: | #~/.config/openbox/autostart
urxvt &
sleep 10
xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1
|
ADDED: Also, Try (adding --sh-syntax):
Code: | #.xinitrc
dbus-launch --sh-syntax --exit-with-session openbox-session
|
|
Here is my report:
* new .xinitrc only: no changes;
* new autostart only, sleep 1: no changes;
* new autostart only, sleep >= 2 : xrandr works;
* new .xinitrc + new autostart, sleep 1: no changes;
* new .xinitrc + new autostart, sleep >= 2 : xrandr works;
So , new .xinitrc made no difference, but sleep own line did.
Ralphred wrote: | If you are having trouble with the timing of a command, it's best to wrap it and have the wrapper only exit when it's successful xrandr-wrapper.sh: | #!/bin/bash
limit=20
until /usr/bin/xrandr --output HDMI1 --mode 1920x1080 --left-of LVDS1 || [[ limit -lt 1 ]]
do
sleep 1
(( -- limit ))
done |
~/.config/openbox/autostart: | urxvt &
xrandr-wrapper.sh & |
That will try and run your xrandr command every second for 20 seconds until it succeeds.
Mind you, setting LeftOf in xorg.conf seems simpler... |
Ralphred, This did not work, and sincerely, I can't understand why.
Quote: | Mind you, setting LeftOf in xorg.conf seems simpler... |
Are you talking about this? Really didn't know, it looks cleaner, I I'll try.
---
Thanks guys, it's working!
But... I know xrandr needs some time so X loads needed libraries, but why on Ubuntu Server + Openbox (fast for a Ubuntu) xrandr run without sleep? And why ' sleep 2 && ' is different from ' \n sleep 2\n' ? And the last one: Is there anything I can do to reduce this time? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21622
|
Posted: Sun Jun 20, 2021 3:30 am Post subject: |
|
|
Although convenient for testing, using sleep in this way is almost always wrong, because the time required is not precisely constant. Either you set the sleep time too short, and the sleep serves no purpose, or you set the sleep time too long, and wait longer than necessary before the desired command executes. In both cases, you would be better served by using no sleep, and instead triggering the next command when the system signals that the command can be executed. |
|
Back to top |
|
|
megalodon n00b
Joined: 19 Jun 2021 Posts: 19 Location: Rio de Janeiro, Brazil
|
Posted: Sun Jun 20, 2021 3:23 pm Post subject: |
|
|
Hu wrote: | Although convenient for testing, using sleep in this way is almost always wrong, because the time required is not precisely constant. Either you set the sleep time too short, and the sleep serves no purpose, or you set the sleep time too long, and wait longer than necessary before the desired command executes. |
Hi Hu, I agree, but I can't complain now as it's working . I'll try @Ralphred solution as it looks cleaner.
Hu wrote: |
In both cases, you would be better served by using no sleep, and instead triggering the next command when the system signals that the command can be executed. |
Hi Hu, do you have any clues about where can I find this information? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21622
|
Posted: Sun Jun 20, 2021 3:51 pm Post subject: |
|
|
It depends on what you need to be notified about. Since using LeftOf works in Xorg, that suggests either your xrandr ran far too early, or that Xorg has a natural hook for handling this sort of event. It might be useful to know what xrandr reported when it failed to reconfigure the display. |
|
Back to top |
|
|
megalodon n00b
Joined: 19 Jun 2021 Posts: 19 Location: Rio de Janeiro, Brazil
|
Posted: Sun Jun 20, 2021 4:15 pm Post subject: |
|
|
Well, I commented xrandr line in my autostart and tried xorg LeftOf, and works perfect. Here are my files:
Code: | # /etc/X11/xorg.conf.d/41-lvds-monitor.conf
Section "Monitor"
Identifier "LVDS"
Option "PreferredMode" "1366x768"
VendorName "Acer"
EndSection
|
Code: | # /etc/X11/xorg.conf.d/42-hdmi-monitor.conf
Section "Monitor"
Identifier "HDMI"
Option "PreferredMode" "1920x1080"
Option "LeftOf" "LVDS"
VendorName "LG"
EndSection
|
Code: | # /etc/X11/xorg.conf.d/40-video.conf
Section "Device"
Identifier "Device0"
Option "Monitor-LVDS1" "LVDS"
Option "Monitor-HDMI1" "HDMI"
Option "AccelMethod" "sna"
Option "TearFree" "true"
Option "DRI" "True"
Driver "intel"
EndSection
|
Thanks guys. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|