filed

Job queue using FUSE

git clone git://mccd.space/filed

commit 1333a3fa73222ed3afdcfd46b43ee0e9bad2ad90
parent 148383e1346220082d13ad3ff881ca664b889c39
Author: Marc Coquand <marc@coquand.email>
Date:   Mon, 15 Dec 2025 15:26:25 +0100

Set

Diffstat:
Mmain.go | 15++++++++++++---
Mqj.1.scd | 9++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/main.go b/main.go
@@ -5,6 +5,7 @@ import (
 	"context"
 	"flag"
 	"fmt"
+	"log"
 	"log/slog"
 	"os"
 	"os/exec"
@@ -18,7 +19,7 @@ import (
 )
 
 func usage() {
-	fmt.Fprintf(os.Stderr, "Usage: %s MOUNTPOINT DBPATH\n", os.Args[0])
+	fmt.Fprintf(os.Stderr, "Usage: %s MOUNTPOINT\n", os.Args[0])
 	flag.PrintDefaults()
 }
 
@@ -32,12 +33,20 @@ func main() {
 	flag.Usage = usage
 	flag.Parse()
 
-	if flag.NArg() != 2 {
+	if flag.NArg() != 1 {
 		usage()
 		os.Exit(2)
 	}
+	dbPath := os.Getenv("QJ_STATE_FILE")
+	if dbPath == "" {
+		xdg_home := os.Getenv("XDG_DATA_HOME")
+		if xdg_home == "" {
+			log.Fatal("QJ_DATA_FILE environment variable needs to be set.")
+		}
+		dbPath = fmt.Sprintf("%s/qj.db", xdg_home)
+	}
+
 	mountpoint := flag.Arg(0)
-	dbPath := flag.Arg(1)
 	if err := Unmount(mountpoint); err != nil {
 		slog.Debug("FUSE: Pre-start unmount failed (this is usually okay)", "error", err)
 	}
diff --git a/qj.1.scd b/qj.1.scd
@@ -6,7 +6,7 @@ qj - queue jobs utility
 
 # SYNOPSIS
 
-*qj* _mountpoint_ _dbpath_
+*qj* _mountpoint_
 
 # DESCRIPTION
 
@@ -54,6 +54,13 @@ features are coming in the future.
 
 Access rights can be modified using _CHOWN(1)_ and _CHMOD(1)_. 
 
+# ENVIRONMENT
+
+## QJ_STATE_FILE
+
+Path to store sqlite state data file. File is created if it does not
+exist. Defaults to $XDG_DATA_HOME/qj.db, or exit(1) if XDG_DATA_HOME is unset.
+
 # EXAMPLES
 
 Create a new job with $JOBID that echoes hello world: