diff --git a/contrib/waybar-yambar-applets/README.md b/contrib/waybar-yambar-applets/README.md deleted file mode 100644 index 1f42c48f7..000000000 --- a/contrib/waybar-yambar-applets/README.md +++ /dev/null @@ -1,99 +0,0 @@ -These Python scripts can be used with Waybar and Yambar. They require the `pydbus` Python module. - -To use with Waybar, place the files `workrave-break-info.py` and `workrave-open.py` somewhere in your `$PATH`, and add the following to your Waybar config file: -```json - "custom/workrave": { - "exec": "workrave-break-info.py -f waybar", - "return-type": "json", - "on-click": "workrave-open.py", - "exec-on-event": false - } -``` -Of course, `"custom/workrave"` should be added to one of these arrays in the config file: `modules-left`, `modules-center`, `modules-right`. - -Note that all `workrave-open.py` does is open Workrave's status window (which doesn't necessarily happen if one simply types in `workrave` at the command-line). - -To use `workrave-break-info.py` with Yambar, the following can be added to the Yambar config file: -```yaml - - script: - path: ~/bin/workrave-break-info.py - args: - - "-f" - - "yambar" - anchors: - - default_color: &default_color {foreground: 87ceebff} #skyblue - - close_to_break_color: &close_to_break_color {foreground: ffa500ff} #orange - - overdue_color: &overdue_color {foreground: ff6347ff} - content: - list: - items: - - map: - conditions: - microbreak_state == "default": - string: - text: "{microbreak} D" - <<: *default_color - microbreak_state == "close to break": - string: - text: "{microbreak} C" - <<: *close_to_break_color - microbreak_state == "overdue": - string: - text: "{microbreak} O" - <<: *overdue_color - - map: - conditions: - restbreak_state == "default": - string: - text: "{restbreak} D" - <<: *default_color - restbreak_state == "close to break": - string: - text: "{restbreak} C" - <<: *close_to_break_color - restbreak_state == "overdue": - string: - text: "{restbreak} O" - <<: *overdue_color - # - map: - # conditions: - # dailylimit_state == "default": - # string: - # text: "{dailylimit} D" - # <<: *default_color - # dailylimit_state == "close to break": - # string: - # text: "{dailylimit} C" - # <<: *close_to_break_color - # dailylimit_state == "overdue": - # string: - # text: "{dailylimit} O" - # <<: *overdue_color -``` -The above configuration of course assumes that `workrave-break-info.py` is in `~/bin`. (Yambar does not use `$PATH` for its script modules.) It also assumes that Workrave has been configured to not use its daily limit. If it is used, the appropriate section should be uncommented. `default_color`, `close_to_break_color`, and `overdue_color` can be adjusted to one's taste, compatibility with Yambar's background, etc. - -Here is the usage of `workrave-break-info.py`: -``` -usage: workrave-break-info.py [-h] [-i POLLING_INTERVAL] [-f {plain,waybar,yambar}] - [--colors-default COLORS_DEFAULT COLORS_DEFAULT] - [--colors-close-to-break COLORS_CLOSE_TO_BREAK COLORS_CLOSE_TO_BREAK] - [--colors-overdue COLORS_OVERDUE COLORS_OVERDUE] - -options: - -h, --help show this help message and exit - -i POLLING_INTERVAL, --polling-interval POLLING_INTERVAL - Time interval for polling Workrave, in seconds [default = 1.0] - -f {plain,waybar,yambar}, --format {plain,waybar,yambar} - Format for output [default = plain] - --colors-default COLORS_DEFAULT COLORS_DEFAULT - Default timer colors (if color is used in the output format). First color is - text color, second is background color. [default = ['black', 'skyblue']] - --colors-close-to-break COLORS_CLOSE_TO_BREAK COLORS_CLOSE_TO_BREAK - Timer color when close to break time (if color is used in the output - format). First color is text color, second is background color. [default = - ['black', 'orange']] - --colors-overdue COLORS_OVERDUE COLORS_OVERDUE - Timer colors when interval between breaks exceeded (if color is used in the - output format. First color is text color, second is background color. - [default = ['white', 'red']] -``` diff --git a/contrib/waybar-yambar-applets/workrave-break-info.py b/contrib/waybar-yambar-applets/workrave-break-info.py deleted file mode 100644 index d943d36d4..000000000 --- a/contrib/waybar-yambar-applets/workrave-break-info.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import time -import sys - -import pydbus - -def wrap_timer_waybar(str_val, colors, timer_type, timer_state): - return f"{str_val}" - -def wrap_timer_plain(str_val, colors, timer_type, timer_state): - return str_val - -def wrap_timer_yambar(str_val, colors, timer_type, timer_state): - return "\n".join((f"{timer_type}|string|{str_val.replace('|', '/')}", - f'{timer_type}_state|string|{timer_state}')) - -wrap_timer_func_dict = { - "plain": wrap_timer_plain, - "waybar": wrap_timer_waybar, - "yambar": wrap_timer_yambar -} - -wrap_str_func_dict = { - "plain": lambda x: x, - "waybar": lambda x: f"""{{"text": "{x}", "tooltip": "Workrave"}}""", - "yambar": lambda x: f"{x}\n" -} - -separator_dict = { - "plain": " ", - "waybar": " ", - "yambar": "\n" -} - -output_fmts = tuple(wrap_timer_func_dict.keys()) - -def seconds_to_time_str(tot_num_sec): - abs_tot_num_sec = abs(tot_num_sec) - sign = "" if tot_num_sec >= 0 else "-" - - if abs_tot_num_sec >= 3600: - num_hr, rem_num_sec = divmod(abs_tot_num_sec, 3600) - num_min, num_sec = divmod(rem_num_sec, 60) - - return f"{sign}{num_hr}:{num_min:02d}:{num_sec:02d}" - else: - num_min, num_sec = divmod(abs_tot_num_sec, 60) - return f"{sign}{num_min}:{num_sec:02d}" - -def choose_colors(time_left, limit): - if time_left < 0: - return "overdue" - elif time_left/limit <= 0.1: - return "close to break" - else: - return "default" - -def timer_str(timer_type, wr_core, wr_cfg, wrap_timer_func, color_dict): - - timer_obj_path = { - "microbreak": "/timers/micro_pause/limit", - "restbreak": "/timers/rest_break/limit", - "dailylimit": "/timers/daily_limit/limit"}[timer_type] - - limit = wr_cfg.GetInt(timer_obj_path)[0] - time_left = limit - wr_core.GetTimerElapsed(timer_type) - - timer_state = choose_colors(time_left, limit) - colors = color_dict[timer_state] - - time_left_str = seconds_to_time_str(time_left) - limit_str = seconds_to_time_str(limit) - - prefix = {"microbreak": "M", - "restbreak": "R", - "dailylimit": "D"}[timer_type] - - basic_str = f"{prefix}: {time_left_str}/{limit_str}" - - return wrap_timer_func(basic_str, colors, timer_type, timer_state) - -def microbreak_str(wr_core, wr_cfg, wrap_timer_func, color_dict): - return timer_str("microbreak", wr_core, wr_cfg, wrap_timer_func, color_dict) - -def restbreak_str(wr_core, wr_cfg, wrap_timer_func, color_dict): - return timer_str("restbreak", wr_core, wr_cfg, wrap_timer_func, color_dict) - -def dailylimit_str(wr_core, wr_cfg, wrap_timer_func, color_dict): - return timer_str("dailylimit", wr_core, wr_cfg, wrap_timer_func, color_dict) - -parser = argparse.ArgumentParser() - -parser.add_argument("-i", "--polling-interval", type = float, default = 1.0, - help = "Time interval for polling Workrave, in seconds " - "[default = %(default)s]") - -parser.add_argument("-f", "--format", - choices = output_fmts, default = output_fmts[0], - help = "Format for output [default = %(default)s]") - -parser.add_argument("--colors-default", nargs = 2, default = ["black", "skyblue"], - help = "Default timer colors (if color is used in the output " - "format). First color is text color, second is background color. " - "[default = %(default)s]") - -parser.add_argument("--colors-close-to-break", nargs = 2, default = ["black", "orange"], - help = "Timer color when close to break time (if color is used in " - "the output format). First color is text color, second is " - "background color. [default = %(default)s]") - -parser.add_argument("--colors-overdue", nargs = 2, default = ["white", "red"], - help = "Timer colors when interval between breaks exceeded (if " - "color is used in the output format. First color is text color, " - "second is background color. [default = %(default)s]") - -args = parser.parse_args() - -wrap_timer_func = wrap_timer_func_dict[args.format] -wrap_str_func = wrap_str_func_dict[args.format] -separator = separator_dict[args.format] - -color_dict = { - "default": args.colors_default, - "close to break": args.colors_close_to_break, - "overdue": args.colors_overdue -} - -session_bus = pydbus.SessionBus() - -wr_core = session_bus.get('org.workrave.Workrave', - '/org/workrave/Workrave/Core') - -wr_cfg = wr_core["org.workrave.ConfigInterface"] - -show_micro_break = wr_cfg.GetBool("/breaks/micro-pause/enabled")[0] -show_rest_break = wr_cfg.GetBool("/breaks/rest-break/enabled")[0] -show_daily_limit = wr_cfg.GetBool("/breaks/daily-limit/enabled")[0] - -funcs_to_repeat = [] -if show_micro_break: - funcs_to_repeat.append(microbreak_str) - -if show_rest_break: - funcs_to_repeat.append(restbreak_str) - -if show_daily_limit: - funcs_to_repeat.append(dailylimit_str) - -while True: - print(wrap_str_func( - separator.join(func(wr_core, wr_cfg, wrap_timer_func, color_dict) - for func in funcs_to_repeat)), flush = True) - - time.sleep(args.polling_interval) diff --git a/contrib/waybar-yambar-poss-other-applets/README.md b/contrib/waybar-yambar-poss-other-applets/README.md new file mode 100644 index 000000000..ee3bdcc5e --- /dev/null +++ b/contrib/waybar-yambar-poss-other-applets/README.md @@ -0,0 +1,152 @@ +These Python scripts can be used with Waybar and Yambar, and possibly other clients as well. They require the `pydbus` Python module. + +To use with Waybar, place the files `workrave-break-info.py` and `workrave-open.py` somewhere in your `$PATH`, and add the following to your Waybar config file: +```json + "custom/workrave": { + "exec": "workrave-break-info.py -f waybar", + "return-type": "json", + "on-click": "workrave-open.py", + "exec-on-event": false + } +``` +Of course, `"custom/workrave"` should be added to one of these arrays in the Waybar config file: `modules-left`, `modules-center`, `modules-right`. + +Note that all `workrave-open.py` does is open Workrave's status window if it isn't already open (which doesn't necessarily happen if one simply types in `workrave` at the command-line). + +To use `workrave-break-info.py` with Yambar, the following can be added to the Yambar config file: +```yaml + - script: + path: ~/bin/workrave-break-info.py + args: + - "-f" + - "yambar" + anchors: + - default_color: &default_color {foreground: 87ceebff} #skyblue + - close_to_break_color: &close_to_break_color {foreground: ffa500ff} #orange + - overdue_color: &overdue_color {foreground: ff6347ff} + - disabled_color: &disabled_color {foreground: 808080ff} #grey + content: + list: + items: + - map: + conditions: + microbreak_enabled: + map: + conditions: + microbreak_state == "default": + string: + text: "{microbreak}" + <<: *default_color + microbreak_state == "close to break": + string: + text: "{microbreak}" + <<: *close_to_break_color + microbreak_state == "overdue": + string: + text: "{microbreak}" + <<: *overdue_color + ~microbreak_enabled: + string: + text: "M: --" + <<: *disabled_color + - map: + conditions: + restbreak_enabled: + map: + conditions: + restbreak_state == "default": + string: + text: "{restbreak}" + <<: *default_color + restbreak_state == "close to break": + string: + text: "{restbreak}" + <<: *close_to_break_color + restbreak_state == "overdue": + string: + text: "{restbreak}" + <<: *overdue_color + ~restbreak_enabled: + string: + text: "R: --" + <<: *disabled_color + - map: + conditions: + dailylimit_enabled: + map: + conditions: + dailylimit_state == "default": + string: + text: "{dailylimit}" + <<: *default_color + dailylimit_state == "close to break": + string: + text: "{dailylimit}" + <<: *close_to_break_color + dailylimit_state == "overdue": + string: + text: "{dailylimit}" + <<: *overdue_color + ~dailylimit_enabled: + string: + text: "D: --" + <<: *disabled_color +``` +The above configuration of course assumes that `workrave-break-info.py` is in `~/bin`. (Yambar does not use `$PATH` for its script modules.) `default_color`, `close_to_break_color`, and `overdue_color` can be adjusted to one's taste, compatibility with Yambar's background, etc. + +The `workrave-break-info.py` script also offers two other formats as well. One is "plain" format, which just has the script repeatedly prints the timer information from Workrave as brief plain text, e.g. `M: 4:53/5:00 R: 19:12/55:00`. + +The other format is "json", where the script repeatedly outputs Workrave's timer information in a JSON format that can be used, for example, by [Elkowar's Wacky Widgets](https://elkowar.github.io/eww/). Each line of output is the string representation of a JSON object with the following keys and values: + +* `"microbreak_enabled"`: A Boolean that indicates if microbreaks are enabled +* `"microbreak_left_in_seconds"`: An integer indicating the number of seconds left until the microbreak starts +* `"microbreak_left_str"`: A string indicating the time left until the microbreak starts, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"microbreak_limit_in_seconds"`: An integer indicating the interval of time between microbreaks as a number of seconds +* `"microbreak_limit_str"`: A string indicating the interval of time between microbreaks, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"microbreak_state"`: A string indicating the state of the microbreak, either "default", "close to break" (for when the microbreak is about to start), or "overdue" (for when a microbreak is, well, overdue) +* `"microbreak_fgcol"`: The desired foreground color for the display of the microbreak +* `"microbreak_bgcol"`: The desired background color for the display of the microbreak +* `"restbreak_enabled"`: A Boolean that indicates if rest breaks are enabled +* `"restbreak_left_in_seconds"`: An integer indicating the number of seconds left until the rest break starts +* `"restbreak_left_str"`: A string indicating the time left until the rest break starts, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"restbreak_limit_in_seconds"`: An integer indicating the interval of time between rest breaks as a number of seconds +* `"restbreak_limit_str"`: A string indicating the interval of time between rest breaks, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"restbreak_state"`: A string indicating the state of the rest break, either "default", "close to break" (for when the rest break is about to start), or "overdue" (for when a rest break is, well, overdue) +* `"restbreak_fgcol"`: The desired foreground color for the display of the rest break +* `"restbreak_bgcol"`: The desired background color for the display of the rest break +* `"dailylimit_enabled"`: A Boolean that indicates if the daily limit is enabled +* `"dailylimit_left_in_seconds"`: An integer indicating the number of seconds in the daily limit +* `"dailylimit_left_str"`: A string indicating the length of the daily limit, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"dailylimit_in_seconds"`: An integer indicating the time in seconds until the daily limit is reached +* `"dailylimit_str"`: A string indicating the time until the daily limit is reached, expressed in a time format like `"%M:%S"` (or `"%H:%M:%S"` for time intervals longer than a hour) +* `"dailylimit_state"`: A string indicating the state of the daily limit, either "default", "close to break" (for when the daily limit is close to being reached), or "overdue" (for when the daily limit has been exceeded) +* `"dailylimit_fgcol"`: The desired foreground color for the display of the daily limit +* `"dailylimit_bgcol"`: The desired background color for the display of the daily limit + +A given client using this JSON output may, of course, ignore at least some of these keys. + +Here is the usage of `workrave-break-info.py`: +``` +usage: workrave-break-info.py [-h] [-i POLLING_INTERVAL] [-f {plain,waybar,yambar,json}] + [--colors-default COLORS_DEFAULT COLORS_DEFAULT] + [--colors-close-to-break COLORS_CLOSE_TO_BREAK COLORS_CLOSE_TO_BREAK] + [--colors-overdue COLORS_OVERDUE COLORS_OVERDUE] + +options: + -h, --help show this help message and exit + -i POLLING_INTERVAL, --polling-interval POLLING_INTERVAL + Time interval for polling Workrave, in seconds [default = 1.0] + -f {plain,waybar,yambar,json}, --format {plain,waybar,yambar,json} + Format for output [default = plain] + --colors-default COLORS_DEFAULT COLORS_DEFAULT + Default timer colors (if color is used in the output format). First color is + text color, second is background color. [default = ['black', 'skyblue']] + --colors-close-to-break COLORS_CLOSE_TO_BREAK COLORS_CLOSE_TO_BREAK + Timer color when close to break time (if color is used in the output format). + First color is text color, second is background color. [default = ['black', + 'orange']] + --colors-overdue COLORS_OVERDUE COLORS_OVERDUE + Timer colors when interval between breaks exceeded (if color is used in the + output format. First color is text color, second is background color. [default + = ['white', 'red']] +``` diff --git a/contrib/waybar-yambar-poss-other-applets/workrave-break-info.py b/contrib/waybar-yambar-poss-other-applets/workrave-break-info.py new file mode 100644 index 000000000..3bb601272 --- /dev/null +++ b/contrib/waybar-yambar-poss-other-applets/workrave-break-info.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 + +import argparse +import time +import sys + +import pydbus + +######################################################################### +# +# For those who want to edit this script's behavior, especially to add +# a new format ... +# +# The "fmt_timer_{$FORMAT}" function, where $FORMAT is a format type +# (plain, waybar, etc.), formats the string for an individual timer, +# i.e. microbreak, rest break, or daily limit. This function takes +# the following inputs to describe the timer: +# +# * enabled: a Boolean indicating if the timer is enabled +# +# * time_left: in seconds, the time left until the next break, or for +# the case of the daily limit, the time left for computer activity +# for the day +# +# * limit: in seconds, the time between breaks, or for the case of +# the daily limit, the daily limit itself +# +# * timer_type: a string with one of the following values: +# "microbreak", "restbreak", or "dailylimit". +# +# * timer_state: a string with one of the following values: +# "default", "close to break", and "overdue". +# +# * colors: a tuple of two strings, the first with a string +# indicating the foreground (or text) color, and the second +# indicating the background color. The colors indicate the value of +# timer_state. +# +# The "fmt_all_timers_{$FORMAT}" function takes a list of strings, +# each of which has information on an individual timer, and produces a +# string that contains informations about all of the timers +# described in that list. +# +# Here's how these functions are used. For example, suppose that: +# +# * The interval between microbreaks is 5 minutes and the time to +# the next microbreak is 3 minutes. +# +# * The interval between rest breaks is 50 minutes and the time to +# the next rest break is 15 minutes. +# +# * The daily limit is 4 hours, and time left for computer activity +# is 2.5 hours. +# +# Then fmt_timer_plain will generate the string "M 3:00/5:00" for the +# microbreak, "R 15:00/50:00" for the rest break, and +# "D 4:00:00/2:30:00" for the daily limit. fmt_all_timers_plain will +# receive the list of strings ["M 3:00/5:00", "R 15:00/50:00", +# "D 4:00:00/2:30:00"] and output the following string: +# +# "M 3:00/5:00 R 15:00/50:00 D 4:00:00/2:30:00" +# +# The dictionary fmt_info_dict associates a string that labels the +# format with a tuple containing the "fmt_timer_{$FORMAT}" +# function and the "fmt_all_timers_{$FORMAT}" function. +# The first key in fmt_info_dict is the default format (i.e., +# "plain"). +# +# To add, say, format "foo", define the functions fmt_timer_foo and +# fmt_all_timers_foo, and then add the following entry to fmt_info_dict: +# +# foo: (fmt_timer_foo, fmt_all_timers_foo) +# +######################################################################### + +def fmt_timer_plain(enabled, time_left, limit, timer_type, timer_state, colors): + + if not enabled: return "" + + time_left_str = seconds_to_time_str(time_left) + limit_str = seconds_to_time_str(limit) + + prefix = {"microbreak": "M", + "restbreak": "R", + "dailylimit": "D"}[timer_type] + + return f"{prefix}: {time_left_str}/{limit_str}" + +def fmt_all_timers_plain(timer_strs): + return " ".join(timer_str for timer_str in timer_strs if timer_str) + +def fmt_timer_waybar(enabled, time_left, limit, timer_type, timer_state, colors): + + if not enabled: return "" + + timer_str = fmt_timer_plain(enabled, time_left, limit, timer_type, timer_state, colors) + + return f"{timer_str}" + +def fmt_all_timers_waybar(timer_strs): + all_timers_str = " ".join(timer_str for timer_str in timer_strs if timer_str) + + return f"""{{"text": "{all_timers_str}", "tooltip": "Workrave"}}""" + +def fmt_timer_yambar(enabled, time_left, limit, timer_type, timer_state, colors): + + timer_str = fmt_timer_plain(True, time_left, limit, timer_type, timer_state, colors) + + return "\n".join((f"{timer_type}|string|{timer_str.replace('|', '/')}", + f"{timer_type}_enabled|bool|{str(enabled).lower()}", + f'{timer_type}_state|string|{timer_state}')) + +def fmt_all_timers_yambar(timer_strs): + all_timers_str = "\n".join(timer_strs) + return f"{all_timers_str}\n" + +def fmt_timer_json(enabled, time_left, limit, timer_type, timer_state, colors): + limit_str_key_prefix = (f"daily" if timer_type == "dailylimit" + else f"{timer_type}_") + + return ", ".join([f'"{timer_type}_enabled": {str(enabled).lower()}', + f'"{timer_type}_left_in_seconds": {time_left}', + f'"{limit_str_key_prefix}limit_in_seconds": {limit}', + f'"{timer_type}_left_str": "{seconds_to_time_str(time_left)}"', + f'"{limit_str_key_prefix}limit_str": "{seconds_to_time_str(limit)}"', + f'"{timer_type}_state": "{timer_state}"', + f'"{timer_type}_fgcol": "{colors[0]}"', + f'"{timer_type}_bgcol": "{colors[1]}"']) + +def fmt_all_timers_json(timer_strs): + all_timers_str = ", ".join(timer_strs) + return f"{{{all_timers_str}}}" + +fmt_info_dict = { + "plain": (fmt_timer_plain, fmt_all_timers_plain), + "waybar": (fmt_timer_waybar, fmt_all_timers_waybar), + "yambar": (fmt_timer_yambar, fmt_all_timers_yambar), + "json": (fmt_timer_json, fmt_all_timers_json) +} + +#### Shouldn't need to edit anything below here. #### + +def seconds_to_time_str(tot_num_sec): + abs_tot_num_sec = abs(tot_num_sec) + sign = "" if tot_num_sec >= 0 else "-" + + if abs_tot_num_sec >= 3600: + num_hr, rem_num_sec = divmod(abs_tot_num_sec, 3600) + num_min, num_sec = divmod(rem_num_sec, 60) + + return f"{sign}{num_hr}:{num_min:02d}:{num_sec:02d}" + else: + num_min, num_sec = divmod(abs_tot_num_sec, 60) + return f"{sign}{num_min}:{num_sec:02d}" + +def get_timer_state(time_left, limit): + if time_left < 0: + return "overdue" + elif time_left/limit <= 0.1: + return "close to break" + else: + return "default" + +def timer_str(timer_type, wr_core, wr_cfg, fmt_timer_func, color_dict): + + timer_enabled_path = { + "microbreak": "/breaks/micro-pause/enabled", + "restbreak": "/breaks/rest-break/enabled", + "dailylimit": "/breaks/daily-limit/enabled"}[timer_type] + + timer_limit_path = { + "microbreak": "/timers/micro_pause/limit", + "restbreak": "/timers/rest_break/limit", + "dailylimit": "/timers/daily_limit/limit"}[timer_type] + + enabled = wr_cfg.GetBool(timer_enabled_path)[0] + + limit = wr_cfg.GetInt(timer_limit_path)[0] + time_left = limit - wr_core.GetTimerElapsed(timer_type) + + timer_state = get_timer_state(time_left, limit) + colors = color_dict[timer_state] + + return fmt_timer_func(enabled, time_left, limit, timer_type, timer_state, colors) + +# def microbreak_str(wr_core, wr_cfg, fmt_timer_func, color_dict): +# return timer_str("microbreak", wr_core, wr_cfg, fmt_timer_func, color_dict) + +# def restbreak_str(wr_core, wr_cfg, fmt_timer_func, color_dict): +# return timer_str("restbreak", wr_core, wr_cfg, fmt_timer_func, color_dict) + +# def dailylimit_str(wr_core, wr_cfg, fmt_timer_func, color_dict): +# return timer_str("dailylimit", wr_core, wr_cfg, fmt_timer_func, color_dict) + +output_fmts = tuple(fmt_info_dict.keys()) + +parser = argparse.ArgumentParser() + +parser.add_argument("-i", "--polling-interval", type = float, default = 1.0, + help = "Time interval for polling Workrave, in seconds " + "[default = %(default)s]") + +parser.add_argument("-f", "--format", + choices = output_fmts, default = output_fmts[0], + help = "Format for output [default = %(default)s]") + +parser.add_argument("--colors-default", nargs = 2, default = ["black", "skyblue"], + help = "Default timer colors (if color is used in the output " + "format). First color is text color, second is background color. " + "[default = %(default)s]") + +parser.add_argument("--colors-close-to-break", nargs = 2, default = ["black", "orange"], + help = "Timer color when close to break time (if color is used in " + "the output format). First color is text color, second is " + "background color. [default = %(default)s]") + +parser.add_argument("--colors-overdue", nargs = 2, default = ["white", "red"], + help = "Timer colors when interval between breaks exceeded (if " + "color is used in the output format. First color is text color, " + "second is background color. [default = %(default)s]") + +args = parser.parse_args() + +fmt_timer_func, fmt_all_timers_func = fmt_info_dict[args.format] + +color_dict = { + "default": args.colors_default, + "close to break": args.colors_close_to_break, + "overdue": args.colors_overdue +} + +session_bus = pydbus.SessionBus() + +wr_core = session_bus.get('org.workrave.Workrave', + '/org/workrave/Workrave/Core') + +wr_cfg = wr_core["org.workrave.ConfigInterface"] + +while True: + + print( + fmt_all_timers_func( + [timer_str(timer_type, wr_core, wr_cfg, fmt_timer_func, color_dict) + for timer_type in ("microbreak", "restbreak", "dailylimit")] + ), flush = True + ) + + time.sleep(args.polling_interval) diff --git a/contrib/waybar-yambar-applets/workrave-open.py b/contrib/waybar-yambar-poss-other-applets/workrave-open.py similarity index 100% rename from contrib/waybar-yambar-applets/workrave-open.py rename to contrib/waybar-yambar-poss-other-applets/workrave-open.py