put config block in a function, add config for gui and update example conf
This commit is contained in:
@@ -47,6 +47,21 @@ def volume_increase(name):
|
||||
result = volume(name)
|
||||
return result
|
||||
|
||||
def config_load():
|
||||
config = ConfigParser(strict=False)
|
||||
config_file = "controldeck.conf"
|
||||
full_config_file_path = path.dirname(path.realpath(__file__)) + sep + config_file
|
||||
if not path.exists(config_file):
|
||||
config_folder = path.join(path.expanduser("~"), '.config', APP_NAME.lower())
|
||||
makedirs(config_folder, exist_ok=True)
|
||||
full_config_file_path = path.join(config_folder, config_file)
|
||||
try:
|
||||
config.read(full_config_file_path)
|
||||
except Exception as e:
|
||||
print(f"{e}")
|
||||
#print(config.sections())
|
||||
return config
|
||||
|
||||
class Button(Div):
|
||||
command = None
|
||||
def __init__(self, **kwargs):
|
||||
@@ -99,18 +114,7 @@ def application():
|
||||
# div2 = Div(classes="flex flex-wrap", a=wp)
|
||||
# Button(text="Sleep", command='systemctl suspend', a=div2)
|
||||
|
||||
config = ConfigParser(strict=False)
|
||||
config_file = "controldeck.conf"
|
||||
full_config_file_path = path.dirname(path.realpath(__file__)) + sep + config_file
|
||||
if not path.exists(config_file):
|
||||
config_folder = path.join(path.expanduser("~"), '.config', APP_NAME.lower())
|
||||
makedirs(config_folder, exist_ok=True)
|
||||
full_config_file_path = path.join(config_folder, config_file)
|
||||
try:
|
||||
config.read(full_config_file_path)
|
||||
except Exception as e:
|
||||
print(f"{e}")
|
||||
#print(config.sections())
|
||||
config = config_load()
|
||||
volume_dict = {}
|
||||
button_dict = {}
|
||||
for i in config.sections():
|
||||
|
||||
@@ -7,14 +7,64 @@ def main():
|
||||
if controldeck.process("ps -ef | grep -i controldeck.py | grep -v grep") == "":
|
||||
controldeck.main()
|
||||
|
||||
config = controldeck.config_load()
|
||||
try:
|
||||
width = int(config.get('gui', 'width', fallback=800))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
width = 800
|
||||
try:
|
||||
height = int(config.get('gui', 'height', fallback=600))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
width = 600
|
||||
try:
|
||||
x = int(config.get('gui', 'x', fallback=''))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
x = None
|
||||
try:
|
||||
y = int(config.get('gui', 'y', fallback=''))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
y = None
|
||||
resizable = config.get('gui', 'resizable', fallback='True').title() == 'True'
|
||||
fullscreen = config.get('gui', 'fullscreen', fallback='False').title() == 'True'
|
||||
try:
|
||||
min_width = int(config.get('gui', 'min_width', fallback=200))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
min_width = 200
|
||||
try:
|
||||
min_height = int(config.get('gui', 'min_height', fallback=100))
|
||||
except ValueError as e:
|
||||
print(f"{e}")
|
||||
min_width = 100
|
||||
min_size = (min_width, min_height)
|
||||
frameless = config.get('gui', 'frameless', fallback='False').title() == 'True'
|
||||
minimized = config.get('gui', 'minimized', fallback='False').title() == 'True'
|
||||
on_top = config.get('gui', 'always_on_top', fallback='False').title() == 'True'
|
||||
|
||||
create_window("ControlDeck",
|
||||
url="http://0.0.0.0:8000",
|
||||
width=800,
|
||||
height=600,
|
||||
frameless=True,
|
||||
html=None,
|
||||
js_api=None,
|
||||
width=width,
|
||||
height=height,
|
||||
x=x,
|
||||
y=y,
|
||||
resizable=resizable,
|
||||
fullscreen=fullscreen,
|
||||
min_size=min_size,
|
||||
hidden=False,
|
||||
frameless=frameless,
|
||||
easy_drag=True,
|
||||
minimized=minimized,
|
||||
on_top=on_top,
|
||||
confirm_close=False,
|
||||
background_color='#000000',
|
||||
transparent=True)
|
||||
transparent=True,
|
||||
text_select=False)
|
||||
start()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# [N.volume.NAME]
|
||||
# name = sink_name
|
||||
# : N. optional group/row specification
|
||||
# : N. optional number to specify group/row
|
||||
# : NAME name of the button
|
||||
# : name sink name, see name with either:
|
||||
# pactl list sinks short
|
||||
@@ -16,5 +16,19 @@
|
||||
# : NAME name of the button
|
||||
# : command command(s) to run
|
||||
|
||||
[gui]
|
||||
width = 800
|
||||
height = 600
|
||||
# x and y specifying the window coordinate (empty = centered)
|
||||
x =
|
||||
y =
|
||||
resizable = True
|
||||
fullscreen = False
|
||||
min_width = 200
|
||||
min_height = 100
|
||||
frameless = False
|
||||
minimized = False
|
||||
always_on_top = False
|
||||
|
||||
[4.button.Test]
|
||||
command = notify-send -a foo baz
|
||||
|
||||
Reference in New Issue
Block a user