socket.go

 1package daemonrpc
 2
 3import (
 4	"path/filepath"
 5
 6	udsrpc "github.com/floatpane/go-uds-jsonrpc"
 7)
 8
 9// appName is the per-user runtime directory namespace for matcha's daemon
10// files. It matches the historical layout: $XDG_RUNTIME_DIR/matcha/ on Linux,
11// ~/Library/Caches/matcha/ on macOS.
12const appName = "matcha"
13
14// SocketPath returns the path to the daemon's Unix domain socket.
15func SocketPath() string {
16	return filepath.Join(udsrpc.RuntimeDir(appName), "daemon.sock")
17}
18
19// PIDPath returns the path to the daemon's PID file.
20func PIDPath() string {
21	return filepath.Join(udsrpc.RuntimeDir(appName), "daemon.pid")
22}
23
24// EnsureRuntimeDir creates the runtime directory if it doesn't exist.
25func EnsureRuntimeDir() error {
26	return udsrpc.EnsureRuntimeDir(appName)
27}