rewrite complete!
This commit is contained in:
parent
ae7679866a
commit
39e79942d8
6 changed files with 56 additions and 48 deletions
3
deps
3
deps
|
@ -1,3 +0,0 @@
|
|||
pyyaml 6.0 YAML parser and emitter for Python
|
||||
schema 0.7.5 Simple data validation library
|
||||
└── contextlib2 >=0.5.5
|
|
@ -1,9 +1,12 @@
|
|||
class Bar:
|
||||
def __init__(self):
|
||||
def __init__(self, seperator, margin):
|
||||
self.left = []
|
||||
self.center = []
|
||||
self.right = []
|
||||
|
||||
self.seperator = seperator
|
||||
self.margin = margin
|
||||
|
||||
def add_module(self, module):
|
||||
match module.alignment:
|
||||
case "left":
|
||||
|
@ -13,15 +16,23 @@ class Bar:
|
|||
case "right":
|
||||
self.right.append(module)
|
||||
|
||||
def print(self):
|
||||
print("%{l}", end='')
|
||||
for module in self.left:
|
||||
print(module.text, end='')
|
||||
print("%{c}", end='')
|
||||
for module in self.center:
|
||||
print(module.text, end='')
|
||||
print("%{r}", end='')
|
||||
for module in self.right:
|
||||
def __print_alignment_group(self, alignment_group):
|
||||
for index, module in enumerate(alignment_group):
|
||||
print(module.text, end='')
|
||||
if len(module.text) > 0:
|
||||
for i in range(index+1, len(alignment_group)):
|
||||
if len(alignment_group[i].text) > 0:
|
||||
print(self.seperator, end='')
|
||||
break
|
||||
|
||||
print(flush=True)
|
||||
def print(self):
|
||||
print("%{l}" + self.margin, end='')
|
||||
self.__print_alignment_group(self.left)
|
||||
|
||||
print("%{c}", end='')
|
||||
self.__print_alignment_group(self.center)
|
||||
|
||||
print("%{r}", end='')
|
||||
self.__print_alignment_group(self.right)
|
||||
|
||||
print(self.margin, flush=True)
|
||||
|
|
|
@ -1,4 +1,31 @@
|
|||
from config_parsing import get_lemonbar_flags, get_validated_config
|
||||
from parse_config_file import get_bar_config_and_module_config_list
|
||||
|
||||
def generate_flags(bar_config):
|
||||
flags = ""
|
||||
for option in bar_config:
|
||||
match option:
|
||||
case 'geometry':
|
||||
flags += (" -g '" + bar_config[option] + "'")
|
||||
case 'bottom':
|
||||
flags += (" -b")
|
||||
case 'force':
|
||||
flags += (" -d")
|
||||
case 'font':
|
||||
flags += (" -f '" + bar_config[option] + "'")
|
||||
case 'name':
|
||||
flags += (" -n '" + bar_config[option] + "'")
|
||||
case 'line_thickness':
|
||||
flags += (" -u " + str(bar_config[option]))
|
||||
case 'bg_color':
|
||||
flags += (" -B '" + bar_config[option] + "'")
|
||||
case 'fg_color':
|
||||
flags += (" -F '" + bar_config[option] + "'")
|
||||
case 'offset':
|
||||
flags += (" -o " + str(bar_config[option]))
|
||||
case 'line_color':
|
||||
flags += (" -U '" + bar_config[option] + "'")
|
||||
return flags.strip()
|
||||
|
||||
print(get_lemonbar_flags(get_validated_config("./testing_config.yml")))
|
||||
bar_config, module_config_list = get_bar_config_and_module_config_list("/home/noah/src/easyconf-lemonbar/data/testing_config.yml")
|
||||
|
||||
print(generate_flags(bar_config))
|
||||
|
|
|
@ -5,8 +5,10 @@ from parse_config_file import get_bar_config_and_module_config_list
|
|||
def main():
|
||||
bar_config, module_config_list = get_bar_config_and_module_config_list("/home/noah/src/easyconf-lemonbar/data/testing_config.yml")
|
||||
padding = bar_config["padding"]
|
||||
seperator = bar_config["seperator"]
|
||||
margin = bar_config["margin"]
|
||||
|
||||
bar = Bar()
|
||||
bar = Bar(seperator, margin)
|
||||
|
||||
for module_config in module_config_list:
|
||||
module = Module(module_config, padding, bar)
|
||||
|
|
|
@ -55,32 +55,3 @@ def get_bar_config_and_module_config_list(filename):
|
|||
return validated_config["bar"]["config"], validated_config["bar"]["modules"]
|
||||
except SchemaError as se:
|
||||
raise se
|
||||
|
||||
|
||||
|
||||
def get_lemonbar_flags(config):
|
||||
configuration_options = config["bar"]["config"]
|
||||
flags = ""
|
||||
for option in configuration_options:
|
||||
match option:
|
||||
case 'geometry':
|
||||
flags += (" -g '" + configuration_options[option] + "'")
|
||||
case 'bottom':
|
||||
flags += (" -b")
|
||||
case 'force':
|
||||
flags += (" -d")
|
||||
case 'font':
|
||||
flags += (" -f '" + configuration_options[option] + "'")
|
||||
case 'name':
|
||||
flags += (" -n '" + configuration_options[option] + "'")
|
||||
case 'line_thickness':
|
||||
flags += (" -u " + str(configuration_options[option]))
|
||||
case 'bg_color':
|
||||
flags += (" -B '" + configuration_options[option] + "'")
|
||||
case 'fg_color':
|
||||
flags += (" -F '" + configuration_options[option] + "'")
|
||||
case 'offset':
|
||||
flags += (" -o " + str(configuration_options[option]))
|
||||
case 'line_color':
|
||||
flags += (" -U '" + configuration_options[option] + "'")
|
||||
return flags.strip()
|
||||
|
|
4
run.sh
4
run.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
lemonbar="lemonbar $(python lemonbar_command.py)"
|
||||
lemonbar="lemonbar $(python ./easyconf-lemonbar/lemonbar_command.py)"
|
||||
|
||||
python main.py | sh -c "${lemonbar}"
|
||||
python ./easyconf-lemonbar/main.py | sh -c "${lemonbar}"
|
||||
|
|
Loading…
Reference in a new issue