Announcement

Collapse
No announcement yet.

xrandr changing the desktop layout?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    xrandr changing the desktop layout?

    So I'm trying to get my laptop to work the way i want when "docked" - which means at my desk, plugged in, lid closed, external monitor connected. Kscreen can't do it right, so I've turned it off.

    I've been having trouble with the external because although it correctly reports it is capable of 3840x1600@75Hz, the HDMI connection I'm using is only capable of 60Hz. I've written a script that works (mostly) but is only run when I manually run it (for now).

    What's happening is if I "dock" and run the script, all is well. If I open the lid and re-enable the laptop monitor as primary (a condition I call "not_docked"), it works but leaves the laptop without a desktop background.

    The oddity is when I first boot up with the lid open (because currently the laptop monitor is primary by default) the laptop monitor is in "Desktop layout" but the external monitor is in "Folder view". Then I close the lid and run my script and the whole desktop (in "desktop layout" mode) moves to the secondary monitor - which is fine. However, when I open the lid and re-run the script to re-enable the laptop monitor as the primary, the laptop monitor returns to Desktop layout but has no background image and the external monitor switched to Folder view (but the folder is not visible)
    and it does have a background.

    So it seems that using xrandr is effecting desktop layout and some other settings. The command in question: xrandr --output eDP-1 --auto --primary --output DP-3 --mode 3840x1600 --rate 60.00 --right-of eDP-1

    The point of this exercise is to make the laptop detect and change screen settings for various setups. The script seems to work manually except for the above. I can't wait until we get Wayland.

    Here's the entire script for reference.
    Code:
    #!/bin/bash
    #
    
    docked () {
    xrandr --output eDP-1 --off --output DP-3 --mode 3840x1600 --rate 60.00 --primary
    }
    
    
    not_docked () {
    xrandr --output eDP-1 --auto --primary --output DP-3 --mode 3840x1600 --rate 60.00 --right-of eDP-1
    }
    
    
    not_attached () {
    xrandr --output eDP-1 --auto --primary
    }
    
    
    mode="3840x1600"
    mode0=`xrandr | grep -n -w "DP-3" | awk -F: '{ print $1 }'`
    mode1=`expr $mode0 + 1`
    modeX=199
    
    
    if [[ `cat /sys/class/drm/card0-DP-3/status` = "disconnected" ]]; then
            not_attached
        else
            if [[ `cat /sys/class/power_supply/AC/online` -eq 1 ]]; then
                if [[ -n `xrandr | sed -n "$mode1","$modeX""p" | grep "$mode"` ]]; then
                    if [[ `cat /proc/acpi/button/lid/LID0/state | awk '{ print $2 }'` = "closed" ]]; then
                            docked
                        else
                            not_docked
    fi; fi; fi; fi
    
    
    exit 0
    Last edited by oshunluvr; Jan 30, 2019, 01:31 PM.

    Please Read Me
Working...
X