[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [STUMP] Multiple monitors
From: |
Michael Raskin |
Subject: |
Re: [STUMP] Multiple monitors |
Date: |
Fri, 03 Sep 2010 21:25:18 +0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100816 Thunderbird/2.0.0.12; Google GoogleBot |
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...
Re: [STUMP] Multiple monitors, Michael Raskin, 2010/09/03
Re: [STUMP] Multiple monitors, Johan Claesson, 2010/09/04