dux-go

module
v1.6.3-0...-5d87a77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT

README

dankgo

Common Go modules used by DMS & the Dux Labs suite (dankcalendar, dgop, danksearch, and whatever comes next).

Every app in the suite was carrying its own copy of the same logger, unix-socket RPC, chi/huma scaffolding, and XDG path helpers. This is that code, extracted once.

Packages

Package What it is
log charmbracelet logger singleton. log.SetEnvPrefix("DANKCAL") → reads DANKCAL_LOG_LEVEL / DANKCAL_LOG_FILE. File sink strips ANSI.
paths XDG dirs (incl. XDGDataDirs/XDGConfigDirs) + per-process socket paths, keyed by app name. paths.New("dankcal").SocketPath()
errdefs CustomError/ErrorType with HTTP status mapping. Apps register their own types from AppErrorBase up. stdlib-only.
errdefs/humaerr huma error envelope + HumaErrorFunc. Split out so non-HTTP apps never pull huma.
ipc JSON-over-unix-socket RPC: server (ping/subscribe/unsubscribe built in), client, event bus, mux. Stale sockets get reaped by PID. Apps with their own subscribe protocol set SubscribeHandler; per-connection handshake capabilities via CapabilitiesFunc.
ipc/params Typed extraction from map[string]any request params.
ipc/spec Method/param specs for describe, ipc list and cobra shell completion, plus key=value CLI param parsing (repeated key → list).
atomicfile Saves that keep mode, owner, SELinux label, ACL, user xattrs, symlinks and hard links; in-place overwrite with fallocate and optional backup. WriteFile for app-owned files.
colorscheme Portal light/dark watcher: subscribes in the background, wakes only for the appearance namespace.
shellapp Quickshell app lifecycle: run/restart/kill commands, daemon supervision, PID/session tracking, config-dir resolution (-c → <PREFIX>_SHELL_DIR → live instance → embedded UI). App-specific behavior hooks in via PreLaunch, ExtraEnv, OnUIExit, and an optional Done() channel on the backend.
shellapp/shellfs Materializes an embedded UI tree onto disk — content-hashed, read-only, pruned when stale.
syncmap Generic sync.Map (typed keys and values).
dbusutil godbus variant helpers: typed Get/As, recursive Normalize.
httpapi huma/chi scaffold: NewHumaConfig, /docs page, router with health + recoverer, graceful Server. Use à la carte or via NewRouter.
httpapi/middleware The chi-ported logger/recoverer/request-id set.
netutil GetIPAddress header dance.
tailscale Read-only tailscaled LocalAPI client over its unix socket: status (self, peers, users) and the IPN bus watch with peer change events. GetJSON/Send for other endpoints. No tailscale.com dependency.
lyrics Song lyrics lookup: sidecar files, disk cache, then LRCLIB / BetterLyrics / LyricsPlus raced in priority order. Typed line and word timing, voices, backing vocals. LRC, TTML and Lyricsfile parsers usable on their own.
weather Weather forecast from Open-Meteo / MET Norway asked at once, first in priority order wins, the others fill its missing readings. Answers in the Open-Meteo shape; MET Norway is mapped, sunrise/sunset and day/night computed from the sun. Command runs external providers.
app Thin bootstrap: app.New(info, rootCmd) wires logging + version, app.Serve(ctx, runners...) handles signals and shutdown. Not a framework.
material Go port of Google's material-color-utilities: HCT, tonal palettes, the 2021 and 2025 dynamic color specs, Wu/WSMeans/Celebi quantizers. Apache-2.0, see material/NOTICE.

Using it

go get github.com/duxlabs-dev/dux-go@v0.1.0

Minimal daemon

a := app.New(app.Info{Name: "Dank Thing", ID: "dankthing", Version: version}, rootCmd)

srv := ipc.NewServer(ipc.Config{AppName: "dankthing", APIVersion: 1}, route)
if err := srv.Listen(); err != nil {
    return err
}
return app.Serve(ctx, srv)

