From f231e7343c28d7387d76e6e4c90c8b4d21303538 Mon Sep 17 00:00:00 2001 From: sewn Date: Mon, 5 Aug 2024 15:00:46 +0300 Subject: [PATCH] remove multi instances feature As per Hyperion. --- Makefile | 26 ++++-------- cmd/robloxmutexer/main.go | 87 --------------------------------------- cmd/vinegar/binary.go | 15 ------- cmd/vinegar/main.go | 1 - config/config.go | 19 ++------- dxvk/dxvk.go | 1 - splash/splash.go | 1 - 7 files changed, 11 insertions(+), 139 deletions(-) delete mode 100644 cmd/robloxmutexer/main.go diff --git a/Makefile b/Makefile index 8577f788..c3a1133b 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,11 @@ VERSION = v1.7.5 PREFIX = /usr -BINPREFIX = $(PREFIX)/libexec/vinegar APPPREFIX = $(PREFIX)/share/applications ICONPREFIX = $(PREFIX)/share/icons/hicolor -GO = go -GO_LDFLAGS = -s -w - -VINEGAR_LDFLAGS = $(GO_LDFLAGS) -X main.BinPrefix=$(BINPREFIX) -X main.Version=$(VERSION) -VINEGAR_GOFLAGS = $(GO_GOFLAGS) +GO = go +GO_LDFLAGS = -s -w -X main.Version=$(VERSION) ROBLOX_ICONS = \ assets/icons/128/roblox-player.png assets/icons/128/roblox-studio.png \ @@ -20,15 +16,12 @@ ROBLOX_ICONS = \ VINEGAR_ICON = splash/vinegar.png -all: vinegar robloxmutexer.exe +all: vinegar icons: $(ROBLOX_ICONS) $(VINEGAR_ICON) -install: install-vinegar install-robloxmutexer install-desktop install-icons +install: install-vinegar install-desktop install-icons vinegar: - $(GO) build $(VINEGAR_GOFLAGS) $(GOFLAGS) -ldflags="$(VINEGAR_LDFLAGS)" ./cmd/vinegar - -robloxmutexer.exe: - GOOS=windows $(GO) build $(GOFLAGS) -ldflags="$(GO_LDFLAGS)" ./cmd/robloxmutexer + $(GO) build $(GOFLAGS) -ldflags="$(GO_LDFLAGS)" ./cmd/vinegar $(ROBLOX_ICONS): assets/roblox-player.svg assets/roblox-studio.svg rm -rf assets/icons @@ -47,9 +40,6 @@ install-vinegar: vinegar assets/org.vinegarhq.Vinegar.metainfo.xml install -Dm755 vinegar $(DESTDIR)$(PREFIX)/bin/vinegar install -Dm644 assets/org.vinegarhq.Vinegar.metainfo.xml -t $(DESTDIR)$(PREFIX)/share/metainfo -install-robloxmutexer: robloxmutexer.exe - install -Dm755 robloxmutexer.exe $(DESTDIR)$(BINPREFIX)/robloxmutexer.exe - install-desktop: install -Dm644 assets/desktop/vinegar.desktop $(DESTDIR)$(APPPREFIX)/org.vinegarhq.Vinegar.desktop install -Dm644 assets/desktop/roblox-app.desktop $(DESTDIR)$(APPPREFIX)/org.vinegarhq.Vinegar.app.desktop @@ -72,7 +62,6 @@ install-icons: icons uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/vinegar rm -f $(DESTDIR)$(PREFIX)/share/metainfo/org.vinegarhq.Vinegar.metainfo.xml - rm -f $(DESTDIR)$(BINPREFIX)/robloxmutexer.exe rm -f $(DESTDIR)$(APPPREFIX)/org.vinegarhq.Vinegar.desktop rm -f $(DESTDIR)$(APPPREFIX)/org.vinegarhq.Vinegar.app.desktop rm -f $(DESTDIR)$(APPPREFIX)/org.vinegarhq.Vinegar.player.desktop @@ -89,7 +78,6 @@ uninstall: rm -f $(DESTDIR)$(ICONPREFIX)/128x128/apps/org.vinegarhq.Vinegar.player.png rm -f $(DESTDIR)$(ICONPREFIX)/128x128/apps/org.vinegarhq.Vinegar.studio.png - mime: xdg-mime default org.vinegarhq.Vinegar.player.desktop x-scheme-handler/roblox-player xdg-mime default org.vinegarhq.Vinegar.player.desktop x-scheme-handler/roblox @@ -102,6 +90,6 @@ tests: $(GO) test $(GOFLAGS) ./... clean: - rm -f vinegar robloxmutexer.exe + rm -f vinegar -.PHONY: all install install-vinegar install-robloxmutexer install-desktop install-icons uninstall icons mime tests clean +.PHONY: all install install-vinegar install-desktop install-icons uninstall icons mime tests clean diff --git a/cmd/robloxmutexer/main.go b/cmd/robloxmutexer/main.go deleted file mode 100644 index 78d59278..00000000 --- a/cmd/robloxmutexer/main.go +++ /dev/null @@ -1,87 +0,0 @@ -//go:build windows -// +build windows - -package main - -import ( - "errors" - "log" - "time" - "unsafe" - - "golang.org/x/sys/windows" -) - -func main() { - log.SetPrefix("robloxmutexer: ") - log.SetFlags(log.Lmsgprefix | log.LstdFlags) - - if err := lock(); err != nil { - log.Fatal(err) - } -} - -func lock() error { - name, err := windows.UTF16PtrFromString("ROBLOX_singletonMutex") - if err != nil { - return err - } - - mutex, err := windows.CreateMutex(nil, false, name) - if err != nil { - if errors.Is(err, windows.ERROR_ALREADY_EXISTS) { - return errors.New("Roblox's Mutex is already locked!") - } - return err - } - defer windows.CloseHandle(mutex) - - _, err = windows.WaitForSingleObject(mutex, 0) - if err != nil { - return err - } - - log.Println("Singleton mutex locked, waiting for no roblox processes") - - for { - time.Sleep(5 * time.Second) - r, err := running("RobloxPlayerBeta.exe") - if err != nil { - return err - } - - if !r { - log.Println("No roblox processes found, freeing mutex") - break - } - } - - return nil -} - -func running(exe string) (bool, error) { - snap, err := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPPROCESS, 0) - if err != nil { - return false, err - } - defer windows.CloseHandle(snap) - - pe := windows.ProcessEntry32{ - Size: (uint32)(unsafe.Sizeof(windows.ProcessEntry32{})), - } - - for { - if err := windows.Process32Next(snap, &pe); err != nil { - // Reached end - if err == windows.ERROR_NO_MORE_FILES { - break - } - return false, err - } - if windows.UTF16ToString(pe.ExeFile[:]) == exe { - return true, nil - } - } - - return false, nil -} diff --git a/cmd/vinegar/binary.go b/cmd/vinegar/binary.go index 95b4b411..dca22ced 100644 --- a/cmd/vinegar/binary.go +++ b/cmd/vinegar/binary.go @@ -244,21 +244,6 @@ func (b *Binary) HandleProtocolURI(mime string) { } func (b *Binary) Execute(args ...string) error { - // Studio can run in multiple instances, not Player - if b.GlobalConfig.MultipleInstances && b.Type == clientsettings.WindowsPlayer { - slog.Info("Running robloxmutexer") - - mutexer := b.Prefix.Wine(filepath.Join(BinPrefix, "robloxmutexer.exe")) - if err := mutexer.Start(); err != nil { - return fmt.Errorf("run robloxmutexer: %w", err) - } - go func() { - if err := mutexer.Wait(); err != nil { - slog.Error("robloxmutexer returned too early", "error", err) - } - }() - } - cmd, err := b.Command(args...) if err != nil { return err diff --git a/cmd/vinegar/main.go b/cmd/vinegar/main.go index 1a827d06..5206dfc1 100644 --- a/cmd/vinegar/main.go +++ b/cmd/vinegar/main.go @@ -17,7 +17,6 @@ import ( ) var ( - BinPrefix string ConfigPath string FirstRun bool Version string diff --git a/config/config.go b/config/config.go index 486943e9..67c22d54 100644 --- a/config/config.go +++ b/config/config.go @@ -4,7 +4,6 @@ package config import ( "errors" "fmt" - "log/slog" "os" "os/exec" "path/filepath" @@ -13,7 +12,6 @@ import ( "github.com/BurntSushi/toml" "github.com/apprehensions/rbxbin" "github.com/vinegarhq/vinegar/splash" - "github.com/vinegarhq/vinegar/sysinfo" ) // LogoPath is set at build-time to set the logo icon path, which is @@ -38,11 +36,10 @@ type Binary struct { // Config is a representation of the Vinegar configuration. type Config struct { - MultipleInstances bool `toml:"multiple_instances"` - SanitizeEnv bool `toml:"sanitize_env"` - Player Binary `toml:"player"` - Studio Binary `toml:"studio"` - Env Environment `toml:"env"` + SanitizeEnv bool `toml:"sanitize_env"` + Player Binary `toml:"player"` + Studio Binary `toml:"studio"` + Env Environment `toml:"env"` Splash splash.Config `toml:"splash"` } @@ -176,14 +173,6 @@ func (c *Config) setup() error { SanitizeEnv() } - // On each Flatpak instance, each one has their own wineserver, which means - // if a new Vinegar flatpak instance is ran, with the intent of having two - // running Player instances, one of the wineservers in either sandboxed - // instance will die. - if c.MultipleInstances && sysinfo.InFlatpak { - slog.Warn("Multiple instances is broken on Flatpak! Please consider using a source installation!") - } - c.Env.Setenv() if err := c.Player.setup(); err != nil { diff --git a/dxvk/dxvk.go b/dxvk/dxvk.go index 01028f49..f87500ac 100644 --- a/dxvk/dxvk.go +++ b/dxvk/dxvk.go @@ -77,7 +77,6 @@ func Extract(name string, pfx *wine.Prefix) error { for { hdr, err := tr.Next() - if err != nil { if err == io.EOF { break diff --git a/splash/splash.go b/splash/splash.go index 85d2f98b..b76b7363 100644 --- a/splash/splash.go +++ b/splash/splash.go @@ -125,7 +125,6 @@ func New(cfg *Config) *Splash { } w := window(s.Size()) - th := material.NewTheme() th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))