diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-03 01:06:47 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-03 01:06:47 +0200 |
commit | b51821368c23ee017317ae9fe16e797662e1a1ba (patch) | |
tree | 219091df543ea40bdb6a86498fad005a7ad4685f | |
parent | move some issues from 'future stuff' into the issue tracker on github (diff) | |
download | blueshift-b51821368c23ee017317ae9fe16e797662e1a1ba.tar.gz blueshift-b51821368c23ee017317ae9fe16e797662e1a1ba.tar.bz2 blueshift-b51821368c23ee017317ae9fe16e797662e1a1ba.tar.xz |
add multi-display support when listing moditors and getting icc profile
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/blueshift_iccprofile.c | 12 | ||||
-rw-r--r-- | src/blueshift_idcrtc.c | 12 | ||||
-rw-r--r-- | src/icc.py | 14 | ||||
-rw-r--r-- | src/monitor.py | 22 |
4 files changed, 38 insertions, 22 deletions
diff --git a/src/blueshift_iccprofile.c b/src/blueshift_iccprofile.c index fb2aa7b..b96e682 100644 --- a/src/blueshift_iccprofile.c +++ b/src/blueshift_iccprofile.c @@ -45,14 +45,12 @@ static xcb_generic_error_t* error; */ int main(int argc, char** argv) { + char* display = NULL; xcb_screen_iterator_t iter; int screen_count; xcb_screen_t* screens; int screen_i; - (void) argc; - (void) argv; - /* To get all ICC profiles, which are binary encoded, we have to connect to the display and for each screen look for @@ -71,8 +69,12 @@ int main(int argc, char** argv) /* This acquires a connection to the X display indicated by the DISPLAY - environ variable. */ - connection = xcb_connect(NULL, NULL); + environ variable, or as indicated + by the first command line argument + if existent. */ + if (argc > 1) + display = *(argv + 1); + connection = xcb_connect(display, NULL); /* Get screen information */ diff --git a/src/blueshift_idcrtc.c b/src/blueshift_idcrtc.c index 67ead56..c1f73b6 100644 --- a/src/blueshift_idcrtc.c +++ b/src/blueshift_idcrtc.c @@ -58,6 +58,7 @@ static xcb_generic_error_t* error; */ int main(int argc, char** argv) { + char* display = NULL; xcb_randr_query_version_cookie_t version_cookie; xcb_randr_query_version_reply_t* randr_version; xcb_screen_iterator_t iter; @@ -66,16 +67,17 @@ int main(int argc, char** argv) int screen_i; int i; - (void) argc; - (void) argv; - /* Get X connection */ /* This acquires a connection to the X display indicated by the DISPLAY - environ variable. */ - connection = xcb_connect(NULL, NULL); + environ variable, or as indicated + by the first command line argument + if existent. */ + if (argc > 1) + display = *(argv + 1); + connection = xcb_connect(display, NULL); /* Check RandR protocol version */ @@ -42,23 +42,29 @@ def load_icc(pathname): return parse_icc(file.read()) -def get_current_icc(): +def get_current_icc(display = None): ''' Get all currently applied ICC profiles as profile applying functions + @param display:str? The display to use, `None` for the current one @return list<(screen:int, monitor:int, profile:()→void)> List of used profiles ''' - return [(screen, monitor, parse_icc(profile)) for screen, monitor, profile in get_current_icc_raw()] + return [(screen, monitor, parse_icc(profile)) for screen, monitor, profile in get_current_icc_raw(display)] -def get_current_icc_raw(): +def get_current_icc_raw(display = None): ''' Get all currently applied ICC profiles as raw profile data + @param display:str? The display to use, `None` for the current one @return list<(screen:int, monitor:int, profile:bytes())> List of used profiles ''' + # Generate command line arguments to execute + command = [LIBEXECDIR + os.sep + 'blueshift_iccprofile'] + if display is not None: + command.append(display) # Spawn the libexec blueshift_iccprofile - process = Popen([LIBEXECDIR + os.sep + 'blueshift_iccprofile'], stdout = PIPE) + process = Popen(command, stdout = PIPE) # Wait for the child process to exit and gather its output to stdout lines = process.communicate()[0].decode('utf-8', 'error').split('\n') # Ensure the tha process has exited diff --git a/src/monitor.py b/src/monitor.py index 36f9235..d115d40 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -500,27 +500,33 @@ class Output: return '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s, EDID: %s]' % rc -def list_screens(method = 'randr'): +def list_screens(method = 'randr', display = None): ''' Retrieve informantion about all screens, outputs and CRTC:s - @param method:str The listing method: 'randr' for RandR (under X), + @param method:str The listing method: 'randr' for RandR (under X), 'drm' for DRM (under TTY) - @return :Screens An instance of a datastructure with the relevant information + @param display:str? The display to use, `None` for the current one + @return :Screens An instance of a datastructure with the relevant information ''' - if method == 'randr': return list_screens_randr() + if method == 'randr': return list_screens_randr(display = display) if method == 'drm': return list_screens_drm() raise Exception('Invalid method: %s' % method) -def list_screens_randr(): +def list_screens_randr(display = None): ''' Retrieve informantion about all screens, outputs and CRTC:s, using RandR - @return :Screens An instance of a datastructure with the relevant information + @param display:str? The display to use, `None` for the current one + @return :Screens An instance of a datastructure with the relevant information ''' - # Spawn the executeable library blueshift_idcrtc - process = Popen([LIBEXECDIR + os.sep + 'blueshift_idcrtc'], stdout = PIPE) + # Generate command line arguments to execute + command = [LIBEXECDIR + os.sep + 'blueshift_idcrtc'] + if display is not None: + command.append(display) + # Spawn the executable library blueshift_idcrtc + process = Popen(command, stdout = PIPE) # Wait for the child process to exit and gather its output to stdout lines = process.communicate()[0].decode('utf-8', 'error').split('\n') # Ensure that the child process has exited |