aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/pulse.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-16 20:31:15 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-16 20:31:35 +0900
commit8bdae74ebe172239573bab9fca634cf350cbd29d (patch)
treed81b8b650b53c4dddba0f417e2baf03d2a647bc2 /internal/app/pulse.go
parentd49b97b1d4fcd07a21aa14bb1727d64dd0214b09 (diff)
final: refactor for removal of system package and reduction of interactions to state package
State query command has been moved to main where it belongs, "system" information are now fetched in app.New and stored in *App with accessors for relevant values. Exit (cleanup-related) functions are separated into its dedicated "final" package. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/app/pulse.go')
-rw-r--r--internal/app/pulse.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/internal/app/pulse.go b/internal/app/pulse.go
index d7e08ba9..4b67ff2e 100644
--- a/internal/app/pulse.go
+++ b/internal/app/pulse.go
@@ -3,13 +3,13 @@ package app
import (
"errors"
"fmt"
+ "git.ophivana.moe/cat/fortify/internal/final"
"io/fs"
"os"
"path"
"git.ophivana.moe/cat/fortify/internal/acl"
"git.ophivana.moe/cat/fortify/internal/state"
- "git.ophivana.moe/cat/fortify/internal/system"
"git.ophivana.moe/cat/fortify/internal/util"
"git.ophivana.moe/cat/fortify/internal/verbose"
)
@@ -18,46 +18,46 @@ func (a *App) SharePulse() {
a.setEnablement(state.EnablePulse)
// ensure PulseAudio directory ACL (e.g. `/run/user/%d/pulse`)
- pulse := path.Join(system.V.Runtime, "pulse")
+ pulse := path.Join(a.runtimePath, "pulse")
pulseS := path.Join(pulse, "native")
if s, err := os.Stat(pulse); err != nil {
if !errors.Is(err, fs.ErrNotExist) {
- state.Fatal("Error accessing PulseAudio directory:", err)
+ final.Fatal("Error accessing PulseAudio directory:", err)
}
- state.Fatal(fmt.Sprintf("PulseAudio dir '%s' not found", pulse))
+ final.Fatal(fmt.Sprintf("PulseAudio dir '%s' not found", pulse))
} else {
// add environment variable for new process
a.AppendEnv(util.PulseServer, "unix:"+pulseS)
if err = acl.UpdatePerm(pulse, a.UID(), acl.Execute); err != nil {
- state.Fatal("Error preparing PulseAudio:", err)
+ final.Fatal("Error preparing PulseAudio:", err)
} else {
- state.RegisterRevertPath(pulse)
+ final.RegisterRevertPath(pulse)
}
// ensure PulseAudio socket permission (e.g. `/run/user/%d/pulse/native`)
if s, err = os.Stat(pulseS); err != nil {
if errors.Is(err, fs.ErrNotExist) {
- state.Fatal("PulseAudio directory found but socket does not exist")
+ final.Fatal("PulseAudio directory found but socket does not exist")
}
- state.Fatal("Error accessing PulseAudio socket:", err)
+ final.Fatal("Error accessing PulseAudio socket:", err)
} else {
if m := s.Mode(); m&0o006 != 0o006 {
- state.Fatal(fmt.Sprintf("Unexpected permissions on '%s':", pulseS), m)
+ final.Fatal(fmt.Sprintf("Unexpected permissions on '%s':", pulseS), m)
}
}
// Publish current user's pulse-cookie for target user
pulseCookieSource := util.DiscoverPulseCookie()
- pulseCookieFinal := path.Join(system.V.Share, "pulse-cookie")
+ pulseCookieFinal := path.Join(a.sharePath, "pulse-cookie")
a.AppendEnv(util.PulseCookie, pulseCookieFinal)
verbose.Printf("Publishing PulseAudio cookie '%s' to '%s'\n", pulseCookieSource, pulseCookieFinal)
if err = util.CopyFile(pulseCookieFinal, pulseCookieSource); err != nil {
- state.Fatal("Error copying PulseAudio cookie:", err)
+ final.Fatal("Error copying PulseAudio cookie:", err)
}
if err = acl.UpdatePerm(pulseCookieFinal, a.UID(), acl.Read); err != nil {
- state.Fatal("Error publishing PulseAudio cookie:", err)
+ final.Fatal("Error publishing PulseAudio cookie:", err)
} else {
- state.RegisterRevertPath(pulseCookieFinal)
+ final.RegisterRevertPath(pulseCookieFinal)
}
verbose.Printf("PulseAudio dir '%s' configured\n", pulse)