From 1453e2a463080e62606cdc6be414720c236d9ae6 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 12:12:31 -0600 Subject: [PATCH 01/12] changed default shell to be nixos compatible, added error.go, added nix flake --- .gitignore | 1 + distribute.sh | 7 ++- flake.lock | 27 +++++++++++ flake.nix | 54 ++++++++++++++++++++++ termeverything/MainLoop.go | 5 ++ termeverything/ParseArgs.go | 5 +- termeverything/error.go | 78 ++++++++++++++++++++++++++++++++ termeverything/resources/help.md | 2 +- 8 files changed, 172 insertions(+), 7 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 termeverything/error.go diff --git a/.gitignore b/.gitignore index 90d605a..f723de2 100755 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ wayland/*.helper.go __debug_bin* term.everything term.everything❗mmulet.com-dont_forget_to_chmod_+x_this_file +result diff --git a/distribute.sh b/distribute.sh index 30f84a1..5ab6756 100755 --- a/distribute.sh +++ b/distribute.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env sh # This script builds a distributable AppImage # of the term.everything application using Podman. @@ -15,7 +15,7 @@ get_distro() { else DISTRO="unknown" fi - + case $DISTRO in ubuntu|debian) echo "sudo apt update && sudo apt install -y " @@ -51,7 +51,7 @@ if ! command -v podman >/dev/null 2>&1; then echo "Please install podman to proceed, it's literally all you need. Don't even need attention. Just podman. Just get podman. What are you waiting for? Stop reading this and install podman." exit 1 fi - + fi if [ -z "${PLATFORM+x}" ]; then @@ -66,4 +66,3 @@ $PODMAN run \ --volume .:/home/mount \ --rm alpine:latest /bin/sh /home/mount/resources/alpineCompile.sh && \ echo "Output is ./dist/$PLATFORM/static/$APP_NAME" - diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..677fdac --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1767379071, + "narHash": "sha256-EgE0pxsrW9jp9YFMkHL9JMXxcqi/OoumPJYwf+Okucw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fb7944c166a3b630f177938e478f0378e64ce108", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3bc52c9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + description = "Run any GUI app in the terminal"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + outputs = + { + self, + nixpkgs, + ... + }: + let + allSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + forAllSystems = + f: + nixpkgs.lib.genAttrs allSystems ( + system: + f { + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + packages = forAllSystems ( + { pkgs }: + { + default = pkgs.buildGoModule rec { + pname = "term-everything"; + name = pname; + version = "0.7.8"; + # subPackages = []; + src = ./.; + vendorHash = null; + nativeBuildInputs = with pkgs; [ + pkg-config + ]; + buildInputs = with pkgs; [ + glib + chafa + ]; + preBuild = '' + go generate ./wayland + ''; + postInstall = '' + mv $out/bin/term.everything $out/bin/${name} + ''; + }; + } + ); + }; +} diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index 6c1e6b2..1c59cc6 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -9,13 +9,17 @@ import ( "github.com/mmulet/term.everything/wayland" ) +func UNUSED(x ...any) {} func MainLoop() { args := ParseArgs() + var logger = newLogger(args.DebugLog, nil, args.Verbose) + UNUSED(logger) SetVirtualMonitorSize(args.VirtualMonitorSize) listener, err := wayland.MakeSocketListener(&args) if err != nil { fmt.Fprintf(os.Stderr, "Failed to create socket listener: %v\n", err) os.Exit(1) + // logger.logFatal("Failed to create socket listener: %v", err) } displaySize := wayland.Size{ @@ -81,6 +85,7 @@ func MainLoop() { if err := cmd.Start(); err != nil { fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) + // logger.log("Failed to start command: %v", err) } else { go func() { _ = cmd.Wait() diff --git a/termeverything/ParseArgs.go b/termeverything/ParseArgs.go index 808f79f..bd80533 100644 --- a/termeverything/ParseArgs.go +++ b/termeverything/ParseArgs.go @@ -28,6 +28,7 @@ type CommandLineArgs struct { ReverseScroll bool MaxFrameRate string Positionals []string + Verbose bool } func (args *CommandLineArgs) WaylandDisplayName() string { @@ -41,7 +42,7 @@ func ParseArgs() CommandLineArgs { flag.BoolVar(&args.SupportOldApps, "support-old-apps", false, "") flag.StringVar(&args.Xwayland, "xwayland", "", "") flag.StringVar(&args.XwaylandWM, "xwayland-wm", "", "") - flag.StringVar(&args.Shell, "shell", "/bin/bash", "") + flag.StringVar(&args.Shell, "shell", "/usr/bin/env sh", "") flag.BoolVar(&args.HideStatusBar, "hide-status-bar", false, "") flag.StringVar(&args.VirtualMonitorSize, "virtual-monitor-size", "", "") versionFlag := flag.Bool("version", false, "") @@ -51,7 +52,7 @@ func ParseArgs() CommandLineArgs { licensesFlag := flag.Bool("licenses", false, "") flag.BoolVar(&args.ReverseScroll, "reverse-scroll", false, "") flag.StringVar(&args.MaxFrameRate, "max-frame-rate", "", "") - + flag.BoolVar(&args.Verbose, "verbose", false, "") flag.Parse() if *versionFlag { diff --git a/termeverything/error.go b/termeverything/error.go new file mode 100644 index 0000000..8c7f7d8 --- /dev/null +++ b/termeverything/error.go @@ -0,0 +1,78 @@ +// // error logging +package termeverything + +import ( + "fmt" + "os" +) + +const DEFAULT_DEBUG_FILE string = "debug.log" + +type Logger struct { + useDebugFile bool + debugFile *os.File + verbose bool +} + +func newLogger(useDebugFile bool, debugFile *string, verbose bool) Logger { + if useDebugFile { + if debugFile == nil || *debugFile == "" { + var t = DEFAULT_DEBUG_FILE // disgusting + debugFile = &t + } + var file, err = os.Create(*debugFile) + if err != nil { + fmt.Print(formatError("failed to open debug file: %v", err)) + os.Exit(1) + } + return Logger{useDebugFile, file, verbose} + } else { + return Logger{useDebugFile, nil, verbose} + } +} + +// logs error using Logger.log then exits with returncode 1 +func (e Logger) logFatal(msg string, a ...any) { + e.log(msg, a...) + os.Exit(1) +} +func (e Logger) logVerbose(msg string, a ...any) { + if e.verbose { + e.log(msg, a...) + } +} + +// log error on stderr or DEBUG_FILE if useDebugFile automatically prepends Error: and appends \n +// unsure if to hard crash on error logging failures, or if stderr is even accessible in term.everything? +func (e Logger) log(msg string, a ...any) { + if e.useDebugFile { + if e.debugFile == nil { + // fmt.Println(formatError("")) + printFormatError("debug file is \"nil\", this should be impossible") // should be unreachable but who knows! + os.Exit(1) + } else { + var _, err = e.debugFile.WriteString(formatError(msg, a...)) + if err != nil { + printFormatError("failed to write to debug file %v", err) + // os.Exit(1) + } + } + } else { + printFormatError(msg, a...) + } +} +func formatError(msg string, a ...any) string { + return fmt.Sprintf("Error: %v\n", fmt.Sprintf(msg, a...)) +} +func printStderr(msg string, a ...any) { + fmt.Fprintf(os.Stderr, msg, a...) +} +func printFormatError(msg string, a ...any) { + printStderr("%v", formatError(msg, a...)) +} + +func (e Logger) close() { + if e.debugFile != nil { + e.debugFile.Close() + } +} diff --git a/termeverything/resources/help.md b/termeverything/resources/help.md index 7b1d47c..2f519e3 100755 --- a/termeverything/resources/help.md +++ b/termeverything/resources/help.md @@ -77,7 +77,7 @@ WAYLAND_DISPLAY= DISPLAY= `--shell ` -The shell used to launch the app. Default is `/bin/bash`. +The shell used to launch the app. Default is `/usr/bin/env sh`. `--hide-status-bar` Hides the status bar at the top of the terminal. Default is false. From 5260823d293f45087d5f40fd06a503d3499a60a7 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 12:46:59 -0600 Subject: [PATCH 02/12] switched to /bin/sh because /usr/bin/env wasn't working, added verbose logging including printing Args --- termeverything/MainLoop.go | 38 +++++++++++++++++++++++++++++++------ termeverything/ParseArgs.go | 2 +- termeverything/error.go | 15 +++++++++------ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index 1c59cc6..b5fd957 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -14,12 +14,38 @@ func MainLoop() { args := ParseArgs() var logger = newLogger(args.DebugLog, nil, args.Verbose) UNUSED(logger) + logger.logVerbose(` + arguments: + WaylandDisplayNameArg=%v + SupportOldApps=%v + Xwayland=%v + XwaylandWM=%v + Shell=%v + HideStatusBar=%v + VirtualMonitorSize=%v + DebugLog=%v + ReverseScroll=%v + MaxFrameRate=%v + Positionals=%v + Verbose=%v`, + args.WaylandDisplayNameArg, + args.SupportOldApps, + args.Xwayland, + args.XwaylandWM, + args.Shell, + args.HideStatusBar, + args.VirtualMonitorSize, + args.DebugLog, + args.ReverseScroll, + args.MaxFrameRate, + args.Positionals, + args.Verbose) SetVirtualMonitorSize(args.VirtualMonitorSize) listener, err := wayland.MakeSocketListener(&args) if err != nil { - fmt.Fprintf(os.Stderr, "Failed to create socket listener: %v\n", err) - os.Exit(1) - // logger.logFatal("Failed to create socket listener: %v", err) + // fmt.Fprintf(os.Stderr, "Failed to create socket listener: %v\n", err) + // os.Exit(1) + logger.logFatal("Failed to create socket listener: %v", err) } displaySize := wayland.Size{ @@ -60,7 +86,7 @@ func MainLoop() { cmdStr := strings.Join(args.Positionals, " ") shell := args.Shell cmd := exec.Command(shell, "-c", cmdStr) - + logger.logVerbose("command: %v",cmd) baseEnv := os.Environ() filtered := make([]string, 0, len(baseEnv)) for _, e := range baseEnv { @@ -84,8 +110,8 @@ func MainLoop() { // cmd.Stdin = os.Stdin if err := cmd.Start(); err != nil { - fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) - // logger.log("Failed to start command: %v", err) + // fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) + logger.log("Failed to start command: %v", err) } else { go func() { _ = cmd.Wait() diff --git a/termeverything/ParseArgs.go b/termeverything/ParseArgs.go index bd80533..062119a 100644 --- a/termeverything/ParseArgs.go +++ b/termeverything/ParseArgs.go @@ -42,7 +42,7 @@ func ParseArgs() CommandLineArgs { flag.BoolVar(&args.SupportOldApps, "support-old-apps", false, "") flag.StringVar(&args.Xwayland, "xwayland", "", "") flag.StringVar(&args.XwaylandWM, "xwayland-wm", "", "") - flag.StringVar(&args.Shell, "shell", "/usr/bin/env sh", "") + flag.StringVar(&args.Shell, "shell", "/bin/sh", "") flag.BoolVar(&args.HideStatusBar, "hide-status-bar", false, "") flag.StringVar(&args.VirtualMonitorSize, "virtual-monitor-size", "", "") versionFlag := flag.Bool("version", false, "") diff --git a/termeverything/error.go b/termeverything/error.go index 8c7f7d8..eab9755 100644 --- a/termeverything/error.go +++ b/termeverything/error.go @@ -38,27 +38,30 @@ func (e Logger) logFatal(msg string, a ...any) { } func (e Logger) logVerbose(msg string, a ...any) { if e.verbose { - e.log(msg, a...) + e._log(fmt.Sprintf("Verbose: %v\n", fmt.Sprintf(msg, a...))) } } // log error on stderr or DEBUG_FILE if useDebugFile automatically prepends Error: and appends \n // unsure if to hard crash on error logging failures, or if stderr is even accessible in term.everything? -func (e Logger) log(msg string, a ...any) { - if e.useDebugFile { - if e.debugFile == nil { +func (l Logger) log(msg string, a ...any) { + l._log(formatError(msg,a...)) +} +func (l Logger) _log(s string){ + if l.useDebugFile { + if l.debugFile == nil { // fmt.Println(formatError("")) printFormatError("debug file is \"nil\", this should be impossible") // should be unreachable but who knows! os.Exit(1) } else { - var _, err = e.debugFile.WriteString(formatError(msg, a...)) + var _, err = l.debugFile.WriteString(s) if err != nil { printFormatError("failed to write to debug file %v", err) // os.Exit(1) } } } else { - printFormatError(msg, a...) + printStderr(s) } } func formatError(msg string, a ...any) string { From f689037f18f8ea4cf8b4269d8ca131f22b0941af Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 13:13:12 -0600 Subject: [PATCH 03/12] fixed flake.nix to not build generate --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3bc52c9..4dd7ab4 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ pname = "term-everything"; name = pname; version = "0.7.8"; - # subPackages = []; + subPackages = [ "." ]; src = ./.; vendorHash = null; nativeBuildInputs = with pkgs; [ @@ -45,6 +45,7 @@ go generate ./wayland ''; postInstall = '' + # rm $out/bin/generate mv $out/bin/term.everything $out/bin/${name} ''; }; From e1c5ee5fb0f1025c5ed5bad96a4f6f58672d0383 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 13:46:19 -0600 Subject: [PATCH 04/12] changed the way SetVirtualMonitorSize returns errors --- Makefile | 6 ++-- termeverything/MainLoop.go | 8 ++++-- termeverything/SetVirtualMonitorSize.go | 38 ++++++++++++++++--------- termeverything/error.go | 21 +++++++++++--- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index daba74b..98ec8f0 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ protocols_files := $(shell find ./wayland/generate) xml_protocols := $(shell find ./wayland/generate -name "*.xml") -generated_protocols := $(patsubst ./wayland/generate/resources/%,./wayland/protocols/%.go,$(xml_protocols)) +generated_protocols := $(patsubst ./wayland/generate/resources/%, ./wayland/protocols/%.go, $(xml_protocols)) -generated_helpers := $(patsubst ./wayland/generate/resources/%,./wayland/%.helper.go,$(xml_protocols)) +generated_helpers := $(patsubst ./wayland/generate/resources/%, ./wayland/%.helper.go, $(xml_protocols)) build: $(generated_protocols) $(generated_helpers) $(bin_name) @@ -29,4 +29,4 @@ clean: rm __debug_bin* 2>/dev/null || true if [ -z "$$MULTI_PLATFORM" ]; then rm -rf ./dist 2>/dev/null || true; fi rm ./wayland/protocols/*.xml.go 2>/dev/null || true - rm ./wayland/*.helper.go 2>/dev/null || true \ No newline at end of file + rm ./wayland/*.helper.go 2>/dev/null || true diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index b5fd957..c4ca7d3 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -40,9 +40,11 @@ func MainLoop() { args.MaxFrameRate, args.Positionals, args.Verbose) - SetVirtualMonitorSize(args.VirtualMonitorSize) + logger.checkFatalErr(SetVirtualMonitorSize(args.VirtualMonitorSize)) + listener, err := wayland.MakeSocketListener(&args) if err != nil { + // fmt.Fprintf(os.Stderr, "Failed to create socket listener: %v\n", err) // os.Exit(1) logger.logFatal("Failed to create socket listener: %v", err) @@ -86,7 +88,7 @@ func MainLoop() { cmdStr := strings.Join(args.Positionals, " ") shell := args.Shell cmd := exec.Command(shell, "-c", cmdStr) - logger.logVerbose("command: %v",cmd) + logger.logVerbose("command: %v", cmd) baseEnv := os.Environ() filtered := make([]string, 0, len(baseEnv)) for _, e := range baseEnv { @@ -111,7 +113,7 @@ func MainLoop() { if err := cmd.Start(); err != nil { // fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) - logger.log("Failed to start command: %v", err) + logger.logFatal("Failed to start command: %v", err) } else { go func() { _ = cmd.Wait() diff --git a/termeverything/SetVirtualMonitorSize.go b/termeverything/SetVirtualMonitorSize.go index 8f54764..b1fca48 100644 --- a/termeverything/SetVirtualMonitorSize.go +++ b/termeverything/SetVirtualMonitorSize.go @@ -2,32 +2,44 @@ package termeverything import ( "fmt" - "os" "strconv" "strings" "github.com/mmulet/term.everything/wayland" ) -func SetVirtualMonitorSize(newVirtualMonitorSize string) { +func SetVirtualMonitorSize(newVirtualMonitorSize string) error { + mkError := func(msg string, a ...any) error { + errorMessage := fmt.Sprintf("Invalid virtual monitor size %s, expected x", newVirtualMonitorSize) + return fmt.Errorf("%v; %v", errorMessage, fmt.Sprintf(msg, a...)) + } + if newVirtualMonitorSize == "" { - return + return nil } parts := strings.Split(newVirtualMonitorSize, "x") if len(parts) != 2 { - fmt.Fprintf(os.Stderr, "Invalid virtual monitor size %s, expected x\n", newVirtualMonitorSize) - os.Exit(1) + // return errors.New(fmt.Sprintf("%v; found less than 2 dimensions %v", errorMessage, parts)) + return mkError("found less than 2 dimensions %v", parts) + // fmt.Fprintf(os.Stderr, "Invalid virtual monitor size %s, expected x\n", newVirtualMonitorSize) + // os.Exit(1) + // logger.logFatal("Invalid virtual monitor size %s, expected x", newVirtualMonitorSize) + } + width, widthErr := strconv.Atoi(parts[0]) + height, heightErr := strconv.Atoi(parts[1]) + if widthErr != nil { + return mkError("invalid width %v; must be an integer", widthErr) + } + if heightErr != nil { + return mkError("invalid height %v; must be an integer", heightErr) } - width, err1 := strconv.Atoi(parts[0]) - height, err2 := strconv.Atoi(parts[1]) - if err1 != nil || err2 != nil { - fmt.Fprintf(os.Stderr, "Invalid virtual monitor size %s, expected x\n", newVirtualMonitorSize) - os.Exit(1) + if width <= 0 { + return mkError("invalid width %v; must be greater than zero", width) } - if width <= 0 || height <= 0 { - fmt.Fprintf(os.Stderr, "Invalid virtual monitor size %s, expected x\n", newVirtualMonitorSize) - os.Exit(1) + if height <= 0 { + return mkError("invalid height %v; must be greater than zero", height) } wayland.VirtualMonitorSize.Width = wayland.Pixels(width) wayland.VirtualMonitorSize.Height = wayland.Pixels(height) + return nil } diff --git a/termeverything/error.go b/termeverything/error.go index eab9755..9237a16 100644 --- a/termeverything/error.go +++ b/termeverything/error.go @@ -31,7 +31,20 @@ func newLogger(useDebugFile bool, debugFile *string, verbose bool) Logger { } } -// logs error using Logger.log then exits with returncode 1 +// check used for functions that return complete errors +func (l Logger) checkErr(err error) { + if err != nil { + l.log("%v", err.Error()) + } +} + +func (l Logger) checkFatalErr(err error) { + if err != nil { + l.logFatal("%v", err.Error()) + } +} + +// log used for errors which need to be formatted func (e Logger) logFatal(msg string, a ...any) { e.log(msg, a...) os.Exit(1) @@ -45,9 +58,9 @@ func (e Logger) logVerbose(msg string, a ...any) { // log error on stderr or DEBUG_FILE if useDebugFile automatically prepends Error: and appends \n // unsure if to hard crash on error logging failures, or if stderr is even accessible in term.everything? func (l Logger) log(msg string, a ...any) { - l._log(formatError(msg,a...)) + l._log(formatError(msg, a...)) } -func (l Logger) _log(s string){ +func (l Logger) _log(s string) { if l.useDebugFile { if l.debugFile == nil { // fmt.Println(formatError("")) @@ -61,7 +74,7 @@ func (l Logger) _log(s string){ } } } else { - printStderr(s) + printStderr("%v", s) } } func formatError(msg string, a ...any) string { From 70e90572d233ab89e776489e43bbb74002eda060 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 13:47:55 -0600 Subject: [PATCH 05/12] added --verbose flag to help.md --- termeverything/resources/help.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/termeverything/resources/help.md b/termeverything/resources/help.md index 2f519e3..01c6d63 100755 --- a/termeverything/resources/help.md +++ b/termeverything/resources/help.md @@ -98,6 +98,8 @@ Limit drawing to the terminal to $N frames per second. Accepts float. `--debug-log` Log most debug statements to debug.log instead of printing to console +`--verbose` +Enable verbose logging # Environment Variables `TERM_EVERYTHING_PIXEL_MODE` From 0871deeb0f4ebddae01f510ffc0c3508fdb45908 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 13:48:38 -0600 Subject: [PATCH 06/12] forgot to save setvirtualmonitorsize --- termeverything/SetVirtualMonitorSize.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/termeverything/SetVirtualMonitorSize.go b/termeverything/SetVirtualMonitorSize.go index b1fca48..23a7c77 100644 --- a/termeverything/SetVirtualMonitorSize.go +++ b/termeverything/SetVirtualMonitorSize.go @@ -19,11 +19,7 @@ func SetVirtualMonitorSize(newVirtualMonitorSize string) error { } parts := strings.Split(newVirtualMonitorSize, "x") if len(parts) != 2 { - // return errors.New(fmt.Sprintf("%v; found less than 2 dimensions %v", errorMessage, parts)) return mkError("found less than 2 dimensions %v", parts) - // fmt.Fprintf(os.Stderr, "Invalid virtual monitor size %s, expected x\n", newVirtualMonitorSize) - // os.Exit(1) - // logger.logFatal("Invalid virtual monitor size %s, expected x", newVirtualMonitorSize) } width, widthErr := strconv.Atoi(parts[0]) height, heightErr := strconv.Atoi(parts[1]) From e1f10890aa35f9821471ca29a78fb1dcae6f5bc6 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 13:57:29 -0600 Subject: [PATCH 07/12] changed setvirtualmonitorsize to print the raw string value instead of atoi err return --- termeverything/SetVirtualMonitorSize.go | 10 ++++++---- termeverything/resources/help.md | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/termeverything/SetVirtualMonitorSize.go b/termeverything/SetVirtualMonitorSize.go index 23a7c77..87ee204 100644 --- a/termeverything/SetVirtualMonitorSize.go +++ b/termeverything/SetVirtualMonitorSize.go @@ -21,13 +21,15 @@ func SetVirtualMonitorSize(newVirtualMonitorSize string) error { if len(parts) != 2 { return mkError("found less than 2 dimensions %v", parts) } - width, widthErr := strconv.Atoi(parts[0]) - height, heightErr := strconv.Atoi(parts[1]) + rawWidth, rawHeight := parts[0], parts[1] + width, widthErr := strconv.Atoi(rawWidth) + height, heightErr := strconv.Atoi(rawHeight) + // using the actual error strings are too verbose so just printing the raw value if widthErr != nil { - return mkError("invalid width %v; must be an integer", widthErr) + return mkError("invalid width %v; must be an integer", rawWidth) } if heightErr != nil { - return mkError("invalid height %v; must be an integer", heightErr) + return mkError("invalid height %v; must be an integer", rawHeight) } if width <= 0 { return mkError("invalid width %v; must be greater than zero", width) diff --git a/termeverything/resources/help.md b/termeverything/resources/help.md index 01c6d63..ea3b532 100755 --- a/termeverything/resources/help.md +++ b/termeverything/resources/help.md @@ -98,6 +98,7 @@ Limit drawing to the terminal to $N frames per second. Accepts float. `--debug-log` Log most debug statements to debug.log instead of printing to console + `--verbose` Enable verbose logging From 7576e8484b4acdc1536a43e89897dcc1412f27de Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 14:35:02 -0600 Subject: [PATCH 08/12] made term.everything return early if command failed instead of just hanging --- termeverything/MainLoop.go | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index c4ca7d3..9082b51 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -111,14 +111,31 @@ func MainLoop() { // cmd.Stderr = os.Stderr // cmd.Stdin = os.Stdin - if err := cmd.Start(); err != nil { - // fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) - logger.logFatal("Failed to start command: %v", err) - } else { - go func() { - _ = cmd.Wait() - }() - } + // if err := cmd.Start(); err != nil { + // // fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) + // logger.logFatal("Failed to start command: %v", err) + // } else { + result := make(chan error) + go func(ret chan error) { + output, err := cmd.CombinedOutput() + if err != nil { + ret <- fmt.Errorf("command failed to run %v; returncode: %v\nstdout/err: %v", cmd, err, string(output)) + } + }(result) + err := <-result + logger.checkFatalErr(err) + // go func(ret chan error) { + // err := cmd.Wait() + // if err != nil { + // output, err := cmd.CombinedOutput() + // ret = fmt.Errorf("command failed to run %v; returncode: %v\nstdout/err: %v", cmd, err, string(output)) + // // logger.logFatal("command failed to run %v; %v\n%v", cmd, err, output) + // } + // ret = nil + // }(result) + // err := <-result + // logger + // } } <-done From 8fe0d9642b594e9b120052908eb5aa8c3052187b Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 14:37:10 -0600 Subject: [PATCH 09/12] removed UNUSED --- termeverything/MainLoop.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index 9082b51..8456f6c 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -9,11 +9,9 @@ import ( "github.com/mmulet/term.everything/wayland" ) -func UNUSED(x ...any) {} func MainLoop() { args := ParseArgs() var logger = newLogger(args.DebugLog, nil, args.Verbose) - UNUSED(logger) logger.logVerbose(` arguments: WaylandDisplayNameArg=%v From 4527026c17f6e2c5af8fb795cdb11fd10f2d519c Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 14:38:03 -0600 Subject: [PATCH 10/12] removed commented out code --- termeverything/MainLoop.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/termeverything/MainLoop.go b/termeverything/MainLoop.go index 8456f6c..9036ffc 100644 --- a/termeverything/MainLoop.go +++ b/termeverything/MainLoop.go @@ -42,9 +42,6 @@ func MainLoop() { listener, err := wayland.MakeSocketListener(&args) if err != nil { - - // fmt.Fprintf(os.Stderr, "Failed to create socket listener: %v\n", err) - // os.Exit(1) logger.logFatal("Failed to create socket listener: %v", err) } @@ -109,10 +106,6 @@ func MainLoop() { // cmd.Stderr = os.Stderr // cmd.Stdin = os.Stdin - // if err := cmd.Start(); err != nil { - // // fmt.Fprintf(os.Stderr, "Failed to start command: %v\n", err) - // logger.logFatal("Failed to start command: %v", err) - // } else { result := make(chan error) go func(ret chan error) { output, err := cmd.CombinedOutput() @@ -122,18 +115,6 @@ func MainLoop() { }(result) err := <-result logger.checkFatalErr(err) - // go func(ret chan error) { - // err := cmd.Wait() - // if err != nil { - // output, err := cmd.CombinedOutput() - // ret = fmt.Errorf("command failed to run %v; returncode: %v\nstdout/err: %v", cmd, err, string(output)) - // // logger.logFatal("command failed to run %v; %v\n%v", cmd, err, output) - // } - // ret = nil - // }(result) - // err := <-result - // logger - // } } <-done From 0c6c87d28c945868828088fb09d7427ef84d22f1 Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 15:23:03 -0600 Subject: [PATCH 11/12] cleaned up function organization and removed macos definitions in nix flake since termeverything doesnt support macos --- flake.nix | 4 ++-- termeverything/error.go | 26 ++++++++++++++------------ termeverything/resources/help.md | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index 4dd7ab4..58c4ab1 100644 --- a/flake.nix +++ b/flake.nix @@ -11,8 +11,8 @@ allSystems = [ "x86_64-linux" # 64-bit Intel/AMD Linux "aarch64-linux" # 64-bit ARM Linux - "x86_64-darwin" # 64-bit Intel macOS - "aarch64-darwin" # 64-bit ARM macOS + # "x86_64-darwin" # 64-bit Intel macOS + # "aarch64-darwin" # 64-bit ARM macOS ]; forAllSystems = f: diff --git a/termeverything/error.go b/termeverything/error.go index 9237a16..76291c8 100644 --- a/termeverything/error.go +++ b/termeverything/error.go @@ -45,13 +45,14 @@ func (l Logger) checkFatalErr(err error) { } // log used for errors which need to be formatted -func (e Logger) logFatal(msg string, a ...any) { - e.log(msg, a...) +func (l Logger) logFatal(msg string, a ...any) { + l.log(msg, a...) + l.close() os.Exit(1) } -func (e Logger) logVerbose(msg string, a ...any) { - if e.verbose { - e._log(fmt.Sprintf("Verbose: %v\n", fmt.Sprintf(msg, a...))) +func (l Logger) logVerbose(msg string, a ...any) { + if l.verbose { + l._log(fmt.Sprintf("Verbose: %v\n", fmt.Sprintf(msg, a...))) } } @@ -60,6 +61,13 @@ func (e Logger) logVerbose(msg string, a ...any) { func (l Logger) log(msg string, a ...any) { l._log(formatError(msg, a...)) } + +func (l Logger) close() { + if l.debugFile != nil { + l.debugFile.Close() + } +} + func (l Logger) _log(s string) { if l.useDebugFile { if l.debugFile == nil { @@ -78,7 +86,7 @@ func (l Logger) _log(s string) { } } func formatError(msg string, a ...any) string { - return fmt.Sprintf("Error: %v\n", fmt.Sprintf(msg, a...)) + return "Error: " + fmt.Sprintf(msg, a...) + "\n" } func printStderr(msg string, a ...any) { fmt.Fprintf(os.Stderr, msg, a...) @@ -86,9 +94,3 @@ func printStderr(msg string, a ...any) { func printFormatError(msg string, a ...any) { printStderr("%v", formatError(msg, a...)) } - -func (e Logger) close() { - if e.debugFile != nil { - e.debugFile.Close() - } -} diff --git a/termeverything/resources/help.md b/termeverything/resources/help.md index ea3b532..fd9365d 100755 --- a/termeverything/resources/help.md +++ b/termeverything/resources/help.md @@ -77,7 +77,7 @@ WAYLAND_DISPLAY= DISPLAY= `--shell ` -The shell used to launch the app. Default is `/usr/bin/env sh`. +The shell used to launch the app. Default is `/bin/sh`. `--hide-status-bar` Hides the status bar at the top of the terminal. Default is false. From 61a020815fcfde14690a3e60780ca906ddf3f19c Mon Sep 17 00:00:00 2001 From: nimrod Date: Sun, 4 Jan 2026 18:52:13 -0600 Subject: [PATCH 12/12] edited flake.nix --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 58c4ab1..3fd4e88 100644 --- a/flake.nix +++ b/flake.nix @@ -9,10 +9,10 @@ }: let allSystems = [ - "x86_64-linux" # 64-bit Intel/AMD Linux - "aarch64-linux" # 64-bit ARM Linux - # "x86_64-darwin" # 64-bit Intel macOS - # "aarch64-darwin" # 64-bit ARM macOS + "x86_64-linux" + "aarch64-linux" + # "x86_64-darwin" + # "aarch64-darwin" ]; forAllSystems = f: