aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-09 03:16:54 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-09 03:16:54 +0900
commit38ef2b4d0caf48a5f6bb9d472b76764cbf14d23d (patch)
treeb419ee1d5b700feb43dd061ba336c6fd7f0ccd59 /main.go
parent357cc4ce4d2888033a8163fe39861c8a88301da6 (diff)
app/dbus: manage dbus proxy and pass address to child
This commit adds code that starts and registers the D-Bus proxy, as well as cleanup code that tracks and closes the daemon once our child exits. A few more flags were added to pass D-Bus config to xdg-dbus-proxy. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'main.go')
-rw-r--r--main.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/main.go b/main.go
index 90276602..4aca72f3 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "encoding/json"
"errors"
"flag"
"fmt"
@@ -9,6 +10,7 @@ import (
"strconv"
"syscall"
+ "git.ophivana.moe/cat/fortify/dbus"
"git.ophivana.moe/cat/fortify/internal/acl"
"git.ophivana.moe/cat/fortify/internal/app"
"git.ophivana.moe/cat/fortify/internal/state"
@@ -17,7 +19,9 @@ import (
var (
Version = "impure"
- a *app.App
+
+ a *app.App
+ c *dbus.Config
)
func tryVersion() {
@@ -41,6 +45,21 @@ func main() {
a = app.New(userName, flag.Args())
state.Set(*a.User, a.Command(), a.UID())
+ // parse D-Bus config file if applicable
+ if mustDBus {
+ if dbusConfig == "builtin" {
+ c = dbus.NewConfig(dbusID, true, mpris)
+ } else {
+ if f, err := os.Open(dbusConfig); err != nil {
+ state.Fatal("Error opening D-Bus proxy config file:", err)
+ } else {
+ if err = json.NewDecoder(f).Decode(&c); err != nil {
+ state.Fatal("Error parsing D-Bus proxy config file:", err)
+ }
+ }
+ }
+ }
+
// ensure RunDir (e.g. `/run/user/%d/fortify`)
if err := os.Mkdir(system.V.RunDir, 0700); err != nil && !errors.Is(err, fs.ErrExist) {
state.Fatal("Error creating runtime directory:", err)
@@ -103,7 +122,7 @@ func main() {
}
if mustDBus {
- a.ShareDBus()
+ a.ShareDBus(c)
}
if mustPulse {