Hi,

qtile is really a great window manager. I like the idea the possibility to 
directly use Python code in the config file and have it executed by qtile.

However, there is one thing which does not work - even after hours of 
research attempts: the setup of several monitors just won't properly work. 
I have a laptop and change monitor setups several times a day by plugging 
in or unplugging monitors. Most of the time I use the screen of the laptop 
and one external monitor, sometimes I use the laptop screen and two 
external monitors, sometimes only laptop screen.

I have the proper xrandr commands at the ready. However, two scenarios do 
not work:

1. When I startup, the proper xrandr command will be executed. The xrandr 
command needs to be executed because qtile will automatically detect only 
one the laptop screen, if the xranrd command is not executed. However, I 
still have to manually restart qtile by pressing cntr+mod+r after the 
execution of the xrandr command.

2. When I change the setup - say physically unplug one of the two monitors 
- the monitor setup is messed up in a way that I have to restart qtile.

I am working with a combination of "@hook.subscribe.startup" and 
"@hook.substribe.screen_change". The startup hook works, the screen_change 
hook does not work. What does parameter "xproto.randr.ScreenChangeNotify" 
<http://docs.qtile.org/en/latest/manual/ref/hooks.html?highlight=screen_change#libqtile.hook.subscribe.screen_change>
 
for the screen_change hook mean? How can I use this parameter?

This is the code which I use in qtile's config file:

LAPTOP_SCREEN_CONNECTED = 'eDP1 connected'
LEFT_MONITOR_CONNECTED = 'DP1-1 connected'
RIGHT_MONITOR_CONNECTED = 'DP1-2 connected'

def get_xrandr_output() -> str:
    return subprocess.check_output(['xrandr']).decode('utf-8')

def three_monitors_connected(xrandr_output: str) -> bool:
    return (LAPTOP_SCREEN_CONNECTED
            and LEFT_MONITOR_CONNECTED
            and RIGHT_MONITOR_CONNECTED) in xrandr_output

def two_monitors_connected(xrandr_output: str) -> bool:
    return (LAPTOP_SCREEN_CONNECTED
            and LEFT_MONITOR_CONNECTED) in xrandr_output
            
@hook.subscribe.startup
def load_proper_monitor_setup() -> None:
    xrandr_output = get_xrandr_output()
    if three_monitors_connected(xrandr_output):
        subprocess.run(['xrandr --output DP1-1 --primary --right-of eDP1 
--output DP1-2 --right-of DP1-1'], shell=True)

    elif two_monitors_connected(xrandr_output):
        subprocess.run(['xrandr --output eDP1 --output DP1-1 --primary 
--right-of eDP1'], shell=True)
    else:
        pass

@hook.subscribe.screen_change
def my_restart(ev):
    lazy.restart()



This is the output of xrandr:

Screen 0: minimum 8 x 8, current 5520 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 
280mm x 160mm
   1920x1080     60.03*+  59.93  
   1680x1050     59.88  
   1600x1024     60.17  
   1400x1050     59.98  
   1600x900      60.00    59.95    59.82  
   1280x1024     60.02  
   1440x900      59.89  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1368x768      60.00    59.88    59.85  
   1360x768      59.80    59.96  
   1280x800      59.81    59.91  
   1152x864      60.00  
   1280x720      59.86    60.00    59.74  
   1024x768      60.00  
   1024x576      60.00    59.90    59.82  
   960x540       60.00    59.63    59.82  
   800x600       60.32    56.25  
   864x486       60.00    59.92    59.57  
   640x480       59.94  
   720x405       59.51    60.00    58.99  
   640x360       59.84    59.32    60.00  
DP1 disconnected (normal left inverted right x axis y axis)
DP1-1 connected primary 1680x1050+1920+0 (normal left inverted right x axis 
y axis) 470mm x 300mm
   1680x1050     59.95*+
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
   720x400       70.08  
DP1-2 connected 1920x1080+3600+0 (normal left inverted right x axis y axis) 
530mm x 300mm
   1920x1080     60.00*+  50.00    59.94  
   1680x1050     59.88  
   1280x1024     75.02    60.02  
   1440x900      59.90  
   1280x960      60.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
DP1-3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)


Thank you so much for your assistance and have a nice day.

Sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/71f36cb1-edab-4271-b41a-22b428f2eb65n%40googlegroups.com.

Reply via email to