11

In xfce, I can run Settings -> Display to change my preferred output monitor. What I haven't found an option for is to have it automatically adjust to a change in available outputs.

For example, if I'm using a DVI display, but undock my laptop, XFCE will not automatically realize that I no longer have a working display and change the output. Gnome did do this, though I'm not sure through what service. I'd like to have some way of making sure I always have at least one working output automatically.

SIDE NOTE: This is related to another question of mine, If I just use a window manager and not a desktop environment, how do I get automatic dock/undock resolution updates?, but is for xfce, not any generic window manager.

6
$ xrandr --auto

From xrandr man page:

--auto: For connected but disabled outputs, this will enable them using their preferred mode (or, something close to 96dpi if they have no preferred mode). For disconnected but enabled outputs, this will disable them.

  • This work for me at least for my setup. – pl1nk May 21 '12 at 9:49
  • But this is a one-time command, not a service, right? – Aleksandr Dubinsky Jan 3 '17 at 12:54
0

This question is answered on Unix StackExchange: https://unix.stackexchange.com/questions/101809/how-can-i-automatically-update-my-monitor-layout-in-xfce/120945#120945 However, since it's not possible to mark this question as a duplicate of a question on another site, I'm just going to copy the answer here.


One way is to create an udev rule, but as I wanted something more portable, I have this bash script. It relies on inotifywait support, does not have some kind of loops and is considered efficient.

external-lcd.sh

#!/bin/sh
# inspired of:                                                                                            
#   http://unix.stackexchange.com/questions/4489/a-tool-for-automatically-applying-randr-configuration-   when-external-display-is-p                                                                                
#   http://ozlabs.org/~jk/docs/mergefb/                                                                   
#   http://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes/181543#181543  

export MONITOR2=/sys/class/drm/card0-VGA-1/status                                                         

while inotifywait -e modify,create,delete,open,close,close_write,access $MONITOR2;                        

dmode="$(cat $MONITOR2)"                                                                                  

do                                                                                                        
    if [ "${dmode}" = disconnected ]; then                                                                
         /usr/bin/xrandr --auto                                                                           
         echo "${dmode}"                                                                                  
    elif [ "${dmode}" = connected ];then                                                                  
         /usr/bin/xrandr --output VGA1 --auto --right-of LVDS1                                            
         echo "${dmode}"                                                                                  
    else /usr/bin/xrandr --auto                                                                           
         echo "${dmode}"                                                                                  
    fi                                                                                                    
done 

Don't forget to make the file executable (chmod +x external-lcd.sh). Then just start it whenever you launch your DE.

I am using this on archlinux so I think it should work. You can change xrandr parameters or swap it to use arandr configurations.

-1

There is no such option since the technology behind desktop agnostic hardware event detection (udev) is rather new for a hobbyist project like xfce.

You might get some good results digging into D-Bus and udev. Have a look at udev not running remove events for starters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.