From 488f7df5e84e6d67d9d7ca38b83c67c88ff49578 Mon Sep 17 00:00:00 2001 From: avollkopf Date: Fri, 6 Feb 2026 13:33:42 +0100 Subject: [PATCH 1/4] add option for firefoxfullscreen autostart in cli --- cbpi/__init__.py | 2 +- cbpi/cli.py | 134 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 132 insertions(+), 4 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 9df7ac54..49565bb5 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,2 +1,2 @@ -__version__ = "4.7.1" +__version__ = "4.7.2.a1" __codename__ = "Winter Bock" diff --git a/cbpi/cli.py b/cbpi/cli.py index 9511455e..edfa71dd 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -21,6 +21,7 @@ import pkgutil import platform import shutil +from shutil import which import time from subprocess import call @@ -291,6 +292,125 @@ def autostart(self, name): print(e) return return + + def firefox(self, name): + """Enable or disable firefox fullscreen mode""" + wlrctl_available = True + wtype_available = True + if which("firefox") is None: + print("Firefox is not installed. Please install firefox to use this feature.") + return + if which("wlrctl") is None: + wlrctl_available = False + if which("wtype") is None: + wtype_available = False + if wlrctl_available is False or wtype_available is False: + print("wlrctl or wtype is not installed. Please install them to use this feature.") + print("Please run 'sudo apt install wlrctl wtype' to install them on Debian based systems") + return + try: + version = int(distro.version()) + except: + version = 0 + + if version < 13: + print("Firefox fullscreen mode is only supported on Raspbian versions > 13 (trixie)") + else: + user = pwd.getpwuid(os.getuid()).pw_name + file = "/home/" + user + "/.config/labwc/autostart" + + if name == "status": + if os.path.exists(file) is False: + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}OFF{}".format( + Fore.RED, Style.RESET_ALL + ) + ) + return + with open(file, "r") as f: + lines = f.readlines() + firefoxfound = False + for line in lines: + if line.find("firefox") != -1: + firefoxfound = True + if firefoxfound is True: + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}ON{}".format( + Fore.LIGHTGREEN_EX, Style.RESET_ALL + ) + ) + else: + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}OFF{}".format( + Fore.RED, Style.RESET_ALL + ) + ) + return + pass + elif name == "on": + print("Add firefox to labwc autostart") + command='bash -c "sleep 20 && firefox --url http://localhost:8000 & wlrctl toplevel waitfor firefoox && wlrctl window focus firefox && wtype -P F11 -p F11"' + try: + if os.path.exists(file) is False: + pathlib.Path(file).mkdir(parents=True, exist_ok=True) + with open(file, "a") as f: + f.write(command) + print("Added firefox to labwc autostart") + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}ON{}".format( + Fore.LIGHTGREEN_EX, Style.RESET_ALL + ) + ) + else: + print("labwc autostart file already exists") + with open(file, "r") as f: + lines = f.readlines() + firefoxfound = False + for line in lines: + if line.find("firefox") != -1: + firefoxfound = True + if firefoxfound is True: + print("firefox is already in the autostart file") + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}ON{}".format( + Fore.LIGHTGREEN_EX, Style.RESET_ALL + ) + ) + return + else: + with open(file, "a") as f: + f.write(command) + print("Added firefox to labwc autostart") + except Exception as e: + print(e) + return + elif name == "off": + print("Remove firefox from labwc autostart") + try: + if os.path.exists(file) is False: + print("labwc autostart file does not exist") + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}OFF{}".format( + Fore.RED, Style.RESET_ALL + ) + ) + return + with open(file, "r") as f: + lines = f.readlines() + with open(file, "w") as f: + for line in lines: + if line.find("firefox") == -1: + f.write(line) + print("Removed firefox from labwc autostart") + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}OFF{}".format( + Fore.RED, Style.RESET_ALL + ) + ) + except Exception as e: + print(e) + return + def chromium(self, name, width=None, height=None): try: @@ -459,9 +579,6 @@ def chromium(self, name, width=None, height=None): except Exception as e: print(e) return - - - @click.group() @click.pass_context @@ -623,3 +740,14 @@ def chromium(context, name, resolution): context.obj.chromium(name) else: print("Chromium option NOT available under Windows") + +@main.command() +@click.pass_context +@click.argument("name") +def firefox(context, name): + """(on|off|status) Enable or disable firefox fullscreen mode""" + operationsystem = sys.platform + if not operationsystem.startswith("win"): + context.obj.firefox(name) + else: + print("Firefox option NOT available under Windows") \ No newline at end of file From b9413633e47ab00ded91bc4f68c0746ccc63ca55 Mon Sep 17 00:00:00 2001 From: avollkopf Date: Fri, 6 Feb 2026 13:45:40 +0100 Subject: [PATCH 2/4] some firefox cli code tweaks --- cbpi/__init__.py | 2 +- cbpi/cli.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 49565bb5..1775376b 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,2 +1,2 @@ -__version__ = "4.7.2.a1" +__version__ = "4.7.2.a2" __codename__ = "Winter Bock" diff --git a/cbpi/cli.py b/cbpi/cli.py index edfa71dd..f93a39ee 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -292,6 +292,10 @@ def autostart(self, name): print(e) return return + elif name not in ["on", "off", "status"]: + print("Usage: cbpi firefox (on|off|status)") + print("Example: cbpi firefox on") + return def firefox(self, name): """Enable or disable firefox fullscreen mode""" @@ -381,6 +385,11 @@ def firefox(self, name): with open(file, "a") as f: f.write(command) print("Added firefox to labwc autostart") + print( + "CraftBeerPi Firefox Fullscreen Autostart is {}ON{}".format( + Fore.LIGHTGREEN_EX, Style.RESET_ALL + ) + ) except Exception as e: print(e) return From 4b92f39d8e2e496854ebd42ccc0d2f4ea6c3e6f5 Mon Sep 17 00:00:00 2001 From: avollkopf Date: Fri, 6 Feb 2026 13:58:34 +0100 Subject: [PATCH 3/4] fix typo in start command --- cbpi/__init__.py | 2 +- cbpi/cli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 1775376b..2a13ed65 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,2 +1,2 @@ -__version__ = "4.7.2.a2" +__version__ = "4.7.2.a3" __codename__ = "Winter Bock" diff --git a/cbpi/cli.py b/cbpi/cli.py index f93a39ee..ff5e5c69 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -353,7 +353,7 @@ def firefox(self, name): pass elif name == "on": print("Add firefox to labwc autostart") - command='bash -c "sleep 20 && firefox --url http://localhost:8000 & wlrctl toplevel waitfor firefoox && wlrctl window focus firefox && wtype -P F11 -p F11"' + command='bash -c "sleep 20 && firefox --url http://localhost:8000 & wlrctl toplevel waitfor firefox && wlrctl window focus firefox && wtype -P F11 -p F11"' try: if os.path.exists(file) is False: pathlib.Path(file).mkdir(parents=True, exist_ok=True) From 30cadac010968915d42a5284e180971a0f11ca99 Mon Sep 17 00:00:00 2001 From: avollkopf Date: Fri, 6 Feb 2026 14:28:20 +0100 Subject: [PATCH 4/4] bump version for release --- cbpi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 2a13ed65..4838149b 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,2 +1,2 @@ -__version__ = "4.7.2.a3" +__version__ = "4.7.2" __codename__ = "Winter Bock"