added no-refresh feature

This commit is contained in:
Noah Swerhun 2023-02-18 13:14:08 -06:00
parent 3b6fa63e7b
commit ef21228dcf
4 changed files with 6 additions and 3 deletions

View file

@ -22,7 +22,7 @@ def get_validated_config(filename):
{
"name": str,
"command": str,
"refresh": And(int, lambda n : n > 0),
"refresh": And(int, lambda n : n >= 0),
Optional("prefix"): str,
"format": {
"align": Or("left", "center", "right"),

View file

@ -53,8 +53,9 @@ bar:
# text that will be displayed for this module. `date` here is used as an
# example. THIS IS A REQUIRED FIELD.
command: "date"
# How often to re-run the command and display the updated text. THIS IS A
# REQUIRED FIELD.
# How often (in milliseconds) to re-run the command and display the
# updated text. If this value is 0, then the module will not be
# refreshed. THIS IS A REQUIRED FIELD.
refresh: 1000
# Prefix to be printed before the text of the command.
prefix: "DATE: "

View file

@ -36,6 +36,8 @@ def new_module_thread(alignment, pre, name, prefix, command, post, refresh):
module_string = create_module_string(pre, prefix, command, post)
running_modules_dict[alignment][name] = module_string
print_bar()
if refresh == 0:
break
sleep(refresh/1000)