diff --git a/powerline/bindings/wm/__init__.py b/powerline/bindings/wm/__init__.py index a92079eb0..b8e881a21 100644 --- a/powerline/bindings/wm/__init__.py +++ b/powerline/bindings/wm/__init__.py @@ -62,7 +62,7 @@ def get_i3_connection(): conn = i3ipc.Connection() return conn -def get_randr_outputs(): +def get_randr_outputs(d = None, window = None): '''Return all randr outputs as a list. Outputs are represented by a dictionary with at least the ``name``, ``width``, @@ -72,44 +72,66 @@ def get_randr_outputs(): from Xlib import X, display from Xlib.ext import randr - d = display.Display() + d = d or display.Display() s = d.screen() - window = s.root.create_window(0, 0, 1, 1, 1, s.root_depth) - outputs = randr.get_screen_resources(window).outputs + if not window: + window = s.root.create_window(0, 0, 1, 1, 1, s.root_depth) + ress = randr.get_screen_resources(window) + outputs = ress.outputs primary = randr.get_output_primary(window).output - outputs = [(o, randr.get_output_info(window, o, 0)) for o in outputs] + npos = 0 + modes = { } + for mode in ress.modes: + data = mode._data + data['name'] = ress.mode_names[npos:npos + mode.name_length] + npos += data['name_length'] + modes[data['id']] = data + + outputs = [(o, d.xrandr_get_output_info(o, ress.config_timestamp)) for o in outputs] outputs = [{ 'name': o[1].name, - 'crtc': randr.get_crtc_info(window, o[1].crtc, 0) if not o[1].connection else None, + 'crtc_id': o[1].crtc, + 'crtc': d.xrandr_get_crtc_info(o[1].crtc, ress.config_timestamp)if o[1].crtc else None, 'primary': ' primary' if o[0] == primary else None, # space intended for bw comp - 'status': ['on', 'off'][o[1].connection], + 'connection': o[1].connection, + 'status': ['on', 'off'][o[1].crtc == 0], + 'modes': [modes[i] for i in o[1].modes], + 'mode_ids': o[1].modes, + 'crtcs': o[1].crtcs, + 'id': o[0] } for o in outputs] # only return connectad outputs outputs = [{ 'name': o['name'], 'primary': o['primary'], + 'crtc_id': o['crtc_id'], 'x': o['crtc'].x if o['crtc'] else None, 'y': o['crtc'].y if o['crtc'] else None, 'height': o['crtc'].height if o['crtc'] else None, 'width': o['crtc'].width if o['crtc'] else None, 'crtc': o['crtc'], - 'status': o['status'] + 'status': o['status'], + 'connection': not o['connection'], + 'modes': o['modes'], + 'mode_ids': o['mode_ids'], + 'crtcs': o['crtcs'], + 'id': o['id'] } for o in outputs] return outputs def get_connected_randr_outputs(pl): - '''Iterate over randr outputs + '''Iterate over randr outputs. Yields all connected outputs that are not ``off``. Outputs are represented by a dictionary with at least the ``name``, ``width``, ``height``, ``primary``, ``x`` and ``y`` keys. ''' try: for o in get_randr_outputs(): - if o['status'] == 'on': + if o['connection'] and o['status'] == 'on': yield o except ImportError: diff --git a/powerline/config_files/colorschemes/default.json b/powerline/config_files/colorschemes/default.json index 45f9aea65..208a5941b 100644 --- a/powerline/config_files/colorschemes/default.json +++ b/powerline/config_files/colorschemes/default.json @@ -9,63 +9,65 @@ "level:3_bold": { "fg": "level:3_fg", "bg": "level:3_bg", "attrs": ["bold"] }, "background": "level:3", "background:divider": "level:3", - "information:additional": "level:3", - "information:regular": "level:3", - "information:highlighted": "level:3_bold", - "information:priority": { "fg": "brightyellow", "bg": "level:3_bg" }, - "warning:regular": { "fg": "level:2_fg", "bg": "brightred", "attrs": ["bold"] }, + + "attached_clients": "level:3", + "battery": "level:3", + "battery:0": "level:3", + "battery:100": { "fg": "red", "bg": "level:3_bg" }, + "battery:full": { "fg": "mediumgreen", "bg": "level:3_bg" }, + "battery:online": { "fg": "yellow", "bg": "level:3_bg" }, + "battery:unknown": { "fg": "yellow", "bg": "level:3_bg" }, + "battery_gamify_gradient": { "fg": "white_red", "bg": "level:3_bg" }, + "battery_gradient": { "fg": "white_red", "bg": "level:3_bg" }, + "clip": "level:2", + "cpu_load_percent": "level:3", + "cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "level:3_bg" }, "critical:failure": { "fg": "level:2_fg", "bg": "darkestred" }, "critical:success": { "fg": "level:2_fg", "bg": "darkestgreen" }, - "generic_shell": "level:3", - "session": "level:2_bold", + "cwd": "level:2", + "cwd:current_folder": "level:2_bold", + "cwd:divider": "level:2", "date": "level:2", - "time": "level:1_bold", - "time:divider": "level:1", - "fuzzy_time": "level:1", "email_alert": { "bg": "level:3_bg", "fg": "brightred", "attrs": ["bold"] }, "email_alert_gradient": { "bg": "level:3_bg", "fg": "yellow_orange_red", "attrs": ["bold"] }, - "hostname": "level:1", - "clip": "level:2", - "weather": "level:3", - "weather_temp_gradient": { "fg": "blue_red", "bg": "level:3_bg" }, - "weather:condition_hot": { "fg": "khaki1", "bg": "level:3_bg" }, - "weather:condition_snowy": { "fg": "skyblue1", "bg": "level:3_bg" }, - "weather:condition_rainy": { "fg": "skyblue1", "bg": "level:3_bg" }, - "uptime": "level:3", + "environment": "level:3", "external_ip": "level:3", + "fuzzy_time": "level:1", + "generic_shell": "level:3", + "hostname": "level:1", + "information:additional": "level:3", + "information:highlighted": "level:3_bold", + "information:priority": { "fg": "brightyellow", "bg": "level:3_bg" }, + "information:regular": "level:3", "internal_ip": "level:3", "network_load": "level:3", "network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "level:3_bg" }, + "output": "level:2", + "player": { "fg": "level:3_fg", "bg": "level:3_bg" }, + "quality_gradient": { "fg": "white_red", "bg": "level:3_bg" }, + "session": "level:2_bold", + "srot": "level:2", + "superuser": { "fg": "level:1_fg", "bg": "brightred", "attrs": ["bold"] }, "system_load": "level:3", "system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "level:3_bg" }, - "volume_gradient": { "fg": "white_red", "bg": "level:3_bg" }, - "quality_gradient": { "fg": "white_red", "bg": "level:3_bg" }, - "wireless:gradient": { "fg": "white_red", "bg": "level:3_bg" }, - "wireless:none": "level:3", - "environment": "level:3", - "cpu_load_percent": "level:3", - "cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "level:3_bg" }, - "battery": "level:3", - "battery_gradient": { "fg": "white_red", "bg": "level:3_bg" }, - "battery_gamify_gradient": { "fg": "white_red", "bg": "level:3_bg" }, - "battery:100": { "fg": "red", "bg": "level:3_bg" }, - "battery:0": "level:3", - "battery:online": { "fg": "yellow", "bg": "level:3_bg" }, - "battery:full": { "fg": "mediumgreen", "bg": "level:3_bg" }, - "battery:unknown": { "fg": "yellow", "bg": "level:3_bg" }, - "player": { "fg": "level:3_fg", "bg": "level:3_bg" }, + "time": "level:1_bold", + "time:divider": "level:1", + "uptime": "level:3", "user": "level:1_bold", - "superuser": { "fg": "level:1_fg", "bg": "brightred", "attrs": ["bold"] }, - "attached_clients": "level:3", "vcsinfo": "level:3", "vcsinfo:branch": "level:3_bold", - "vcsinfo:dirty": { "fg": "brightorange", "bg": "level:3_bg" }, "vcsinfo:clean": { "fg": "brightgreen", "bg": "level:3_bg" }, + "vcsinfo:dirty": { "fg": "brightorange", "bg": "level:3_bg" }, "vcsinfo:divider": "level:3", - "cwd": "level:2", - "cwd:current_folder": "level:2_bold", - "cwd:divider": "level:2", "virtualenv": "level:3", - "srot": "level:2" + "volume_gradient": { "fg": "white_red", "bg": "level:3_bg" }, + "warning:regular": { "fg": "level:2_fg", "bg": "brightred", "attrs": ["bold"] }, + "weather": "level:3", + "weather:condition_hot": { "fg": "khaki1", "bg": "level:3_bg" }, + "weather:condition_rainy": { "fg": "skyblue1", "bg": "level:3_bg" }, + "weather:condition_snowy": { "fg": "skyblue1", "bg": "level:3_bg" }, + "weather_temp_gradient": { "fg": "blue_red", "bg": "level:3_bg" }, + "wireless:gradient": { "fg": "white_red", "bg": "level:3_bg" }, + "wireless:none": "level:3" } } diff --git a/powerline/config_files/colorschemes/pdb/solarized.json b/powerline/config_files/colorschemes/pdb/solarized.json deleted file mode 100644 index 2e1c787c1..000000000 --- a/powerline/config_files/colorschemes/pdb/solarized.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "groups": { - "stack_depth": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] } - } -} diff --git a/powerline/config_files/colorschemes/shell/solarized.json b/powerline/config_files/colorschemes/shell/solarized.json deleted file mode 100644 index a07afe64a..000000000 --- a/powerline/config_files/colorschemes/shell/solarized.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "Solarized dark for shell", - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": ["bold"] } - }, - "mode_translations": { - "vicmd": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] } - } - } - } -} diff --git a/powerline/config_files/colorschemes/solarized.json b/powerline/config_files/colorschemes/solarized.json deleted file mode 100644 index 39c1f452c..000000000 --- a/powerline/config_files/colorschemes/solarized.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "Solarized dark", - "groups": { - "information:additional": { "fg": "solarized:base2", "bg": "solarized:base01" }, - "information:regular": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] }, - "information:highlighted": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"]}, - "information:priority": { "fg": "solarized:base3", "bg": "solarized:yellow" }, - "warning:regular": { "fg": "solarized:base3", "bg": "solarized:red" }, - "critical:failure": { "fg": "solarized:base3", "bg": "solarized:red" }, - "critical:success": { "fg": "solarized:base3", "bg": "solarized:green" }, - "background": { "fg": "solarized:base3", "bg": "solarized:base02" }, - "background:divider": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "user": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }, - "virtualenv": { "fg": "solarized:base3", "bg": "solarized:green" }, - "vcsinfo": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "vcsinfo:dirty": { "fg": "solarized:yellow", "bg": "solarized:base02" }, - "vcsinfo:clean": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "email_alert_gradient": { "fg": "solarized:base3", "bg": "yellow_orange_red" }, - "email_alert": "warning:regular", - "cwd": "information:additional", - "cwd:current_folder": "information:regular", - "cwd:divider": { "fg": "solarized:base1", "bg": "solarized:base01" }, - "network_load": { "fg": "solarized:base1", "bg": "solarized:base03" }, - "network_load:divider": "network_load", - "network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base03" }, - "network_load_sent_gradient": "network_load_gradient", - "network_load_recv_gradient": "network_load_gradient", - "hostname": { "fg": "solarized:base3", "bg": "solarized:base01" }, - "environment": { "fg": "solarized:base3", "bg": "solarized:green" }, - "attached_clients": { "fg": "solarized:base3", "bg": "solarized:green" }, - "date": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "time": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": ["bold"] }, - "time:divider": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "system_load": { "fg": "solarized:base1", "bg": "solarized:base03" }, - "weather_temp_gradient": { "fg": "blue_red", "bg": "solarized:base03" }, - "weather": { "fg": "solarized:base1", "bg": "solarized:base03" }, - "uptime": { "fg": "solarized:base1", "bg": "solarized:base03" } - } -} diff --git a/powerline/config_files/colorschemes/vim/solarized.json b/powerline/config_files/colorschemes/vim/solarized.json deleted file mode 100644 index 3ab671bf0..000000000 --- a/powerline/config_files/colorschemes/vim/solarized.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "name": "Solarized dark for vim", - "groups": { - "information:additional": { "fg": "solarized:base2", "bg": "solarized:base01" }, - "information:unimportant": { "fg": "solarized:base3", "bg": "solarized:base01" }, - "background": { "fg": "solarized:base3", "bg": "solarized:base02" }, - "background:divider": { "fg": "solarized:base00", "bg": "solarized:base02" }, - "mode": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": ["bold"] }, - "visual_range": { "fg": "solarized:green", "bg": "solarized:base3", "attrs": ["bold"] }, - "modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base01", "attrs": ["bold"] }, - "paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }, - "readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base01" }, - "vcsinfo:dirty": { "fg": "solarized:yellow", "bg": "solarized:base01" }, - "vcsinfo:divider": { "fg": "solarized:base1", "bg": "solarized:base01" }, - "file_name": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] }, - "window_title": { "fg": "solarized:base3", "bg": "solarized:base01" }, - "file_name_no_file": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] }, - "file_format": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base01" }, - "file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base01" }, - "file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base01" }, - "line_percent": { "fg": "solarized:base3", "bg": "solarized:base00" }, - "line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base00" }, - "position": { "fg": "solarized:base3", "bg": "solarized:base00" }, - "position_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base00" }, - "line_current": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] }, - "line_current_symbol": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "solarized:base2" }, - "col_current": { "fg": "solarized:base0", "bg": "solarized:base2" }, - "environment": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "attached_clients": { "fg": "solarized:base1", "bg": "solarized:base02" }, - "error": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }, - "warning": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }, - "current_tag": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": ["bold"] } - }, - "mode_translations": { - "nc": { - "colors": { - "solarized:base01": "solarized:base02", - "solarized:base00": "solarized:base02", - "solarized:base0": "solarized:base01", - "solarized:base1": "solarized:base00", - "solarized:base2": "solarized:base0", - "solarized:base3": "solarized:base1" - } - }, - "i": { - "groups": { - "background": { "fg": "solarized:base3", "bg": "solarized:base01" }, - "background:divider": { "fg": "solarized:base2", "bg": "solarized:base01" }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }, - "modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base2", "attrs": ["bold"] }, - "paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }, - "readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base2" }, - "vcsinfo": { "fg": "solarized:base01", "bg": "solarized:base2" }, - "vcsinfo:divider": { "fg": "solarized:base00", "bg": "solarized:base2" }, - "file_directory": { "fg": "solarized:base01", "bg": "solarized:base2" }, - "file_name": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": ["bold"] }, - "file_size": { "fg": "solarized:base02", "bg": "solarized:base2" }, - "file_name_no_file": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": ["bold"] }, - "file_name_empty": { "fg": "solarized:base02", "bg": "solarized:base2" }, - "file_format": { "fg": "solarized:base2", "bg": "solarized:base01" }, - "file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base2" }, - "file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base2" }, - "file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base2" }, - "line_percent": { "fg": "solarized:base3", "bg": "solarized:base1" }, - "line_percent_gradient": { "fg": "solarized:base3", "bg": "solarized:base1" }, - "position": { "fg": "solarized:base3", "bg": "solarized:base1" }, - "position_gradient": { "fg": "solarized:base3", "bg": "solarized:base1" }, - "line_current": { "fg": "solarized:base03", "bg": "solarized:base3", "attrs": ["bold"] }, - "line_current_symbol": { "fg": "solarized:base03", "bg": "solarized:base3" }, - "col_current": { "fg": "solarized:base0", "bg": "solarized:base3" } - } - }, - "ic": { - "groups": { - "background": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] }, - "background:divider": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] } - } - }, - "ix": { - "groups": { - "background": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] }, - "background:divider": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] } - } - }, - "v": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "V": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "^V": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "R": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - }, - "Rc": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - }, - "Rx": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - } - } -} diff --git a/powerline/config_files/colorschemes/vim/solarizedlight.json b/powerline/config_files/colorschemes/vim/solarizedlight.json deleted file mode 100644 index 06e75379b..000000000 --- a/powerline/config_files/colorschemes/vim/solarizedlight.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "name": "Solarized light for vim", - "groups": { - "information:additional": { "fg": "solarized:base02", "bg": "solarized:base2" }, - "information:unimportant": { "fg": "solarized:base1", "bg": "solarized:base01" }, - "background": { "fg": "solarized:base03", "bg": "solarized:base01" }, - "background:divider": { "fg": "solarized:base0", "bg": "solarized:base01" }, - "mode": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": ["bold"] }, - "visual_range": { "fg": "solarized:green", "bg": "solarized:base3", "attrs": ["bold"] }, - "modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base2", "attrs": ["bold"] }, - "paste_indicator": { "fg": "solarized:red", "bg": "solarized:base2", "attrs": ["bold"] }, - "readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base2" }, - "vcsinfo:dirty": { "fg": "solarized:yellow", "bg": "solarized:base2" }, - "vcsinfo:divider": { "fg": "solarized:base1", "bg": "solarized:base2" }, - "file_name": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] }, - "window_title": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "file_size": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "file_name_no_file": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] }, - "file_name_empty": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base2" }, - "file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base2" }, - "file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base2" }, - "line_percent": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base2" }, - "position": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "position_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base2" }, - "line_current": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": ["bold"] }, - "line_current_symbol": { "fg": "solarized:base3", "bg": "solarized:base02" }, - "virtcol_current_gradient": { "fg": "yellow_orange_red", "bg": "solarized:base02" }, - "col_current": { "fg": "solarized:base00", "bg": "solarized:base02" }, - "error": { "fg": "solarized:base03", "bg": "solarized:red", "attrs": ["bold"] }, - "warning": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] }, - "current_tag": { "fg": "solarized:base03", "bg": "solarized:base01", "attrs": ["bold"] } - }, - "mode_translations": { - "nc": { - "colors": { - "solarized:base2": "solarized:base01", - "solarized:base0": "solarized:base01", - "solarized:base00": "solarized:base2", - "solarized:base1": "solarized:base0", - "solarized:base02": "solarized:base00", - "solarized:base03": "solarized:base1" - } - }, - "i": { - "groups": { - "background": { "fg": "solarized:base03", "bg": "solarized:base2" }, - "background:divider": { "fg": "solarized:base02", "bg": "solarized:base2" }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }, - "modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base02", "attrs": ["bold"] }, - "paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }, - "readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base02" }, - "vcsinfo": { "fg": "solarized:base2", "bg": "solarized:base02" }, - "vcsinfo:divider": { "fg": "solarized:base0", "bg": "solarized:base02" }, - "file_directory": { "fg": "solarized:base2", "bg": "solarized:base02" }, - "file_name": { "fg": "solarized:base01", "bg": "solarized:base02", "attrs": ["bold"] }, - "file_size": { "fg": "solarized:base01", "bg": "solarized:base02" }, - "file_name_no_file": { "fg": "solarized:base01", "bg": "solarized:base02", "attrs": ["bold"] }, - "file_name_empty": { "fg": "solarized:base01", "bg": "solarized:base02" }, - "file_format": { "fg": "solarized:base02", "bg": "solarized:base2" }, - "file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base02" }, - "file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base02" }, - "file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base02" }, - "line_percent": { "fg": "solarized:base03", "bg": "solarized:base1" }, - "line_percent_gradient": { "fg": "solarized:base03", "bg": "solarized:base1" }, - "position": { "fg": "solarized:base03", "bg": "solarized:base1" }, - "position_gradient": { "fg": "solarized:base03", "bg": "solarized:base1" }, - "line_current": { "fg": "solarized:base3", "bg": "solarized:base03", "attrs": ["bold"] }, - "line_current_symbol": { "fg": "solarized:base3", "bg": "solarized:base03" }, - "virtcol_current_gradient": { "fg": "yellow_orange_red", "bg": "solarized:base03" }, - "col_current": { "fg": "solarized:base00", "bg": "solarized:base03" } - } - }, - "ic": { - "groups": { - "background": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] }, - "background:divider": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": [] }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] } - } - }, - "ix": { - "groups": { - "background": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] }, - "background:divider": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": [] }, - "mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] } - } - }, - "v": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "V": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "^V": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] } - } - }, - "R": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - }, - "Rc": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - }, - "Rx": { - "groups": { - "mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] } - } - } - } -} diff --git a/powerline/config_files/colorschemes/wm/default.json b/powerline/config_files/colorschemes/wm/default.json index 388942017..925b48427 100644 --- a/powerline/config_files/colorschemes/wm/default.json +++ b/powerline/config_files/colorschemes/wm/default.json @@ -1,65 +1,174 @@ { - "name": "Default", + "name": "Default", "groups": { - "clip": { "fg": "level:2_fg", "bg": "level:2_bg", "click": { - "left": "xsel -cb" - } }, - "volume_gradient": { "fg": "white_red", "bg": "level:3_bg", "click": { - "scroll up": "pactl set-sink-volume 0 +1%", - "scroll down": "pactl set-sink-volume 0 -1%" - } }, - "player": { "fg": "level:3_fg", "bg": "level:3_bg", "click": { - "left": "xdotool key XF86AudioPlay" - } }, - "player:next": { "fg": "level:3_fg", "bg": "level:3_bg", "click": { - "left": "xdotool key XF86AudioNext" - } }, - "player:previous": { "fg": "level:3_fg", "bg": "level:3_bg", "click": { - "left": "xdotool key XF86AudioPrev" - } }, - "workspace": { "fg": "level:2_fg", "bg": "level:2_bg", "click": { - "left": "i3-msg workspace {workspace_name}", - "right": "i3-msg move to workspace {workspace_name}" - } }, - "workspace:focused": "level:3", - "workspace:visible": "level:1", - "workspace:urgent": { "bg": "level:2_bg", "fg": "0xffaf00", "click": { - "left": "i3-msg workspace {workspace_name}", - "right": "i3-msg move to workspace {workspace_name}" - } }, - "scratchpad": { "fg": "level:2_fg", "bg": "level:2_bg", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:focused": { "fg": "level:3_fg", "bg": "level:3_bg", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:visible": { "fg": "level:1_fg", "bg": "level:1_bg", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:urgent": { "bg": "level:3_bg", "fg": "brightorange", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "output": { "bg": "level:3_bg", "fg": "brightorange" }, - "appoint": "level:3", - "appoint:urgent": "level:2_bold", - "appoint:error": { "fg": "level:3_fg", "bg": "red", "click": { - "left": "powerline-gcal-auth 'client_id' 'client_secret'" - } }, - "mode": "level:2", - "active_window_title": "level:2", - "hostname": { "fg": "level:1_fg", "bg": "level:1_bg", "click": { - "left": "#bar;restart" - } }, + "clip": { + "fg": "level:2_fg", + "bg": "level:2_bg", + "click": { + "left": "xsel -cb" + } + }, + "volume_gradient": { + "fg": "white_red", + "bg": "level:3_bg", + "click": { + "scroll up": "pactl set-sink-volume @DEFAULT_SINK@ +1%", + "scroll down": "pactl set-sink-volume @DEFAULT_SINK@ -1%" + } + }, + "player": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "xdotool key XF86AudioPlay", + "middle": "#bar;ch_toggle" + } + }, + "player:next": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "xdotool key XF86AudioNext" + } + }, + "player:previous": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "xdotool key XF86AudioPrev" + } + }, + "workspace": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "i3-msg workspace {workspace_name}", + "right": "i3-msg move to workspace {workspace_name}" + } + }, + "workspace:focused": { + "fg": "level:3_bg", + "bg": "level:3_fg" + }, + "workspace:visible": { + "fg": "level:3_bg", + "bg": "level:3_fg" + }, + "workspace:urgent": { + "bg": "level:2_bg", + "fg": "0xffaf00", + "click": { + "left": "i3-msg workspace {workspace_name}", + "right": "i3-msg move to workspace {workspace_name}" + } + }, + "scratchpad": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "i3-msg scratchpad show", + "right": "i3-msg move to scratchpad" + } + }, + "scratchpad:focused": { + "fg": "level:3_bg", + "bg": "level:3_fg", + "click": { + "left": "i3-msg scratchpad show", + "right": "i3-msg move to scratchpad" + } + }, + "scratchpad:visible": "scratchpad:focused", + "scratchpad:urgent": { + "bg": "level:3_bg", + "fg": "brightorange", + "click": { + "left": "i3-msg scratchpad show", + "right": "i3-msg move to scratchpad" + } + }, + "output": { + "bg": "level:2_bg", + "fg": "level:2_fg" + }, + "output:status": { + "bg": "level:2_bg", + "fg": "level:2_fg", + "click": { + "left": "#bar;pass_oneshot:output:{output_name}:toggle" + } + }, + "output:mirror": { + "bg": "level:2_bg", + "fg": "level:2_fg", + "click": { + "left": "#bar;pass_oneshot:mode:toggle" + } + }, + "srot": "level:2", "srot:mode": { "bg": "level:2_bg", "fg": "level:2_fg", "click": { - "left": "#bar;pass_oneshot:toggle_rot" + "left": "#bar;pass_oneshot:toggle_rot", + "middle": "#bar;pass_oneshot:toggle_controls:{output}" + } + }, + "srot:tc": { + "bg": "level:2_bg", + "fg": "level:2_fg", + "click": { + "left": "#bar;pass_oneshot:capture_input:{output}", + "middle": "#bar;pass_oneshot:toggle_controls:{output}" + } + }, + "srot:rc": { + "bg": "level:2_bg", + "fg": "level:2_fg", + "click": { + "left": "#bar;pass_oneshot:capture:{output}", + "middle": "#bar;pass_oneshot:toggle_controls:{output}" + } + }, + "appoint": { + "bg": "level:3_bg", + "fg": "level:3_fg", + "click": { + "left": "#bar;ch_toggle" + } + }, + "appoint:urgent": { + "bg": "level:2_bg", + "fg": "level:2_fg", + "click": { + "left": "#bar;ch_toggle" + } + }, + "appoint:error": { + "fg": "level:3_fg", + "bg": "red", + "click": { + "right": "powerline-gcal-auth '' ''", + "left": "#bar;ch_toggle" + } + }, + "generic_shell": "level:1", + "mode": "level:2", + "active_window_title": "level:2", + "hostname": { + "fg": "level:1_fg", + "bg": "level:1_bg", + "click": { + "left": "#bar;restart" + } + }, + "wireless:gradient": { + "fg": "level:3_fg", + "bg": "level:3_bg", + "click": { + "left": "#bar;ch_toggle" } } } } + diff --git a/powerline/config_files/colorschemes/wm/solarized.json b/powerline/config_files/colorschemes/wm/solarized.json deleted file mode 100644 index 0cf3c7235..000000000 --- a/powerline/config_files/colorschemes/wm/solarized.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "Default", - "groups": { - "background": { "fg": "white", "bg": "0x005f87" }, - "background:divider": { "fg": "gray5", "bg": "0x005f87" }, - "session": { "fg": "black", "bg": "gray10", "attrs": ["bold"] }, - "date": { "fg": "0xe4e4e4", "bg": "0x0087af" }, - "time": { "fg": "0x585858", "bg": "0xe4e4e4", "attrs": ["bold"] }, - "time:divider": { "fg": "0x585858", "bg": "0xe4e4e4" }, - "email_alert": { "fg": "white", "bg": "brightred", "attrs": ["bold"] }, - "email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attrs": ["bold"] }, - "hostname": { "fg": "0x585858", "bg": "0xe4e4e4" }, - "weather": { "fg": "gray8", "bg": "0x005f87" }, - "weather_temp_gradient": { "fg": "blue_red", "bg": "0x005f87" }, - "weather_condition_hot": { "fg": "khaki1", "bg": "0x005f87" }, - "weather_condition_snowy": { "fg": "skyblue1", "bg": "0x005f87" }, - "weather_condition_rainy": { "fg": "skyblue1", "bg": "0x005f87" }, - "uptime": { "fg": "gray8", "bg": "0x005f87" }, - "external_ip": { "fg": "gray8", "bg": "0x005f87" }, - "internal_ip": { "fg": "gray8", "bg": "0x005f87" }, - "network_load": { "fg": "gray8", "bg": "0x005f87" }, - "network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "0x005f87" }, - "system_load": { "fg": "gray8", "bg": "0x005f87" }, - "system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "0x005f87" }, - "volume_gradient": { "fg": "green_yellow_red", "bg": "0x005f87", "click": { - "scroll up": "pactl set-sink-volume 0 +1%", - "scroll down": "pactl set-sink-volume 0 -1%" - } }, - "quality_gradient": { "fg": "green_yellow_red", "bg": "0x005f87" }, - "environment": { "fg": "gray8", "bg": "0x005f87" }, - "cpu_load_percent": { "fg": "gray8", "bg": "0x005f87" }, - "cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "0x005f87" }, - "battery": { "fg": "gray8", "bg": "0x005f87" }, - "battery_gradient": { "fg": "white_red", "bg": "0x005f87" }, - "battery:full": { "fg": "red", "bg": "0x005f87" }, - "battery:empty": { "fg": "white", "bg": "0x005f87" }, - "player": { "fg": "0xe4e4e4", "bg": "0x005f87", "click": { - "scroll down": "xdotool key XF86AudioNext", - "scroll up": "xdotool key XF86AudioPrev", - "left": "xdotool key XF86AudioPlay", - "right": "xdotool key XF86AudioNext" - } }, - "user": { "fg": "white", "bg": "darkblue", "attrs": ["bold"] }, - "superuser": { "fg": "white", "bg": "brightred", "attrs": ["bold"] }, - "attached_clients": { "fg": "gray8", "bg": "0x005f87" }, - "workspace": { "fg": "0xe4e4e4", "bg": "0x0087af", "click": { - "left": "i3-msg workspace {0:.2}", - "right": "i3-msg move to workspace {0:.2}" - } }, - "workspace:focused": { "fg": "0xe4e4e4", "bg": "0x005f87" }, - "workspace:visible": { "fg": "0x585858", "bg": "0xe4e4e4" }, - "workspace:urgent": { "bg": "0x0087af", "fg": "0xffaf00", "click": { - "left": "i3-msg workspace {0:.2}", - "right": "i3-msg move to workspace {0:.2}" - } }, - "scratchpad": { "fg": "0xe4e4e4", "bg": "0x0087af", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:focused": { "fg": "0xe4e4e4", "bg": "0x005f87", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:visible": { "fg": "0x585858", "bg": "0xe4e4e4", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "scratchpad:urgent": { "bg": "0x005f87", "fg": "brightorange", "click": { - "left": "i3-msg scratchpad show", - "right": "i3-msg move to scratchpad" - } }, - "output": { "bg": "0x005f87", "fg": "mediumpurple" }, - "appoint": { "fg": "0x0087af", "bg": "0xe4e4e4" }, - "appoint:urgent": { "fg": "darkestcyan", "bg": "khaki1", "attrs": ["bold"] }, - "mode": { "fg": "0xe4e4e4", "bg": "0x0087af" }, - "active_window_title": { "bg": "0xe4e4e4", "fg": "0x0087af" }, - "workspace:icon": { "bg": "0xe4e4e4", "fg": "0x0087af" } - } -} diff --git a/powerline/config_files/themes/wm/default.json b/powerline/config_files/themes/wm/default.json index 3a34399ad..f3cff8dd1 100644 --- a/powerline/config_files/themes/wm/default.json +++ b/powerline/config_files/themes/wm/default.json @@ -5,7 +5,7 @@ "function": "powerline.segments.common.players.gpmdp", "name": "gpmdp", "args": { - "format": "{state_symbol}{artist} — {title}", + "format": "{state_symbol}{artist} — {title} ({album})", "short_format": "{state_symbol}{short_title}", "state_symbols": { "fallback": "♫", @@ -24,17 +24,20 @@ "steps": 5 }, "auto_disable": true, - "show_controls": true + "show_controls": true, + "auto_shrink": true } }, { "function": "powerline.segments.common.players.dbus_player", "name": "vlc", "args": { - "format": "{state_symbol}{artist} — {title}", + "format": "{state_symbol}{artist} — {title} ({album})", "short_format": "{state_symbol}{short_title}", "auto_disable": true, "show_controls": true, + "auto_shrink": true, + "channel_name": "players.vlc", "state_symbols": { "fallback": "♫", "play": "▶ ", @@ -58,15 +61,17 @@ "args": { "format": " {volume:3.0%}", "format_muted": null - } + }, + "priority": 40 }, { "function": "powerline.segments.common.net.wireless", "args": { - "device": "wlo1", - "format": " {quality:3.0%} at {essid}", - "short_format": " {quality:3.0%} at {essid}" - } + "format": " {quality:3.0%} at {essid}", + "short_format": " {quality:3.0%}", + "auto_shrink": true + }, + "priority": 40 }, { "function": "powerline.segments.common.bat.battery", @@ -95,6 +100,14 @@ { "draw_soft_divider": false, "function": "powerline.segments.common.bat.battery", + "args": { + "format": "{capacity:3.0%}", + "original_health": true + } + }, + { + "draw_soft_divider": true, + "function": "powerline.segments.common.bat.battery", "args": { "name": "rem_time", "original_health": true @@ -104,7 +117,8 @@ "function": "powerline.segments.common.time.date", "args": { "format": "%m-%d" - } + }, + "priority": 10 }, { "function": "powerline.segments.common.time.date", @@ -112,15 +126,57 @@ "args": { "format": "%H:%M", "istime": true - } + }, + "priority": 1 } ], "left": [ { - "function": "powerline.segments.common.net.hostname" + "function": "powerline.segments.common.net.hostname", + "priority": 70 + }, + { + "function": "powerline.segments.randr.output", + "args": { + "status_icons": { + "on": "", + "off": "" + }, + "mirror_icons": { + "extend": "", + "mirror": "" + } + } + }, + { + "function": "powerline.segments.randr.srot", + "args": { + "name": "mode", + "output": "eDP1", + "mapped_inputs": [ + "Insert your touch screen/ digitizer name from xinput --list here", + "Wacom HID 481C Finger", + "Wacom HID 481C Pen Pen", + "Wacom HID 481C Pen Eraser" + ], + "touchpads": [ + "Insert your touchpad names here", + "ALP0016:00 044E:1215", + "AlpsPS/2 ALPS GlidePoint" + ], + "icons": { + "auto": "", + "locked": "" + }, + "additional_controls": [ + [ " {touch_output}", ["srot:tc"] ], + [ " {managed_output}", ["srot:rc"] ] + ] + } }, { - "function": "powerline.segments.common.env.clip" + "function": "powerline.segments.common.env.clip", + "priority": 80 }, { "function": "powerline.segments.i3wm.mode", @@ -132,7 +188,8 @@ "gaps-o": "Outer Gaps: p|m|0 (local), Shift + p|m|0 (global)", "gaps-i": "Inner Gaps: p|m|0 (local), Shift + p|m|0 (global)" } - } + }, + "priority": 60 }, { "function": "powerline.segments.i3wm.workspaces", @@ -141,10 +198,12 @@ "draw_soft_divider": true, "args": { "only_show": [ "focused", "visible" ], - "output": "__all__", "separator": " ", - "show_multiple_icons": false - } + "show_multiple_icons": false, + "show_dummy_workspace": true, + "show_output": true + }, + "priority": 30 }, { "function": "powerline.segments.i3wm.workspaces", @@ -152,12 +211,15 @@ "draw_inner_divider": true, "draw_soft_divider": true, "args": { - "output": "__all__", - "separator": " " - } + "separator": " ", + "show_dummy_workspace": true, + "show_output": true + }, + "priority": 30 }, { - "function": "powerline.segments.i3wm.scratchpad" + "function": "powerline.segments.i3wm.scratchpad", + "priority": 30 } ] } diff --git a/powerline/segments/common/appoints.py b/powerline/segments/common/appoints.py index 462ae6eaf..550194559 100644 --- a/powerline/segments/common/appoints.py +++ b/powerline/segments/common/appoints.py @@ -147,6 +147,11 @@ def shorten(summary): res += w[0:3] return res + def truncate_long(pl, wd, seg): + wd -= len(seg['contents']) + nw_con = seg['contents'][0:max(len(seg['contents'])//2, -wd)].strip(' .,;(-') + return nw_con + '…' if len(nw_con) < len(seg['contents']) else nw_con + # check if these events are relevant if not short_mode: return [{ @@ -160,13 +165,17 @@ def shorten(summary): else (dt + bf).strftime(time_format), 'summary': sm, 'short_summary': shorten(sm), 'location': lc, 'count': evt_count}, 'truncate': (lambda a,b,seg: short_format.format(**seg['_data'])) if - not auto_shrink else None + not auto_shrink else truncate_long } for dt, sm, lc, bf in events if dt <= now] + segments elif evt_count: + urgent = False + for dt, sm, lc, bf in events: + if now < dt + bf: + urgent = True return [{ 'contents': short_format.format(time='', summary='', short_summary='', location='', count=evt_count, error=''), - 'highlight_groups': ['appoint'], + 'highlight_groups': ['appoint:urgent', 'appoint'] if urgent else ['appoint'], 'payload_name': channel_name }] diff --git a/powerline/segments/common/net.py b/powerline/segments/common/net.py index b44616ec0..4faf77bd3 100644 --- a/powerline/segments/common/net.py +++ b/powerline/segments/common/net.py @@ -32,12 +32,12 @@ def hostname(pl, segment_info, only_if_ssh=False, exclude_domain=False): return socket.gethostname() @requires_segment_info -def wireless(pl, segment_info, device, format='{quality:3.0%} at {essid}', +def wireless(pl, segment_info, device=None, format='{quality:3.0%} at {essid}', short_format='{quality:3.0%}', format_down=None, auto_shrink=False): '''Returns the current connection quality. :param string device: - the device to use + the device to use. Per default this segment will try to be smart. :param string format: the output format :param string short_format: @@ -57,6 +57,12 @@ def wireless(pl, segment_info, device, format='{quality:3.0%} at {essid}', ''' payload_name = 'net.wireless' + if not device: + for interface in os.listdir('/sys/class/net'): + if interface.startswith('w'): + device = interface + break + try: import iwlib except ImportError: diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 49fd3bbaa..03bcf4e5b 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -84,6 +84,11 @@ def truncate(pl, wd, seg): seg['_data']['short_title'] = nw_ttl + '…' if len(nw_ttl) < len(ttl) else nw_ttl return short_format.format(**seg['_data']) + def truncate_long(pl, wd, seg): + wd -= len(seg['contents']) + nw_con = seg['contents'][0:max(len(seg['contents'])//2, -wd)].strip(' .,;(-') + return nw_con + '…' if len(nw_con) < len(seg['contents']) else nw_con + segments = [] if show_controls: @@ -102,7 +107,7 @@ def truncate(pl, wd, seg): 'draw_inner_divider': True, 'payload_name': channel_name, '_data': stats, - 'truncate': truncate if not auto_shrink else None + 'truncate': truncate if not auto_shrink else truncate_long }] if show_controls: diff --git a/powerline/segments/randr.py b/powerline/segments/randr.py index e59cfee23..5766694b4 100644 --- a/powerline/segments/randr.py +++ b/powerline/segments/randr.py @@ -341,6 +341,9 @@ def render(self, data, segment_info, show_on_all_outputs=True, name='rotation', @requires_segment_info class OutputSegment(ThreadedSegment): interval = 1 + + d = None + window = None outputs = {} segment_state = 0 # 0: minimal, 1: list outputs, 2: show modes for chosen output @@ -348,35 +351,151 @@ class OutputSegment(ThreadedSegment): MIRROR_STATES = ['extend', 'mirror'] mirror_state = 0 # 0: extend, 1: mirror + last_oneshot = 0 + + bar_needs_resize = None + def set_state(self, **kwargs): - self.outputs = get_randr_outputs() + from Xlib import X, display + from Xlib.ext import randr + self.d = display.Display() + s = self.d.screen() + self.window = s.root.create_window(0, 0, 1, 1, 1, s.root_depth) + + self.outputs = [o for o in get_randr_outputs(self.d, self.window) if o['connection']] super(OutputSegment, self).set_state(**kwargs) def update(self, *args, **kwargs): + self.outputs = [o for o in get_randr_outputs(self.d, self.window) if o['connection']] return None + def update_mirror_state(self): + print(f'TODO: Update mirror state to {self.mirror_state}') + + def enable_output(self, output): + from Xlib.ext import randr + used_crtc = [o['crtc_id'] for o in self.outputs if o['crtc_id']] + free_crtc = [c for c in output['crtcs'] if c not in used_crtc] + + if len(free_crtc) < 1: + # No crtc available, so we cannot enable this output + return False + + if self.mirror_state: + # We need to find a mode that every connected output supports + enabled_outputs = [o for o in self.outputs if o['crtc']] + + mode = output['mode_ids'] + for e in enabled_outputs: + mode = [m for m in mode if m in e['mode_ids']] + + if not len(mode): + # Outputs couldn't agree on mode + return False + + randr.set_crtc_config(self.d, free_crtc[0], + 0, 0, 0, mode[0], randr.Rotate_0, [output['id']]) + for o in self.outputs: + if o['crtc_id'] in used_crtc: + randr.set_crtc_config(self.d, o['crtc_id'], + 0, 0, 0, mode[0], randr.Rotate_0, [o['id']]) + + # Everything worked (hopefully), so redraw the bar + self.bar_needs_resize = [output['name']] + [o['name'] for o in self.outputs + if o['crtc_id'] in used_crtc] + return True + + def disable_output(self, output): + from Xlib.ext import randr + # remove the output from the crtc it is mapped to + if self.mirror_state: + # We need to find a mode that every connected output supports + enabled_outputs = [o for o in self.outputs if o['crtc'] and o['name'] != output['name']] + + if len(enabled_outputs) == 0: + # Prohibit the user from disabling the last output + return False + + mode = enabled_outputs[0]['mode_ids'] + for e in enabled_outputs: + mode = [m for m in mode if m in e['mode_ids']] + + # disable the output + randr.set_crtc_config(self.d, output['crtc_id'], 0, 0, 0, 0, randr.Rotate_0, []) + for o in enabled_outputs: + randr.set_crtc_config(self.d, o['crtc_id'], + 0, 0, 0, mode[0], randr.Rotate_0, [o['id']]) + + # Everything worked (hopefully), so redraw the bar + self.bar_needs_resize = [output['name']] + [o['name'] for o in enabled_outputs] + return True + def render(self, data, segment_info, mirror_format='{mirror_icon}', mirror_icons={'mirror': 'M', 'extend': 'E'}, output_format='{output} {status_icon}', - status_icons={'on': 'on', 'off': 'off'}, **kwargs): + status_icons={'on': 'on', 'off': 'off'}, hide_if_single_output=True, **kwargs): + channel_name = 'randr.output' - result = [] + channel_value = None + if 'payloads' in segment_info and channel_name in segment_info['payloads']: + channel_value = segment_info['payloads'][channel_name] - return None + if channel_value and not isinstance(channel_value, str) and len(channel_value) == 2 and channel_value[0].startswith('mode:') and channel_value[1] > self.last_oneshot: + command = channel_value[0].split(':')[1] + self.last_oneshot = channel_value[1] + if command == 'toggle': + self.mirror_state = (self.mirror_state + 1) % len(self.MIRROR_STATES) + else: + for i in self.MIRROR_STATES: + if i == command: + self.mirror_state = i + self.update_mirror_state() + + if channel_value and not isinstance(channel_value, str) and len(channel_value) == 2 and channel_value[0].startswith('output:') and channel_value[1] > self.last_oneshot: + self.last_oneshot = channel_value[1] + output = channel_value[0].split(':')[1] + command = channel_value[0].split(':')[2] + + output = [o for o in self.outputs if o['name'] == output] + if len(output) == 1: + output = output[0] + if command == 'on': + self.enable_output(output) + if command == 'off': + self.disable_output(output) + if command == 'toggle': + if output['crtc']: + self.disable_output(output) + else: + self.enable_output(output) + + if self.bar_needs_resize: + scrn = self.bar_needs_resize + self.bar_needs_resize = None + segment_info['restart'](scrn) + + + if hide_if_single_output and len(self.outputs) < 2: + return None + + result = [] result += [{ 'contents': mirror_format.format(mirror_state=self.MIRROR_STATES[self.mirror_state], mirror_icon=mirror_icons[self.MIRROR_STATES[self.mirror_state]]), - 'highlight_groups': ['output:' + self.MIRROR_STATES[self.mirror_state], 'output'], + 'highlight_groups': ['output:' + self.MIRROR_STATES[self.mirror_state], 'output:mirror', + 'output'], 'draw_inner_divider': True, + 'payload_name': channel_name, 'click_values': {'mirror_state': self.MIRROR_STATES[self.mirror_state]} }] result += [{ 'contents': output_format.format(output=o['name'], status_icon=status_icons[o['status']]), - 'highlight_groups': ['output:' + o['status'], 'output'], + 'highlight_groups': ['output:' + o['status'], 'output:status', 'output'], 'draw_inner_divider': True, + 'payload_name': channel_name, 'click_values': {'output_name': o['name'], 'output_status': o['status']} } for o in self.outputs] diff --git a/scripts/powerline-lemonbar b/scripts/powerline-lemonbar index f9b9091d6..23fd6cd3e 100755 --- a/scripts/powerline-lemonbar +++ b/scripts/powerline-lemonbar @@ -47,6 +47,8 @@ def render(reschedule=False): t.start() except BrokenPipeError: # The lemonbar died, so should we pass + except RuntimeError: + pass global needs_restart n_r = needs_restart if len(n_r): @@ -131,7 +133,10 @@ def restart_bar(output_name): def restart_callback(output): global needs_restart - needs_restart.extend([output]) + if not isinstance(output, str): + needs_restart += output + else: + needs_restart.extend([output]) if __name__ == '__main__': parser = get_argparser() diff --git a/setup.py b/setup.py index 6f1e50bf5..2fbe67bb3 100755 --- a/setup.py +++ b/setup.py @@ -59,7 +59,7 @@ def compile_client(): setup( name='powerline-status-i3', - version='1.7.3', + version='1.7.4', description='The ultimate statusline/prompt utility. A fork containing more features for the i3 window manager.', long_description=README, classifiers=[