diff --git a/scripts/config.py b/scripts/config.py index a71e318..cbc4797 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -29,6 +29,12 @@ def load(): if not configData["settings"].get("output"): configData["settings"]["output"] = "raspi-teletext" + if not configData["settings"].get("packetServer"): + configData["settings"]["packetServer"] = False + + if not configData["settings"].get("packetServerPort"): + configData["settings"]["packetServerPort"] = 19761 + return configData def save(configData): @@ -155,4 +161,4 @@ def doServiceInstall(type, path, url): text += process.stdout.decode("utf8") raise RuntimeError(text) else: - raise RuntimeError("unknown service type") \ No newline at end of file + raise RuntimeError("unknown service type") diff --git a/scripts/runvbit2.py b/scripts/runvbit2.py index 7697b1a..5721422 100755 --- a/scripts/runvbit2.py +++ b/scripts/runvbit2.py @@ -36,12 +36,16 @@ def signalHandler(_signo, _stack_frame): # could check for overrides in the json config here too if vbit2 gains a command argument to override lines per field -output = configData["settings"].get("output") -if not output: - print("no output type selected") - quit() +cmdline = [os.path.join(os.getenv('HOME'), ".local/bin/vbit2"), "--dir", service["path"]] +prerun = [] +postrun = [] -if output == "raspi-teletext": +output = configData["settings"].get("output") +if output == "none": + # disables piped output! + cmdline.append("--format") + cmdline.append("none") +elif output == "raspi-teletext": prerun = ["sudo", os.path.join(os.getenv('HOME'), "raspi-teletext/tvctl"), "on"] postrun = ["sudo", os.path.join(os.getenv('HOME'), "raspi-teletext/tvctl"), "off"] @@ -58,13 +62,20 @@ def signalHandler(_signo, _stack_frame): if prerun: subprocess.run(prerun) -vbit = subprocess.Popen([os.path.join(os.getenv('HOME'), ".local/bin/vbit2"), "--dir", service["path"]], stdout=subprocess.PIPE) +packetServerPort = configData["settings"].get("packetServerPort") +if configData["settings"].get("packetServer") and packetServerPort: + cmdline.append("--packetserver") + cmdline.append(str(packetServerPort)) + +vbit = subprocess.Popen(cmdline, stdout=subprocess.PIPE) signal.signal(signal.SIGTERM, signalHandler) signal.signal(signal.SIGINT, signalHandler) -subprocess.Popen(destproc, stdin=vbit.stdout) +if not output == "none": + subprocess.Popen(destproc, stdin=vbit.stdout) + vbit.wait() if postrun: - subprocess.run(postrun) \ No newline at end of file + subprocess.run(postrun) diff --git a/scripts/vbit-config.py b/scripts/vbit-config.py index 2298c8a..669c2ba 100755 --- a/scripts/vbit-config.py +++ b/scripts/vbit-config.py @@ -214,8 +214,10 @@ def uninstallService(): config.uninstallService(name) def optionsMenu(): + configData = config.load() updateEnabled = subprocess.run(["systemctl", "--user", "is-enabled", "teletext-update.timer"], capture_output=True, text=True).stdout == "enabled\n" bootEnabled = subprocess.run(["systemctl", "--user", "is-enabled", "vbit2.service"], capture_output=True, text=True).stdout == "enabled\n" + serverEnabled = configData["settings"].get("packetServer") options = [("U", "Automatically update selected service")] @@ -231,6 +233,13 @@ def optionsMenu(): else: options[1] += ("off",) + options += [("S", "Enable teletext packet server")] + + if serverEnabled: + options[2] += ("on",) + else: + options[2] += ("off",) + code, tags = d.checklist("",choices=options, title="Options", no_tags=True, no_cancel=True) if code == "ok": @@ -246,6 +255,14 @@ def optionsMenu(): if "B" in tags and not bootEnabled: # run at boot was clear, now enabled subprocess.run(["systemctl", "--user", "enable", "vbit2.service"], stderr=subprocess.DEVNULL) + if not "S" in tags and serverEnabled: + # server was enabled, now clear + configData["settings"]["packetServer"] = False + config.save(configData) + if "S" in tags and not serverEnabled: + # server was clear, now enabled + configData["settings"]["packetServer"] = True + config.save(configData) def mainMenu(): while True: @@ -292,4 +309,4 @@ def mainMenu(): if __name__ == "__main__": mainMenu() - os.system('clear') \ No newline at end of file + os.system('clear') diff --git a/version.h b/version.h index 48d4e4b..71009d6 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #ifndef _VERSION_H_ #define _VERSION_H_ -#define VBIT2_VERSION "v2.6.0" +#define VBIT2_VERSION "v2.7.0" #endif