LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [.profile]: xrandr (https://www.linuxquestions.org/questions/linux-newbie-8/%5B-profile%5D-xrandr-4175668131/)

thomasbb 01-21-2020 05:30 AM

[.profile]: xrandr
 
Hello,
In the .profile file, I added:
Code:

xrandr --output DVI-I-0 --auto --primary --output DVI-I-1 --auto --right-of DVI-I-0
but it doesn't work and still takes to be executed manually. What did I do wrong?

slac-in-the-box 01-21-2020 01:41 PM

I think the .profile is for configuring the shell environment more than X11.

Perhaps you could save your command as a script, make it executable, and add your script to your Window Manager's startup apps.

Use emacs, vi, kate, or whatever text editor you use, to save a file, say ~/.xrandrconfig.sh, with the following contents:
Code:

#!/bin/sh
xrandr --output DVI-I-0 --auto --primary --output DVI-I-1 --auto --right-of DVI-I-0

then, at the command line (fire up a terminal emulator, like xterm),

Code:

chmod +x ~/.xrandrconfig.sh
And then find, in your Window Manager's settings, the one to configure startup applications, and add xrandrconfig.sh.




Another option:

If you are the only user, you can also create, in /etc/X11/xorg.conf.d a configuration file, ending in .conf, just for configuring these screens, but I think you will have to use the syntax of xorg.conf and not xrandr.

mrmazda 01-21-2020 07:12 PM

In Debian Buster I put my xrandr script in /etc/X11/Xsession.d/.

thomasbb 01-22-2020 02:05 AM

The xrandr command was executed only when a terminal was launched... The System > Preferences > Startup Applications trick works. Many thanks for your help

thomasbb 01-24-2020 03:31 AM

Quote:

Originally Posted by mrmazda (Post 6081337)
In Debian Buster I put my xrandr script in /etc/X11/Xsession.d/.

By curiosity, I'm trying the /etc/X11/Xsession.d/ solution. Apparently, the script takes a specific name: https://manpages.debian.org/buster/x...sion.5.en.html

In my case, I chose 80custom_xrandrconfig with executable content:
Code:

#!/bin/bash
xrandr --output DVI-I-0 --auto --primary --output DVI-I-1 --auto --right-of DVI-I-0

But it doesn't work though, did I miss something?

mrmazda 01-24-2020 04:13 AM

Does it work if you run it from that location after X is started?

Right-of is the default position of a second display when automagic is used. Where is it located if you don't run xrandr to move it?

IME the name of the script doesn't matter, but executability does.

https://manpages.debian.org/buster/x...sion.5.en.html times out when I try to open it.

thomasbb 01-24-2020 05:24 AM

Quote:

Originally Posted by mrmazda (Post 6082344)
Does it work if you run it from that location after X is started?

Ran from there, it worked after login.
Quote:

Originally Posted by mrmazda (Post 6082344)
Right-of is the default position of a second display when automagic is used. Where is it located if you don't run xrandr to move it?

The command automagic isn't detected in a terminal
Quote:

Originally Posted by mrmazda (Post 6082344)
IME the name of the script doesn't matter, but executability does.
https://manpages.debian.org/buster/x...sion.5.en.html times out when I try to open it.

It lags a bit from here too...

mrmazda 01-24-2020 05:33 AM

There is no automagic command. Automagic means automatic X configuration on the fly at each X startup using neither xrandr nor xorg.con* files. What is output of
Code:

ls -l /etc/X11/Xsession.d/

thomasbb 01-24-2020 05:35 AM

Quote:

Originally Posted by mrmazda (Post 6082359)
There is no automagic command. Automagic means automatic X configuration on the fly at each X startup using neither xrandr nor xorg.con* files. What is output of
Code:

ls -l /etc/X11/Xsession.d/

Here is the list:
Code:

-rw-r--r-- 1 root root 1062 nov.  15  2017 20dbus_xdg-runtime
-rw-r--r-- 1 root root 2030 janv. 20  2012 20x11-common_process-args
-rw-r--r-- 1 root root  878 mars  30  2010 30x11-common_xresources
-rw-r--r-- 1 root root  389 mars  22  2012 35x11-common_xhost-local
-rw-r--r-- 1 root root  187 juil.  1  2008 40x11-common_xsessionrc
-rw-r--r-- 1 root root 1568 mai  20  2011 50x11-common_determine-startup
-rw-r--r-- 1 root root  743 mai    2  2018 55gnome-session_gnomerc
-rw-r--r-- 1 root root 1335 avril  2  2018 55numlockx
-rw-r--r-- 1 root root  664 mars  20  2014 55xfce4-session
-rw-r--r-- 1 root root  310 mars  1  2018 56xubuntu-session
-rw-r--r-- 1 root root  146 janv. 20  2012 60x11-common_localhost
-rw-r--r-- 1 root root  991 juin  21  2018 60x11-common_xdg_path
-rw-r--r-- 1 root root  71 août  29  2018 60xbrlapi
-rw-r--r-- 1 root root  336 mars  26  2014 70gconfd_path-on-session
-rw-r--r-- 1 root root 1541 mars  21  2015 70im-config_launch
-rw-r--r-- 1 root root  752 nov.  15  2017 75dbus_dbus-launch
-rwxr-xr-x 1 root root  96 janv. 24 10:18 80custom_xrandrconfig
-rwxr-xr-x 1 root root 2430 avril 29  2019 80im-switch
-rw-r--r-- 1 root root  880 déc.  1  2017 90gpg-agent
-rw-r--r-- 1 root root  368 mars  13  2018 90qt-a11y
-rw-r--r-- 1 root root  629 mars  30  2010 90x11-common_ssh-agent
-rw-r--r-- 1 root root  513 déc.  2  2015 95dbus_update-activation-env
-rw-r--r-- 1 root root  166 juil.  1  2008 99x11-common_start


mrmazda 01-24-2020 05:44 AM

Quote:

Originally Posted by thomasbb (Post 6082360)
-rwxr-xr-x 1 root root 2430 avril 29 2019 80im-switch[/CODE]

Is this a file you created? If so, what does it contain? I have no such file in Buster.

thomasbb 01-24-2020 05:50 AM

Quote:

Originally Posted by mrmazda (Post 6082362)
Is this a file you created? If so, what does it contain? I have no such file in Buster.

It's not from me, it seem to be linked to /usr/bin/im-switch. Here is the content:
Code:

[ -x /usr/bin/im-switch ] || return 0
#!/bin/sh
# Copyright (C) 2005 Kenshi Muto <kmuto@debian.org>
#  Modified for Debian package.
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# X Input method setup script

[ -x /usr/bin/im-switch ] || return 0

# Keep original values related to IM
_XIM=$XIM
_XIM_PROGRAM=$XIM_PROGRAM
_XIM_ARGS=$XIM_ARGS
_XMODIFIERS=$XMODIFIERS
_GTK_IM_MODULE=$GTK_IM_MODULE
_QT_IM_MODULE=$QT_IM_MODULE

# $LNG is locale <language>_<region> without .<encoding> and .<encoding>@EURO
LNG=${LC_ALL:-${LC_CTYPE:-${LANG}}}
LNG=${LNG%@*}
LNG=${LNG%.*}

[ -z "$LNG" ] && LNG="all_ALL" || true

echo "Setting IM through im-switch for locale=$LNG."

# Source first found configuration under $LNG locale
for f in    "$HOME/.xinput.d/${LNG}" \
            "$HOME/.xinput.d/all_ALL" \
            "/etc/X11/xinit/xinput.d/${LNG}" \
            "/etc/X11/xinit/xinput.d/all_ALL" \
            "/etc/X11/xinit/xinput.d/default" ; do
    if [ -f "$f" -a -r "$f" ]; then
        echo "Start IM through $f linked to $(readlink -f $f)."
        . "$f"
        break
    fi
done

unset LNG

# Revibe IM related environment if other values were set.
[ "$_XIM" ] && XIM=$_XIM || true
[ "$_XIM_PROGRAM" ] && XIM_PROGRAM=$_XIM_PROGRAM || true
[ "$_XIM_ARGS" ] && XIM_ARGS=$_XIM_ARGS || true
[ "$_XMODIFIERS" ] && XMODIFIERS=$_XMODIFIERS ||true
[ "$_GTK_IM_MODULE" ] && GTK_IM_MODULE=$_GTK_IM_MODULE || true
[ "$_QT_IM_MODULE" ] && QT_IM_MODULE=$_QT_IM_MODULE || true


[ -n "$GTK_IM_MODULE" ] && export GTK_IM_MODULE || true
[ -n "$QT_IM_MODULE" ] && export QT_IM_MODULE || true

# setup XMODIFIERS
[ -z "$XMODIFIERS" -a -n "$XIM" ] && XMODIFIERS="@im=$XIM" || true
[ -n "$XMODIFIERS" ] && export XMODIFIERS || true

# execute XIM_PROGRAM
if [ -n "$XIM_PROGRAM" -a -x "$XIM_PROGRAM" ]; then
        if [ -z "$XIM_PROGRAM_SETS_ITSELF_AS_DAEMON" ]; then
                {
                        sleep 10
                        eval "$XIM_PROGRAM $XIM_ARGS &" || true
                } &
        else
                {
                        sleep 10
                        eval "$XIM_PROGRAM $XIM_ARGS" || true
                } &
        fi
fi
# execute XIM_PROGRAM_XTRA
[ -n "$XIM_PROGRAM_XTRA" ] && eval "$XIM_PROGRAM_XTRA &" || true


mrmazda 01-24-2020 05:58 AM

Have you tried any other names for 80custom_xrandrconfig, such as 10custom_xrandrconfig?

thomasbb 01-24-2020 06:37 AM

Quote:

Originally Posted by mrmazda (Post 6082365)
Have you tried any other names for 80custom_xrandrconfig, such as 10custom_xrandrconfig?

Even with the new name, it doesn't work. But I'm not under Debian proper, maybe it's not wired exactly the same.
Anyhow, from the Startup Application window, the command works

mrmazda 01-24-2020 12:50 PM

Quote:

Originally Posted by thomasbb (Post 6082378)
maybe it's not wired exactly the same.

IME, that's quite possible. Not all distros use the same sequence of events to get X started. In openSUSE my script goes in /etc/X11/xinit/xinitrc.d/. Mageia uses another location that escapes my recollection ATM.

thomasbb 01-27-2020 05:56 AM

Another possible solution
 
Quote:

Originally Posted by mrmazda (Post 6082535)
IME, that's quite possible. Not all distros use the same sequence of events to get X started. In openSUSE my script goes in /etc/X11/xinit/xinitrc.d/. Mageia uses another location that escapes my recollection ATM.

So, a hands-on way to do is with a myResolution.desktop file in ~/.config/autostart:

Code:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=myResolution
Comment=automatically configures the screen resolution at startup
Exec=xrandr --output DVI-I-0 --auto --primary --output DVI-I-1 --auto --right-of DVI-I-0
StartupNotify=false
Terminal=false
Hidden=false



All times are GMT -5. The time now is 08:15 AM.