diff options
-rw-r--r-- | info/blueshift.texinfo | 10 | ||||
-rw-r--r-- | src/monitor.py | 24 |
2 files changed, 22 insertions, 12 deletions
diff --git a/info/blueshift.texinfo b/info/blueshift.texinfo index 36717be..40c7339 100644 --- a/info/blueshift.texinfo +++ b/info/blueshift.texinfo @@ -458,9 +458,13 @@ server, invoke the @code{randr} function; @code{print_curves} can be used to print the curves to stdout instead (for debugging). These functions apply the curves to all -monitors, put you can also use select monitors -by specifying each monitor in as separate -arguments. The monitors are indexed from zero. +monitors in the default screen (screen 0), put +you can also use select monitors by specifying +each monitor in as separate arguments. The +monitors are indexed from zero. The screen by +can be selected by adding the argument +@code{screen = X}, where @code{X} is the +index of the screen. If you want to write your own curve flushing fucntion @code{translate_to_integers} can be diff --git a/src/monitor.py b/src/monitor.py index 6a35ef4..87a2290 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -23,7 +23,7 @@ from curve import * LIBDIR = 'bin' sys.path.append(LIBDIR) -randr_opened = False +randr_opened = None def translate_to_integers(): @@ -47,28 +47,31 @@ def close_c_bindings(): Close all C bindings and let them free resources and close connections ''' global randr_opened - if randr_opened: + if randr_opened is not None: from blueshift_randr import randr_close - randr_opened = False + randr_opened = None randr_close() -def randr(*crtcs): +def randr(*crtcs, screen = 0): ''' Applies colour curves using the X11 extension randr @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_randr import randr_open, randr_apply + from blueshift_randr import randr_open, randr_apply, randr_close global randr_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 not randr_opened: - if randr_open(0) == 0: ## TODO support specifying screen - randr_opened = True + if (randr_opened is None) or not (randr_opened == screen): + if randr_opened is not None: + randr_close() + if randr_open(screen) == 0: + randr_opened = screen else: sys.exit(1) try: @@ -78,9 +81,12 @@ def randr(*crtcs): pass # Happens on exit by TERM signal -def print_curves(*crtcs): +def print_curves(*crtcs, screen = 0): ''' Prints the curves to stdout + + @param *crtcs Dummy parameter + @param screen Dummy parameter ''' (R_curve, G_curve, B_curve) = translate_to_integers() print(R_curve) |