From 150ac61fc2929fcd2a0f08ab4a7cbcfe7d7fa4e9 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:26:42 +0000 Subject: [PATCH 01/19] Add new bus package for dealing with dbus --- go.mod | 1 + go.sum | 2 ++ internal/bus/bus.go | 26 ++++++++++++++++++++++++++ internal/bus/gamemode.go | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 internal/bus/bus.go create mode 100644 internal/bus/gamemode.go diff --git a/go.mod b/go.mod index 6ee52ab..b34d163 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect gioui.org/shader v1.0.8 // indirect github.com/go-text/typesetting v0.0.0-20231101082850-a36c1d9288f6 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/image v0.13.0 // indirect diff --git a/go.sum b/go.sum index 7f8a5e1..a5330b8 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/go-text/typesetting v0.0.0-20231101082850-a36c1d9288f6 h1:1DDZ2Nr1mno github.com/go-text/typesetting v0.0.0-20231101082850-a36c1d9288f6/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k= github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI= github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/hugolgst/rich-go v0.0.0-20230917173849-4a4fb1d3c362 h1:Q8D2HP1l2mOoeRVLhHjDhK8MRb7LkjESWRtd2gbauws= github.com/hugolgst/rich-go v0.0.0-20230917173849-4a4fb1d3c362/go.mod h1:nGaW7CGfNZnhtiFxMpc4OZdqIexGXjUlBnlmpZmjEKA= github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY= diff --git a/internal/bus/bus.go b/internal/bus/bus.go new file mode 100644 index 0000000..c675671 --- /dev/null +++ b/internal/bus/bus.go @@ -0,0 +1,26 @@ +package bus + +import ( + "github.com/godbus/dbus/v5" +) + +type SessionBus struct{ + conn *dbus.Conn + portal dbus.BusObject +} + +func NewSession() *SessionBus { + conn, err := dbus.ConnectSessionBus() + if err != nil { + return &SessionBus{} + } + + portal := conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop") + + session := &SessionBus{ + conn: conn, + portal: portal, + } + + return session +} diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go new file mode 100644 index 0000000..ecb9cde --- /dev/null +++ b/internal/bus/gamemode.go @@ -0,0 +1,34 @@ +package bus + +import ( + "errors" + "fmt" + "os" + + "github.com/godbus/dbus/v5" +) + +func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { + if s.conn == nil { + return false, nil + } + + fmt.Println(os.Getpid()) + + call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) + if call.Err != nil { + //Transparently handle missing portal + if !errors.Is(call.Err, dbus.ErrMsgNoObject) { + return false, nil + } + return false, call.Err + } + + response := call.Body[0].(int32) + + if response < 0 { + return false, nil + } + + return true, nil +} \ No newline at end of file From f064646f41719eadaef6f1f5b447d96c61c06823 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:28:33 +0000 Subject: [PATCH 02/19] Add new "GameMode" option. This option adds first-class gamemode support into Vinegar via the use of desktop portals. https://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-org.freedesktop.portal.GameMode Enabled by default --- cmd/vinegar/binary.go | 18 +++++++++++++++++- config/config.go | 5 ++++- wine/cmd.go | 8 ++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index ab60482..ed5ef7c 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -25,6 +25,7 @@ import ( "github.com/vinegarhq/vinegar/util" "github.com/vinegarhq/vinegar/wine" "github.com/vinegarhq/vinegar/wine/dxvk" + "github.com/vinegarhq/vinegar/internal/bus" ) const ( @@ -49,6 +50,9 @@ type Binary struct { // Logging Auth bool Activity bsrpc.Activity + + // DBUS session + BusSession *bus.SessionBus } func NewBinary(bt roblox.BinaryType, cfg *config.Config, pfx *wine.Prefix) *Binary { @@ -71,6 +75,8 @@ func NewBinary(bt roblox.BinaryType, cfg *config.Config, pfx *wine.Prefix) *Bina Name: bt.BinaryName(), Type: bt, Prefix: pfx, + + BusSession: bus.NewSession(), } } @@ -122,6 +128,16 @@ func (b *Binary) Run(args ...string) error { log.Printf("Launching %s", b.Name) b.Splash.SetMessage("Launching " + b.Alias) + if err := cmd.RunNoLock(); err != nil { + return fmt.Errorf("roblox process: %w", err) + } + + if b.Config.GameMode { + if _, err := b.BusSession.GamemodeRegister(cmd.Process.Pid); err != nil { + fmt.Fprintf(os.Stderr, "failed to register gamemode: %w", err) + } + } + defer func() { // Don't do anything if the process even ran correctly. if cmd.Process == nil { @@ -149,7 +165,7 @@ func (b *Binary) Run(args ...string) error { b.Prefix.Kill() }() - if err := cmd.Run(); err != nil { + if err := cmd.Wait(); err != nil { return fmt.Errorf("roblox process: %w", err) } diff --git a/config/config.go b/config/config.go index 32846ee..5bd242b 100644 --- a/config/config.go +++ b/config/config.go @@ -35,6 +35,7 @@ type Binary struct { FFlags roblox.FFlags `toml:"fflags"` Env Environment `toml:"env"` ForcedGpu string `toml:"gpu"` + GameMode bool `toml:"gamemode"` } type Config struct { @@ -113,6 +114,7 @@ func Default() Config { Player: Binary{ DiscordRPC: true, Dxvk: true, + GameMode: true, FFlags: roblox.FFlags{ "DFIntTaskSchedulerTargetFps": 640, }, @@ -121,7 +123,8 @@ func Default() Config { }, }, Studio: Binary{ - Dxvk: true, + Dxvk: true, + GameMode: true, }, Splash: Splash{ diff --git a/wine/cmd.go b/wine/cmd.go index ec77cc9..bc8e331 100644 --- a/wine/cmd.go +++ b/wine/cmd.go @@ -82,3 +82,11 @@ func (c *Cmd) Run() error { } return c.Wait() } + +func (c *Cmd) RunNoLock() error { + if err := c.Start(); err != nil { + return err + } + + return nil +} \ No newline at end of file From 565d5567125f6f51c7f7c432874b052a0e2e0221 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:33:44 +0000 Subject: [PATCH 03/19] binary.go: remove %w format directive in Fprintf --- cmd/vinegar/binary.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index ed5ef7c..cf94874 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -134,7 +134,7 @@ func (b *Binary) Run(args ...string) error { if b.Config.GameMode { if _, err := b.BusSession.GamemodeRegister(cmd.Process.Pid); err != nil { - fmt.Fprintf(os.Stderr, "failed to register gamemode: %w", err) + fmt.Fprintf(os.Stderr, "failed to register gamemode: %s", err.Error()) } } From 51c48f4566c25f344eba9f7f11c7ec259491020d Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:15:29 +0000 Subject: [PATCH 04/19] bus.go: declare portal inside of SessionBus struct literal Co-authored-by: sewn Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/bus.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/internal/bus/bus.go b/internal/bus/bus.go index c675671..d827423 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -15,12 +15,8 @@ func NewSession() *SessionBus { return &SessionBus{} } - portal := conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop") - session := &SessionBus{ conn: conn, - portal: portal, + portal: conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop"), } - - return session } From 907c2318d3f0c6bae1d5ee30eb055b5068038c93 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:15:29 +0000 Subject: [PATCH 05/19] Revert "bus.go: declare portal inside of SessionBus struct literal" This reverts commit 51c48f4566c25f344eba9f7f11c7ec259491020d. --- internal/bus/bus.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/bus/bus.go b/internal/bus/bus.go index d827423..c675671 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -15,8 +15,12 @@ func NewSession() *SessionBus { return &SessionBus{} } + portal := conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop") + session := &SessionBus{ conn: conn, - portal: conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop"), + portal: portal, } + + return session } From 815f6a6f0eadfaa60abd19f74250f365e6d0b4d0 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:52:11 +0000 Subject: [PATCH 06/19] bus.go: declare portal inside of SessionBus struct literal (v2) Co-authored-by: sewn Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/bus.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/bus/bus.go b/internal/bus/bus.go index c675671..6f097cd 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -15,12 +15,8 @@ func NewSession() *SessionBus { return &SessionBus{} } - portal := conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop") - - session := &SessionBus{ + return &SessionBus{ conn: conn, - portal: portal, + portal: conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop"), } - - return session } From 93f49f85b8d7a9ac2bace46c53d2908d7e1819df Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:57:39 +0000 Subject: [PATCH 07/19] gamemode.go: simplify return Co-authored-by: sewn Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/gamemode.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go index ecb9cde..b4ec74f 100644 --- a/internal/bus/gamemode.go +++ b/internal/bus/gamemode.go @@ -26,9 +26,5 @@ func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { response := call.Body[0].(int32) - if response < 0 { - return false, nil - } - - return true, nil + return response > 0, nil } \ No newline at end of file From 0bebc3d6f4f72cec8b792f5c693fd05de886cf41 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:06:17 +0000 Subject: [PATCH 08/19] Fixes to code formatting and style --- config/config.go | 2 +- internal/bus/bus.go | 4 ++-- internal/bus/gamemode.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 5bd242b..035363e 100644 --- a/config/config.go +++ b/config/config.go @@ -35,7 +35,7 @@ type Binary struct { FFlags roblox.FFlags `toml:"fflags"` Env Environment `toml:"env"` ForcedGpu string `toml:"gpu"` - GameMode bool `toml:"gamemode"` + GameMode bool `toml:"gamemode"` } type Config struct { diff --git a/internal/bus/bus.go b/internal/bus/bus.go index 6f097cd..bc00197 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -4,7 +4,7 @@ import ( "github.com/godbus/dbus/v5" ) -type SessionBus struct{ +type SessionBus struct { conn *dbus.Conn portal dbus.BusObject } @@ -16,7 +16,7 @@ func NewSession() *SessionBus { } return &SessionBus{ - conn: conn, + conn: conn, portal: conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop"), } } diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go index b4ec74f..b323070 100644 --- a/internal/bus/gamemode.go +++ b/internal/bus/gamemode.go @@ -27,4 +27,4 @@ func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { response := call.Body[0].(int32) return response > 0, nil -} \ No newline at end of file +} From 08c5d617fd5adfde3ac853f82f9407d09b7d9c14 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:14:06 +0000 Subject: [PATCH 09/19] wine/cmd.go: Drop RunNoLock it was completely useless lmao --- cmd/vinegar/binary.go | 2 +- wine/cmd.go | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index cf94874..34feec2 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -128,7 +128,7 @@ func (b *Binary) Run(args ...string) error { log.Printf("Launching %s", b.Name) b.Splash.SetMessage("Launching " + b.Alias) - if err := cmd.RunNoLock(); err != nil { + if err := cmd.Start(); err != nil { return fmt.Errorf("roblox process: %w", err) } diff --git a/wine/cmd.go b/wine/cmd.go index bc8e331..ec77cc9 100644 --- a/wine/cmd.go +++ b/wine/cmd.go @@ -82,11 +82,3 @@ func (c *Cmd) Run() error { } return c.Wait() } - -func (c *Cmd) RunNoLock() error { - if err := c.Start(); err != nil { - return err - } - - return nil -} \ No newline at end of file From f20d538c42b8a488eec73ff93673378e3643cf89 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:17:24 +0000 Subject: [PATCH 10/19] gamemode.go: remove unnecessary print Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/gamemode.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go index b323070..6d54efb 100644 --- a/internal/bus/gamemode.go +++ b/internal/bus/gamemode.go @@ -12,9 +12,7 @@ func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { if s.conn == nil { return false, nil } - - fmt.Println(os.Getpid()) - + call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) if call.Err != nil { //Transparently handle missing portal From c7c0a0682067f50a72e261b28e2d858a4ad8b2c2 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:20:13 +0000 Subject: [PATCH 11/19] gamemode.go: Remove unused imports Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/gamemode.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go index 6d54efb..cb49107 100644 --- a/internal/bus/gamemode.go +++ b/internal/bus/gamemode.go @@ -2,8 +2,6 @@ package bus import ( "errors" - "fmt" - "os" "github.com/godbus/dbus/v5" ) From 82ee7681e0a9b3564c503a9aabb7e77ec8f99bdf Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:28:18 +0000 Subject: [PATCH 12/19] Merged gamemode.go and bus.go together --- internal/bus/bus.go | 21 +++++++++++++++++++++ internal/bus/gamemode.go | 26 -------------------------- 2 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 internal/bus/gamemode.go diff --git a/internal/bus/bus.go b/internal/bus/bus.go index bc00197..1ade669 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -1,6 +1,8 @@ package bus import ( + "errors" + "github.com/godbus/dbus/v5" ) @@ -20,3 +22,22 @@ func NewSession() *SessionBus { portal: conn.Object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop"), } } + +func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { + if s.conn == nil { + return false, nil + } + + call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) + if call.Err != nil { + //Transparently handle missing portal + if !errors.Is(call.Err, dbus.ErrMsgNoObject) { + return false, nil + } + return false, call.Err + } + + response := call.Body[0].(int32) + + return response > 0, nil +} \ No newline at end of file diff --git a/internal/bus/gamemode.go b/internal/bus/gamemode.go deleted file mode 100644 index cb49107..0000000 --- a/internal/bus/gamemode.go +++ /dev/null @@ -1,26 +0,0 @@ -package bus - -import ( - "errors" - - "github.com/godbus/dbus/v5" -) - -func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { - if s.conn == nil { - return false, nil - } - - call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) - if call.Err != nil { - //Transparently handle missing portal - if !errors.Is(call.Err, dbus.ErrMsgNoObject) { - return false, nil - } - return false, call.Err - } - - response := call.Body[0].(int32) - - return response > 0, nil -} From 750c5b4053d285ed903a0feadef9c49efaaf3a9a Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:30:54 +0000 Subject: [PATCH 13/19] Drop unused BusSession.GamemodeRegister() bool return --- cmd/vinegar/binary.go | 2 +- internal/bus/bus.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 34feec2..6e7139d 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -133,7 +133,7 @@ func (b *Binary) Run(args ...string) error { } if b.Config.GameMode { - if _, err := b.BusSession.GamemodeRegister(cmd.Process.Pid); err != nil { + if err := b.BusSession.GamemodeRegister(cmd.Process.Pid); err != nil { fmt.Fprintf(os.Stderr, "failed to register gamemode: %s", err.Error()) } } diff --git a/internal/bus/bus.go b/internal/bus/bus.go index 1ade669..c55f1d2 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -23,21 +23,19 @@ func NewSession() *SessionBus { } } -func (s *SessionBus) GamemodeRegister(pid int) (bool, error) { +func (s *SessionBus) GamemodeRegister(pid int) (error) { if s.conn == nil { - return false, nil + return nil } call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) if call.Err != nil { //Transparently handle missing portal if !errors.Is(call.Err, dbus.ErrMsgNoObject) { - return false, nil + return nil } - return false, call.Err + return call.Err } - response := call.Body[0].(int32) - - return response > 0, nil + return nil } \ No newline at end of file From cca0a7c3f3d87458507de82e578b47f4c4a31986 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:41:08 +0000 Subject: [PATCH 14/19] Last minute go fmt --- cmd/vinegar/binary.go | 2 +- internal/bus/bus.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 6e7139d..261090b 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -16,6 +16,7 @@ import ( bsrpc "github.com/vinegarhq/vinegar/bloxstraprpc" "github.com/vinegarhq/vinegar/config" + "github.com/vinegarhq/vinegar/internal/bus" "github.com/vinegarhq/vinegar/internal/dirs" "github.com/vinegarhq/vinegar/internal/state" "github.com/vinegarhq/vinegar/roblox" @@ -25,7 +26,6 @@ import ( "github.com/vinegarhq/vinegar/util" "github.com/vinegarhq/vinegar/wine" "github.com/vinegarhq/vinegar/wine/dxvk" - "github.com/vinegarhq/vinegar/internal/bus" ) const ( diff --git a/internal/bus/bus.go b/internal/bus/bus.go index c55f1d2..6705e6f 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -23,7 +23,7 @@ func NewSession() *SessionBus { } } -func (s *SessionBus) GamemodeRegister(pid int) (error) { +func (s *SessionBus) GamemodeRegister(pid int) error { if s.conn == nil { return nil } @@ -38,4 +38,4 @@ func (s *SessionBus) GamemodeRegister(pid int) (error) { } return nil -} \ No newline at end of file +} From 4377fb720364686c7763fc67b0bcca60444ed786 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:46:10 +0000 Subject: [PATCH 15/19] Simplify structure of SessionBus.GamemodeRegister Co-authored-by: sewn Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- internal/bus/bus.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/bus/bus.go b/internal/bus/bus.go index 6705e6f..5d0df0a 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -23,17 +23,13 @@ func NewSession() *SessionBus { } } -func (s *SessionBus) GamemodeRegister(pid int) error { +func (s *SessionBus) GamemodeRegister(pid int32) error { if s.conn == nil { return nil } - call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, int32(pid)) - if call.Err != nil { - //Transparently handle missing portal - if !errors.Is(call.Err, dbus.ErrMsgNoObject) { - return nil - } + call := s.portal.Call("org.freedesktop.portal.GameMode.RegisterGame", 0, pid) + if call.Err != nil && !errors.Is(call.Err, dbus.ErrMsgNoObject) { return call.Err } From 3faf1e3864f128a1969ba60248e85e1f011f8aa4 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:49:08 +0000 Subject: [PATCH 16/19] binary.go: convert pid to int32 when calling gamemode register Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- cmd/vinegar/binary.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 261090b..f45fe03 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -133,7 +133,7 @@ func (b *Binary) Run(args ...string) error { } if b.Config.GameMode { - if err := b.BusSession.GamemodeRegister(cmd.Process.Pid); err != nil { + if err := b.BusSession.GamemodeRegister(int32(cmd.Process.Pid)); err != nil { fmt.Fprintf(os.Stderr, "failed to register gamemode: %s", err.Error()) } } From 84ed4558da5c7d5b1a621c273a4ea3991137c957 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:08:57 +0000 Subject: [PATCH 17/19] Rename bus.NewSession() to bus.New() follows vinegar code style choices better --- cmd/vinegar/binary.go | 2 +- internal/bus/bus.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index f45fe03..2cc788b 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -76,7 +76,7 @@ func NewBinary(bt roblox.BinaryType, cfg *config.Config, pfx *wine.Prefix) *Bina Type: bt, Prefix: pfx, - BusSession: bus.NewSession(), + BusSession: bus.New(), } } diff --git a/internal/bus/bus.go b/internal/bus/bus.go index 5d0df0a..3c1842d 100644 --- a/internal/bus/bus.go +++ b/internal/bus/bus.go @@ -11,7 +11,7 @@ type SessionBus struct { portal dbus.BusObject } -func NewSession() *SessionBus { +func New() *SessionBus { conn, err := dbus.ConnectSessionBus() if err != nil { return &SessionBus{} From 0b007d5822a9b4512239d75ea7ee0afd65d14d6f Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:23:22 +0000 Subject: [PATCH 18/19] List Gamemode functionality in README.md Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 38b9a64..54961ef 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,12 @@ An open-source, minimal, configurable, fast bootstrapper for running Roblox on L + Roblox's logs appear within Vinegar + FPS Unlocking for Player by default, without rbxfpsunlocker + Browser launch via MIME ++ Built-in, no hassle, [GameMode](https://github.com/FeralInteractive/gamemode) functionality + Custom execution of wine program within wineprefix + TOML configuration file + Force a specific version of Roblox + Select/Force Roblox release channels, lets you opt into non-production Roblox release channels - + Custom launcher specified to be used when launching Roblox (eg. [GameMode](https://github.com/FeralInteractive/gamemode)). + + Custom launcher specified to be used when launching Roblox + Wine Root, allows you to set a specific wine installation path + Sanitization of environment + Set different environment variables and FFlags for both Player and Studio From f7a55ece93d2b5d44c20cb422b742625c492ccd6 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:26:49 +0000 Subject: [PATCH 19/19] List Gamemode functionality in README.md v2 this sounds way better Signed-off-by: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54961ef..8234bc5 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ An open-source, minimal, configurable, fast bootstrapper for running Roblox on L + Roblox's logs appear within Vinegar + FPS Unlocking for Player by default, without rbxfpsunlocker + Browser launch via MIME -+ Built-in, no hassle, [GameMode](https://github.com/FeralInteractive/gamemode) functionality ++ Automatic [GameMode](https://github.com/FeralInteractive/gamemode) functionality + Custom execution of wine program within wineprefix + TOML configuration file + Force a specific version of Roblox