added global padding feature

This commit is contained in:
Noah Swerhun 2023-03-10 21:47:01 -06:00
parent 5a28ec0b49
commit 1ae9b10caa
5 changed files with 12 additions and 3 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
testing_config.yml testing_config.yml
__pycache__

View file

@ -16,7 +16,8 @@ def get_validated_config(filename):
Optional("offset"): int, Optional("offset"): int,
Optional("line_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'), Optional("line_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'),
Optional("padding", default=" "): str, Optional("padding", default=" "): str,
Optional("seperator", default="|"): str Optional("seperator", default="|"): str,
Optional("global_padding", default=""): str
}, },
"modules": [ "modules": [
{ {

View file

@ -38,6 +38,9 @@ bar:
# Seperator between modules. Module formatting options are not applied to # Seperator between modules. Module formatting options are not applied to
# the seperator. # the seperator.
seperator: "|" seperator: "|"
# Padding on either end of the bar itself. This will be placed before and
# after all text on the bar.
global_padding: ""
# Here is where you can define a list your individual modules. You can define # Here is where you can define a list your individual modules. You can define
# as many modules as you want. Some fields are required; these will be # as many modules as you want. Some fields are required; these will be

View file

@ -9,7 +9,7 @@ def print_bar():
for alignment in running_modules_dict: for alignment in running_modules_dict:
match alignment: match alignment:
case "left": case "left":
print("%{l}", end="") print("%{l}" + global_padding, end="")
case "center": case "center":
print("%{c}", end="") print("%{c}", end="")
case "right": case "right":
@ -26,7 +26,9 @@ def print_bar():
if len(group[i]) > 0: if len(group[i]) > 0:
print(seperator, end="") print(seperator, end="")
break; break;
if alignment == "right":
print(global_padding, end="")
print(flush=True) print(flush=True)
def create_module_string(pre, prefix, command, post): def create_module_string(pre, prefix, command, post):
@ -51,10 +53,12 @@ def new_module_thread(alignment, pre, name, prefix, command, post, refresh):
def main(): def main():
global padding global padding
global seperator global seperator
global global_padding
config = get_validated_config("./testing_config.yml") config = get_validated_config("./testing_config.yml")
padding = config["bar"]["config"]["padding"] padding = config["bar"]["config"]["padding"]
seperator = config["bar"]["config"]["seperator"] seperator = config["bar"]["config"]["seperator"]
global_padding = config["bar"]["config"]["global_padding"]
modules = config["bar"]["modules"] modules = config["bar"]["modules"]