diff --git a/.gitignore b/.gitignore index d0d0cbc..ac2e6cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist *.uid *.remap +*.import diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a0b7657 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Jose Falanga + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile index 52acd14..3004760 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ PLUGIN_ID ?= $(shell grep 'plugin\.id' plugin.json | grep -o ':.*' | grep -o '"[^"]\+"' | sed 's/"//g') PLUGIN_NAME ?= $(shell grep 'plugin\.name' plugin.json | grep -o ':.*' | grep -o '"[^"]\+"' | sed 's/"//g') -GODOT ?= /usr/bin/godot +GODOT ?= $(shell command -v godot 2>/dev/null || echo godot) OPENGAMEPAD_UI_REPO ?= https://github.com/ShadowBlip/OpenGamepadUI.git +OPENGAMEPAD_UI_TAG ?= v0.40.4 OPENGAMEPAD_UI_BASE ?= ../OpenGamepadUI EXPORT_PRESETS ?= $(OPENGAMEPAD_UI_BASE)/export_presets.cfg PLUGINS_DIR := $(OPENGAMEPAD_UI_BASE)/plugins @@ -33,8 +34,8 @@ dist: build ## Build and package plugin .PHONY: build build: $(PLUGINS_DIR)/$(PLUGIN_ID) export_preset ## Build the plugin - @echo "Exporting plugin package" - cd $(OPENGAMEPAD_UI_BASE) && $(MAKE) addons + @echo "Importing project assets (expect non-fatal GDExtension errors without a built core addon)" + cd $(OPENGAMEPAD_UI_BASE) && $(GODOT) --headless --import > /dev/null 2>&1 || true mkdir -p dist touch dist/.gdignore $(GODOT) --headless \ @@ -51,7 +52,7 @@ install: dist ## Installs the plugin @echo "Installed plugin to $(INSTALL_DIR)" $(OPENGAMEPAD_UI_BASE): - git clone $(OPENGAMEPAD_UI_REPO) $@ + git clone --branch $(OPENGAMEPAD_UI_TAG) --depth 1 $(OPENGAMEPAD_UI_REPO) $@ $(PLUGINS_DIR)/$(PLUGIN_ID): $(OPENGAMEPAD_UI_BASE) if ! [ -L $(PLUGINS_DIR)/$(PLUGIN_ID) ]; then ln -s $(PWD) $(PLUGINS_DIR)/$(PLUGIN_ID); fi @@ -60,7 +61,7 @@ $(PLUGINS_DIR)/$(PLUGIN_ID): $(OPENGAMEPAD_UI_BASE) export_preset: $(OPENGAMEPAD_UI_BASE) ## Configure plugin export preset $(eval LAST_PRESET=$(shell grep -oEi '^\[preset\.([0-9]+)]' $(EXPORT_PRESETS) | tail -n 1)) $(eval LAST_PRESET_NUM=$(shell echo "$(LAST_PRESET)" | grep -oE '([0-9]+)')) - $(eval PRESET_NUM=$(shell echo "$(LAST_PRESET_NUM)+1" | bc)) + $(eval PRESET_NUM=$(shell expr $(LAST_PRESET_NUM) + 1)) @if grep 'name="$(PLUGIN_NAME)"' $(EXPORT_PRESETS) > /dev/null; then \ echo "Export preset already configured"; \ else \ diff --git a/README.md b/README.md new file mode 100644 index 0000000..a5bcef4 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Session Switch + +An OpenGamepadUI plugin that adds a **Switch to Steam** button to the power +menu so OpenGamepadUI can return to Steam game mode. + +OpenGamepadUI's built-in ChimeraOS platform support adds a "Switch to Desktop" +button but has no way to get back to Steam game mode once you leave it. This +plugin adds the missing round-trip button. + +## Features + +- Adds a **Switch to Steam** button to the power menu, right above the exit + button. +- Returns to the session that was active before OpenGamepadUI took over, so + your autologin configuration is left untouched. +- Restarts InputPlumber before switching so the gamepad is not left in an + exclusive (blocked) state for Steam. +- No configuration required. + +## Requirements + +- ChimeraOS or SteamOS with OpenGamepadUI running as an exclusive session. +- Godot 4.4.x on the build machine (the plugin bytecode must match the Godot + version embedded in the OpenGamepadUI release you are targeting). + +## Installation + +Download the plugin zip and place it in the plugins directory +(`~/.local/share/opengamepadui/plugins`), or build it yourself: + +```sh +make dist +``` + +Then restart OpenGamepadUI. The **Switch to Steam** button appears in the +power menu. + +## How it works + +- The plugin only activates when the OS session switcher + (`/usr/lib/os-session-select`) is present. On other systems the button is + never added. +- Pressing **Switch to Steam** runs + `os-session-select `, where `` is the value + ChimeraOS recorded in `~/.config/chimeraos-session-return` before + OpenGamepadUI took over (falling back to `gamescope-session-steam-plus`). +- Before switching, it runs `sudo -n systemctl restart inputplumber`. + ChimeraOS's default sudoers grants passwordless access to exactly this + command, so the switch stays non-interactive. If passwordless sudo for + `systemctl restart inputplumber` is not configured on your system, the + restart is skipped with a warning and the switch still proceeds. + +## Compatibility + +Tested with OpenGamepadUI v0.40.4 on ChimeraOS. The plugin pins to the +OpenGamepadUI tag it is built against (`OPENGAMEPAD_UI_TAG` in the Makefile) +so the compiled plugin bytecode always matches the running OpenGamepadUI +version. + +## License + +MIT diff --git a/assets/session-switch.svg b/assets/session-switch.svg new file mode 100644 index 0000000..9a536d4 --- /dev/null +++ b/assets/session-switch.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/docs/icon.png b/docs/icon.png new file mode 100644 index 0000000..493bc4a Binary files /dev/null and b/docs/icon.png differ diff --git a/plugin.json b/plugin.json index 8e11f49..ea084d4 100644 --- a/plugin.json +++ b/plugin.json @@ -5,9 +5,18 @@ "plugin.min-api-version": "1.1.0", "plugin.link": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin", "plugin.source": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin", - "plugin.description": "Adds a 'Switch to Steam' button to the power menu so OpenGamepadUI can return to Steam game mode on ChimeraOS and SteamOS.", - "store.tags": [], - "store.images": [], + "plugin.summary": "Adds a 'Switch to Steam' button to the power menu", + "plugin.description": "Lets OpenGamepadUI return to Steam game mode on ChimeraOS and SteamOS by adding a 'Switch to Steam' button to the power menu, in addition to the built-in 'Switch to Desktop' button.", + "store.tags": [ + "session-switch", + "utility", + "system", + "chimeraos", + "steamos" + ], + "store.images": [ + "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin/raw/branch/trunk/docs/icon.png" + ], "author.name": "Jose Falanga", "author.email": "jose.falanga@gmail.com", "entrypoint": "plugin.gd"