At Fri, 03 Sep 2010 21:25:18 +0400, Michael Raskin wrote: > > On 09/03/2010 09:14 PM, Eric Larson wrote: > > Since I'm using it on my laptop with an external monitor, I also wrote > > a quick script that I can run when I unplug my external monitor. > > > > from subprocess import call > > import re > > import os > > > > class Randr(object): > > > > def __init__(self): > > self.screens = { > > > > 'monitor': 'DVI1', > > 'laptop': 'LVDS1' > > } > > > > def is_connected(self, fn): > > for line in open(fn, 'r'): > > if line.startswith('%s connected' % self.screens['monitor']): > > return True > > > > def run(self): > > fn = '.tmp_buffer_python_xstart' > > p = call(['xrandr', '-q'], stdout=open(fn, 'w+')) > > if self.is_connected(fn): > > xrandr_cmd = [ > > 'xrandr', '--output', self.screens['laptop'], # '--off' > > '--right-of', self.screens['monitor'] > > ] > > p = call(xrandr_cmd) > > p2 = call(['xrandr', '--output', self.screens['monitor'], > > '--mode', '1680x1050']) > > os.remove(fn) > > > > if __name__ == '__main__': > > r = Randr() > > r.run() > > #! /bin/sh > xrandr -q | grep "VGA-0 connected" && > xrandr --output VGA-0 --right-of LVDS --preferred & > xrandr -q | grep "VGA-0 connected" || > xrandr --output VGA-0 --off & > > Seems to do the same and is somewhat simpler...
The other thing the script does is set the resolution. That said, I suspected that a simple shell script solution would be possible. When all you have is a hammer... ;) Eric _______________________________________________ Stumpwm-devel mailing list Stumpwm-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/stumpwm-devel