Friday, September 3, 2010

Xrandr + Xmonad Session

For my 'xmonad-session' I use a bunch of scripts to easilly get needed monitor setup for my dual head laptop graphic card.

$ l bin/xrandr-*
bin/xrandr-bigdesktop -> xrandr-bigdesktop-LVDS_DVI

$ cat bin/xrandr-bigdesktop-VGA_DVI 

xrandr --output LVDS --off
xrandr --output HDMI-0 --off
xrandr --output VGA-0 --auto \
       --output DVI-0 --auto --primary --right-of VGA-0

Symlink 'xrandr-bigdesktop' is my default ... that is my laptop display is turned on and it is primary one and if something is connected to DVI-0 it would be used as secondary monitor. This symlink is called from my 'xmonad-session' startup script called by CDM in my case, so after boot I got LVDS_DVI setup (if there is nothing physically connected to DVI-0 I got properly just one monitor laptop LVDS setup, xrandr command will not fail and xmonad later starts correctly in 'one monitor' layout).

In office I've got 2 external LCD monitors so my preffered layout there is 'bin/xrandr-bigdesktop-VGA_DVI'. After I start my default LVDS_DVI session I just run in the terminal:

$ xrandr-bigdesktop-VGA_DVI && xmonad-session-repair

xsetroot -solid black

#nitrogen --restore

killall trayer
trayer --edge top --align right \
       --width 10 --widthtype request --height 19 --heighttype pixel \
       --SetDockType true --SetPartialStrut true \
       --transparent true --alpha 0 --tint 0x000000 \
       --expand true &

xmonad --restart

When I need to move e.g. to meeting room I usually just grab my laptop and run :). So after that I have just dead laptop screen. What I do? I switch to some tty let's say first one Ctrl+Alt+F1 and then after I login and not forget to put myself into console in CDM menu I do:

# to be able to communicate with X server
$ export DISPLAY=:0.0

# because CDM doesn't load profile
$ . .profile

$ xrandr-bigdesktop-LVDS_DVI
xrandr: Configure crtc 0 failed
xrandr: cannot find crtc for output LVDS

# let's try sleep first for couple of seconds
# in meantime switch to xtty (usually it would be 7th = Alt+f7 but depends how you're starting X server)
# and wait... until your LVDS is back
$ sleep 5 && xrandr-bigdesktop-LVDS_DVI

I've configured some xmonad key bindings so I don't have to do anything above manually.

-- xrandr
((myModMask, xK_F10), spawn "xrandr-bigdesktop-LVDS_DVI && xmonad-session-repair"),
((myModMask, xK_F11), spawn "xrandr-bigdesktop-LVDS_VGA && xmonad-session-repair"),
((myModMask, xK_F12), spawn "xrandr-bigdesktop-VGA_DVI && xmonad-session-repair")


  1. Thank you! I don't know why I didn't find this post sooner (believe me, I looked!) You just helped me *so* much. :-) I combined your solution with this approach to handling status bar widths as percentages [0].


  2. Ultimately, the on line casino is promoting excitement, which is comprised of hope and variance. Even though a slot might have a modest home benefit from management’s perspective, corresponding to 4 p.c, it can possibly} and infrequently does win all of George’s Tuesday night time bankroll briefly order. Featuring a 24-foot video wall, thirteen betting kiosks, drink specials, and 29 HDTVs for viewing the most effective games—our Barstool Sportsbook has 점보카지노 every thing you want for a great expertise. Winning combos will criss-cross, use diagonals, Ms, Ws, squigglies, curly-cues, and different directions, depending on the sport.