Skip to content

Commit

Permalink
Add packet server option to vbit-config and bump version number
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXGuesser committed Apr 7, 2024
1 parent f4ac9f4 commit 25c387c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
8 changes: 7 additions & 1 deletion scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -155,4 +161,4 @@ def doServiceInstall(type, path, url):
text += process.stdout.decode("utf8")
raise RuntimeError(text)
else:
raise RuntimeError("unknown service type")
raise RuntimeError("unknown service type")
27 changes: 19 additions & 8 deletions scripts/runvbit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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)
subprocess.run(postrun)
19 changes: 18 additions & 1 deletion scripts/vbit-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand All @@ -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":
Expand All @@ -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:
Expand Down Expand Up @@ -292,4 +309,4 @@ def mainMenu():

if __name__ == "__main__":
mainMenu()
os.system('clear')
os.system('clear')
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _VERSION_H_
#define _VERSION_H_

#define VBIT2_VERSION "v2.6.0"
#define VBIT2_VERSION "v2.7.0"

#endif

0 comments on commit 25c387c

Please sign in to comment.