aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/util
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-17 13:48:42 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-17 13:48:42 +0900
commit4b7d616862dc7d8c73561b85deb0ca1fabf30781 (patch)
treed069af086d1fcfeca2f9a629e0f3eb3e2f19500f /internal/util
parent6a6f62efa672bdb439c2f9056055193a53c1df01 (diff)
exit: move final and early code to internal package
Exit cleanup state information is now stored in a dedicated struct and built up using methods of that struct. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/early.go12
-rw-r--r--internal/util/std.go46
2 files changed, 0 insertions, 58 deletions
diff --git a/internal/util/early.go b/internal/util/early.go
deleted file mode 100644
index ba7375c7..00000000
--- a/internal/util/early.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package util
-
-import "fmt"
-
-var SdBootedV = func() bool {
- if v, err := SdBooted(); err != nil {
- fmt.Println("warn: read systemd marker:", err)
- return false
- } else {
- return v
- }
-}()
diff --git a/internal/util/std.go b/internal/util/std.go
index 9709cc22..b237ad73 100644
--- a/internal/util/std.go
+++ b/internal/util/std.go
@@ -2,21 +2,12 @@ package util
import (
"errors"
- "fmt"
- "git.ophivana.moe/cat/fortify/internal/final"
"io/fs"
"os"
- "path"
)
const (
systemdCheckPath = "/run/systemd/system"
-
- home = "HOME"
- xdgConfigHome = "XDG_CONFIG_HOME"
-
- PulseServer = "PULSE_SERVER"
- PulseCookie = "PULSE_COOKIE"
)
// SdBooted implements https://www.freedesktop.org/software/systemd/man/sd_booted.html
@@ -31,40 +22,3 @@ func SdBooted() (bool, error) {
return true, nil
}
-
-// DiscoverPulseCookie try various standard methods to discover the current user's PulseAudio authentication cookie
-func DiscoverPulseCookie() string {
- if p, ok := os.LookupEnv(PulseCookie); ok {
- return p
- }
-
- if p, ok := os.LookupEnv(home); ok {
- p = path.Join(p, ".pulse-cookie")
- if s, err := os.Stat(p); err != nil {
- if !errors.Is(err, fs.ErrNotExist) {
- final.Fatal("Error accessing PulseAudio cookie:", err)
- // unreachable
- return p
- }
- } else if !s.IsDir() {
- return p
- }
- }
-
- if p, ok := os.LookupEnv(xdgConfigHome); ok {
- p = path.Join(p, "pulse", "cookie")
- if s, err := os.Stat(p); err != nil {
- if !errors.Is(err, fs.ErrNotExist) {
- final.Fatal("Error accessing PulseAudio cookie:", err)
- // unreachable
- return p
- }
- } else if !s.IsDir() {
- return p
- }
- }
-
- final.Fatal(fmt.Sprintf("Cannot locate PulseAudio cookie (tried $%s, $%s/pulse/cookie, $%s/.pulse-cookie)",
- PulseCookie, xdgConfigHome, home))
- return ""
-}