diff --git a/Taskfile.azure.yml b/Taskfile.azure.yml new file mode 100644 index 0000000..22c691e --- /dev/null +++ b/Taskfile.azure.yml @@ -0,0 +1,40 @@ +version: '3' + +tasks: + build: + desc: Build Azure artifacts + deps: [rewrite] + cmds: + - defer: { task: restore } + - for: + matrix: + KIND: [basic, banana, potato] + THEME: [azure-light, azure-dark] + cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/azure/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec + + rewrite: + internal: true + desc: Run the source code rewriter + cmds: + - poetry run python tools/rewriter.py --rewrite --theme {{.THEME}} + + restore: + internal: true + desc: Restore the backup files + cmds: + - poetry run python tools/rewriter.py --restore + + compress: + desc: Compress Azure artifacts + cmds: + - for: + matrix: + KIND: [basic, banana, potato] + THEME: [azure-light, azure-dark] + cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"' + + clean: + desc: Clean build and dist directories + cmds: + - | + {{.SHELL}} -Command "Remove-Item -Path build/azure-*,dist/azure-* -Recurse -Force" diff --git a/Taskfile.forest.yml b/Taskfile.forest.yml new file mode 100644 index 0000000..5d49434 --- /dev/null +++ b/Taskfile.forest.yml @@ -0,0 +1,40 @@ +version: '3' + +tasks: + build: + desc: Build Forest artifacts + deps: [rewrite] + cmds: + - defer: { task: restore } + - for: + matrix: + KIND: [basic, banana, potato] + THEME: [forest-light, forest-dark] + cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/forest/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec + + rewrite: + internal: true + desc: Run the source code rewriter + cmds: + - poetry run python tools/rewriter.py --rewrite --theme {{.THEME}} + + restore: + internal: true + desc: Restore the backup files + cmds: + - poetry run python tools/rewriter.py --restore + + compress: + desc: Compress Forest artifacts + cmds: + - for: + matrix: + KIND: [basic, banana, potato] + THEME: [forest-light, forest-dark] + cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"' + + clean: + desc: Clean build and dist directories + cmds: + - | + {{.SHELL}} -Command "Remove-Item -Path build/forest-*,dist/forest-* -Recurse -Force" diff --git a/Taskfile.sunvalley.yml b/Taskfile.sunvalley.yml new file mode 100644 index 0000000..711e93c --- /dev/null +++ b/Taskfile.sunvalley.yml @@ -0,0 +1,24 @@ +version: '3' + +tasks: + build: + desc: Build Sunvalley artifacts + cmds: + - for: + matrix: + KIND: [basic, banana, potato] + cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley/sunvalley-{{.ITEM.KIND}}.spec + + compress: + desc: Compress Sunvalley artifacts + cmds: + - for: + matrix: + KIND: [basic, banana, potato] + cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"' + + clean: + desc: Clean build and dist directories + cmds: + - | + {{.SHELL}} -Command "Remove-Item -Path build/sunvalley-*,dist/sunvalley-* -Recurse -Force" diff --git a/Taskfile.yml b/Taskfile.yml index c188757..081b3c8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,5 +1,19 @@ version: '3' +includes: + sunvalley: + taskfile: ./Taskfile.sunvalley.yml + vars: + THEME: sunvalley + forest: + taskfile: ./Taskfile.forest.yml + vars: + THEME: forest + azure: + taskfile: ./Taskfile.azure.yml + vars: + THEME: azure + vars: SHELL: pwsh @@ -18,64 +32,24 @@ tasks: build: desc: Build all artifacts - cmds: - - task: build-sunvalley - - echo "Sunvalley build complete" - - task: build-forest - - echo "Forest build complete" - - build-sunvalley: - desc: Build Sunvalley artifacts cmds: - for: matrix: - KIND: [basic, banana, potato] - cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley-{{.ITEM.KIND}}.spec - - build-forest: - desc: Build Forest artifacts - deps: [rewrite] - cmds: - - defer: { task: restore } - - for: - matrix: - KIND: [basic, banana, potato] - THEME: [light, dark] - cmd: poetry run pyinstaller --noconfirm --distpath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} spec/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.spec - - rewrite: - internal: true - desc: Run the source code rewriter - cmds: - - poetry run python tools/rewriter.py --rewrite - - restore: - internal: true - desc: Restore the backup files - cmds: - - poetry run python tools/rewriter.py --restore + THEME: [sunvalley, forest, azure] + task: '{{.ITEM.THEME}}:build' compress: - deps: [compress-sunvalley, compress-forest] - - compress-sunvalley: + desc: Compress all artifacts cmds: - for: matrix: - KIND: [basic, banana, potato] - cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"' - - compress-forest: - cmds: - - for: - matrix: - KIND: [basic, banana, potato] - THEME: [light, dark] - cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} -DestinationPath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.zip -Force"' + THEME: [sunvalley, forest, azure] + task: '{{.ITEM.THEME}}:compress' clean: desc: Clean up build and dist directories cmds: - - | - {{.SHELL}} -Command " - Remove-Item -Path build/forest-*,build/sunvalley-*,dist/forest-*,dist/sunvalley-* -Recurse -Force" + - for: + matrix: + THEME: [sunvalley, forest, azure] + task: '{{.ITEM.THEME}}:clean' diff --git a/configs/app.toml b/configs/app.toml index 3cd3c08..aaa0a8f 100644 --- a/configs/app.toml +++ b/configs/app.toml @@ -1,10 +1,9 @@ # load a specific profile on start (file name without .toml ext) # [configs] # config="example" -# load with themes enabled? set the default mode +# load with themes enabled? [theme] enabled = true -mode = "light" # load in extended mode? if so which orientation [extends] extended = true @@ -22,4 +21,4 @@ size = 3 default = 0 # show the navigation frame? [navigation] -show = true +show = false diff --git a/configs/vban.toml b/configs/vban.toml index 33fbe27..a955382 100644 --- a/configs/vban.toml +++ b/configs/vban.toml @@ -2,12 +2,12 @@ ### set the ip then uncomment # [connection-1] # kind = 'banana' -# ip = '' +# ip = 'localhost' # streamname = 'Command1' # port = 6980 # [connection-2] # kind = 'potato' -# ip = '' +# ip = 'gamepc.local' # streamname = 'Command1' # port = 6980 diff --git a/tools/rewriter.py b/tools/rewriter.py index 5bc545e..f0e1ad1 100644 --- a/tools/rewriter.py +++ b/tools/rewriter.py @@ -16,7 +16,7 @@ def write_outs(output, outs: tuple): output.write(out) -def rewrite_app(): +def rewrite_app(theme): app_logger = logger.getChild('app') app_logger.info('rewriting app.py') infile = Path(SRC_DIR) / 'app.bk' @@ -34,24 +34,28 @@ def rewrite_app(): ( ' self._vmr = vmr\n', ' self._theme = theme\n', + ' self._theme_name = theme.split("-")[0]\n', + ' self._theme_type = theme.split("-")[-1]\n', ' tcldir = Path.cwd() / "theme"\n', ' if not tcldir.is_dir():\n', ' tcldir = Path.cwd() / "_internal" / "theme"\n', - ' self.tk.call("source", tcldir.resolve() / f"forest-{self._theme}.tcl")\n', + ' match self._theme_name:\n', + ' case "forest":\n', + ' self.tk.call("source", tcldir.resolve() / f"{self._theme}.tcl")\n', + ' case "azure":\n', + ' self.tk.call("source", tcldir.resolve() / f"{self._theme_name}.tcl")\n', ), ) # def connect() case 'def connect(kind_id: str, vmr) -> App:\n': - output.write( - 'def connect(kind_id: str, vmr, theme="light") -> App:\n' - ) + output.write('def connect(kind_id: str, vmr, theme) -> App:\n') case ' return VMMIN_cls(vmr)\n': output.write(' return VMMIN_cls(vmr, theme)\n') case _: output.write(line) -def rewrite_builders(): +def rewrite_builders(theme): builders_logger = logger.getChild('builders') builders_logger.info('rewriting builders.py') infile = Path(SRC_DIR) / 'builders.bk' @@ -71,15 +75,26 @@ def rewrite_builders(): case 'import sv_ttk\n': output.write('#import sv_ttk\n') case ' self.app.resizable(False, False)\n': - write_outs( - output, - ( - ' self.app.resizable(False, False)\n' - ' if _configuration.themes_enabled:\n', - ' ttk.Style().theme_use(f"forest-{self.app._theme}")\n', - ' self.logger.info(f"Forest Theme applied")\n', - ), - ) + if theme.startswith('forest'): + write_outs( + output, + ( + ' self.app.resizable(False, False)\n' + ' if _configuration.themes_enabled:\n', + ' ttk.Style().theme_use(self.app._theme)\n', + ' self.logger.info(f"{self.app._theme} Theme applied")\n', + ), + ) + elif theme.startswith('azure'): + write_outs( + output, + ( + ' self.app.resizable(False, False)\n' + ' if _configuration.themes_enabled:\n', + ' self.app.tk.call("set_theme", self.app._theme_type)\n', + ' self.logger.info(f"Azure {self.app._theme_type} Theme applied")\n', + ), + ) ignore_next_lines = 6 # setting navframe button widths case ' variable=self.navframe.submix,\n': @@ -171,12 +186,21 @@ def rewrite_builders(): ) case _: if 'Toggle.TButton' in line: - output.write(line.replace('Toggle.TButton', 'ToggleButton')) + if theme.startswith('forest'): + output.write( + line.replace('Toggle.TButton', 'ToggleButton') + ) + elif theme.startswith('azure'): + output.write( + line.replace( + 'Toggle.TButton', 'Switch.TCheckbutton' + ) + ) else: output.write(line) -def rewrite_menu(): +def rewrite_menu(theme): menu_logger = logger.getChild('menu') menu_logger.info('rewriting menu.py') infile = Path(SRC_DIR) / 'menu.bk' @@ -199,7 +223,7 @@ def rewrite_menu(): output.write(line) -def prepare_for_build(): +def prepare_for_build(theme): ################# MOVE FILES FROM PACKAGE DIR INTO SRC DIR ######################### for file in ( PACKAGE_DIR / 'app.py', @@ -211,12 +235,8 @@ def prepare_for_build(): file.rename(SRC_DIR / f'{file.stem}.bk') ###################### RUN THE FILE REWRITER FOR EACH *.BK ######################### - steps = ( - rewrite_app, - rewrite_builders, - rewrite_menu, - ) - [step() for step in steps] + for step in (rewrite_app, rewrite_builders, rewrite_menu): + step(theme) def cleanup(): @@ -239,12 +259,13 @@ def cleanup(): if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--rewrite', action='store_true') + parser.add_argument('--theme', type=str, default='forest') parser.add_argument('--restore', action='store_true') args = parser.parse_args() if args.rewrite: logger.info('preparing files for build') - prepare_for_build() + prepare_for_build(args.theme) elif args.restore: logger.info('cleaning up files') cleanup() diff --git a/vmcompact/configurations.py b/vmcompact/configurations.py index 1dbe734..a6c2f16 100644 --- a/vmcompact/configurations.py +++ b/vmcompact/configurations.py @@ -60,7 +60,7 @@ _defaults = { 'submixes': { 'default': 0, }, - 'navigation': {'show': True}, + 'navigation': {'show': False}, }