Directories

Path Synopsis
Package atomicfile saves files without losing their mode, owner, labels, ACLs, symlinks or hard links.
Package atomicfile saves files without losing their mode, owner, labels, ACLs, symlinks or hard links.
Package boottimer provides a one-shot timer whose deadline keeps counting across system suspend.
Package boottimer provides a one-shot timer whose deadline keeps counting across system suspend.
cmd
Package colorscheme follows the desktop portal's light/dark preference.
Package colorscheme follows the desktop portal's light/dark preference.
Package elevate runs an app's hidden helper command as root through pkexec; elevate/helper is the root side.
Package elevate runs an app's hidden helper command as root through pkexec; elevate/helper is the root side.
helper
Package helper is the root side of a pkexec elevation.
Package helper is the root side of a pkexec elevation.
middleware
From go-chi https://github.com/go-chi/chi/blob/d32a83448b5f43e42bc96487c6b0b3667a92a2e4/middleware/request_id.go
From go-chi https://github.com/go-chi/chi/blob/d32a83448b5f43e42bc96487c6b0b3667a92a2e4/middleware/request_id.go
internal
ipc
spec
Package spec describes an app's IPC methods for `describe`, `ipc list` and shell completion, and parses the `ipc <method> key=value...` command line into request params.
Package spec describes an app's IPC methods for `describe`, `ipc list` and shell completion, and parses the `ipc <method> key=value...` command line into request params.
Package lyrics looks up song lyrics from local sidecar files, a disk cache, and online providers.
Package lyrics looks up song lyrics from local sidecar files, a disk cache, and online providers.
example command
go run ./lyrics/example "Daft Punk" "Get Lucky"
go run ./lyrics/example "Daft Punk" "Get Lucky"
material
num
Package portal provides small clients for the XDG desktop portal interfaces (org.freedesktop.portal.Desktop) used by sandboxed Dux apps.
Package portal provides small clients for the XDG desktop portal interfaces (org.freedesktop.portal.Desktop) used by sandboxed Dux apps.
Package qtbase runs the quickshell runtime from libdux-qt-base.so inside the host binary's own `qs` subcommand.
Package qtbase runs the quickshell runtime from libdux-qt-base.so inside the host binary's own `qs` subcommand.
Package shellapp runs a quickshell-based desktop app: it supervises the UI process, daemonizes, tracks instances via PID files, resolves the shell config dir, and talks to a running instance over dankgo/ipc.
Package shellapp runs a quickshell-based desktop app: it supervises the UI process, daemonizes, tracks instances via PID files, resolves the shell config dir, and talks to a running instance over dankgo/ipc.
shellfs
Package shellfs materializes an embedded UI tree onto the filesystem, since quickshell needs real paths.
Package shellfs materializes an embedded UI tree onto the filesystem, since quickshell needs real paths.
Package tailscale is a minimal client for the tailscaled LocalAPI: plain HTTP over the daemon's unix socket.
Package tailscale is a minimal client for the tailscaled LocalAPI: plain HTTP over the daemon's unix socket.
Package trash implements the FreeDesktop.org Trash specification 1.0.
Package trash implements the FreeDesktop.org Trash specification 1.0.
wayland
blur
Package blur probes whether the compositor offers background blur.
Package blur probes whether the compositor offers background blur.
client
Package client is Go port of wayland-client library for writing pure Go GUI software for wayland supported platforms.
Package client is Go port of wayland-client library for writing pure Go GUI software for wayland supported platforms.
Package weather fetches a forecast from an ordered list of providers, falling back to the next on failure and filling readings the first one lacks from the others.
Package weather fetches a forecast from an ordered list of providers, falling back to the next on failure and filling readings the first one lacks from the others.
Package wlclipboard reads, watches, and owns the Wayland clipboard through the ext_data_control_v1 protocol without external binaries.
Package wlclipboard reads, watches, and owns the Wayland clipboard through the ext_data_control_v1 protocol without external binaries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL