diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-21 14:50:00 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-21 14:50:00 +0100 |
commit | fc49478a082a300940878e5de72fa2055ca7b3b0 (patch) | |
tree | 2ec9eae42025aebb1415de2a4715f12c11f26c11 /src/monitor.py | |
parent | remove old variables (diff) | |
download | blueshift-fc49478a082a300940878e5de72fa2055ca7b3b0.tar.gz blueshift-fc49478a082a300940878e5de72fa2055ca7b3b0.tar.bz2 blueshift-fc49478a082a300940878e5de72fa2055ca7b3b0.tar.xz |
add vidmode support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/monitor.py')
-rw-r--r-- | src/monitor.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/monitor.py b/src/monitor.py index 87a2290..ecc827b 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -24,6 +24,7 @@ LIBDIR = 'bin' sys.path.append(LIBDIR) randr_opened = None +vidmode_opened = None def translate_to_integers(): @@ -46,11 +47,15 @@ def close_c_bindings(): ''' Close all C bindings and let them free resources and close connections ''' - global randr_opened + global randr_opened, vidmode_opened if randr_opened is not None: from blueshift_randr import randr_close randr_opened = None randr_close() + if vidmode_opened is not None: + from blueshift_vidmode import vidmode_close + vidmode_opened = None + vidmode_close() def randr(*crtcs, screen = 0): @@ -81,6 +86,34 @@ def randr(*crtcs, screen = 0): pass # Happens on exit by TERM signal +def vidmode(*crtcs, screen = 0): + ''' + Applies colour curves using the X11 extension vidmode + + @param *crtcs The CRT controllers to use, all are used if none are specified + @param screen The screen that the monitors belong to + ''' + from blueshift_vidmode import vidmode_open, vidmode_apply, vidmode_close + global vidmode_opened + crtcs = sum([1 << i for i in list(crtcs)]) + if crtcs == 0: + crtcs = (1 << 64) - 1 + + (R_curve, G_curve, B_curve) = translate_to_integers() + if (vidmode_opened is None) or not (vidmode_opened == screen): + if vidmode_opened is not None: + vidmode_close() + if vidmode_open(screen) == 0: + vidmode_opened = screen + else: + sys.exit(1) + try: + if not vidmode_apply(crtcs, R_curve, G_curve, B_curve) == 0: + sys.exit(1) + except OverflowError: + pass # Happens on exit by TERM signal + + def print_curves(*crtcs, screen = 0): ''' Prints the curves to stdout |