Compare commits
No commits in common. "v0.1.4" and "trunk" have entirely different histories.
2 changed files with 10 additions and 11 deletions
19
plugin.gd
19
plugin.gd
|
|
@ -10,8 +10,7 @@ extends Plugin
|
||||||
const SESSION_SELECT_PATH := "/usr/lib/os-session-select"
|
const SESSION_SELECT_PATH := "/usr/lib/os-session-select"
|
||||||
const POWER_MENU_GROUP := "power_menu"
|
const POWER_MENU_GROUP := "power_menu"
|
||||||
const BUTTON_NAME := "SwitchToSteamButton"
|
const BUTTON_NAME := "SwitchToSteamButton"
|
||||||
const BUTTON_LABEL := "Switch to Steam"
|
const MAX_ATTEMPTS := 600
|
||||||
const MAX_POLL_FRAMES := 600
|
|
||||||
|
|
||||||
# ChimeraOS records the session that was active before OpenGamepadUI took over
|
# ChimeraOS records the session that was active before OpenGamepadUI took over
|
||||||
# in this file when the OpenGamepadUI session is entered. We return to that
|
# in this file when the OpenGamepadUI session is entered. We return to that
|
||||||
|
|
@ -36,11 +35,11 @@ func _ready() -> void:
|
||||||
if not _has_session_switcher():
|
if not _has_session_switcher():
|
||||||
logger.info("No session switcher script detected: " + SESSION_SELECT_PATH)
|
logger.info("No session switcher script detected: " + SESSION_SELECT_PATH)
|
||||||
return
|
return
|
||||||
_poll_for_power_menu()
|
_add_button_when_ready()
|
||||||
|
|
||||||
|
|
||||||
func _poll_for_power_menu() -> void:
|
func _add_button_when_ready() -> void:
|
||||||
for i in MAX_POLL_FRAMES:
|
for i in MAX_ATTEMPTS:
|
||||||
if _try_add_button():
|
if _try_add_button():
|
||||||
return
|
return
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|
@ -52,11 +51,11 @@ func _try_add_button() -> bool:
|
||||||
if not power_menu:
|
if not power_menu:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var exit_button: Variant = power_menu.get("exit_button")
|
var exit_button = power_menu.get("exit_button")
|
||||||
if not exit_button:
|
if not exit_button:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var container: Variant = exit_button.get_parent()
|
var container = exit_button.get_parent()
|
||||||
if not container:
|
if not container:
|
||||||
return false
|
return false
|
||||||
if container.has_node(BUTTON_NAME):
|
if container.has_node(BUTTON_NAME):
|
||||||
|
|
@ -69,13 +68,13 @@ func _try_add_button() -> bool:
|
||||||
var button := button_scene.instantiate()
|
var button := button_scene.instantiate()
|
||||||
button.name = BUTTON_NAME
|
button.name = BUTTON_NAME
|
||||||
button.set("click_focuses", false)
|
button.set("click_focuses", false)
|
||||||
button.set("text", BUTTON_LABEL)
|
button.set("text", "Switch to Steam")
|
||||||
button.pressed.connect(_switch_session)
|
button.pressed.connect(_switch_session)
|
||||||
|
|
||||||
container.add_child(button)
|
container.add_child(button)
|
||||||
container.move_child(button, exit_button.get_index())
|
container.move_child(button, exit_button.get_index())
|
||||||
|
|
||||||
var focus_group: Variant = power_menu.get("focus_group")
|
var focus_group = power_menu.get("focus_group")
|
||||||
if focus_group and focus_group.has_method("recalculate_focus"):
|
if focus_group and focus_group.has_method("recalculate_focus"):
|
||||||
focus_group.recalculate_focus()
|
focus_group.recalculate_focus()
|
||||||
|
|
||||||
|
|
@ -107,7 +106,7 @@ func _restart_inputplumber() -> void:
|
||||||
var out: Array = []
|
var out: Array = []
|
||||||
var code := OS.execute("sudo", ["-n", "systemctl", "restart", "inputplumber"], out)
|
var code := OS.execute("sudo", ["-n", "systemctl", "restart", "inputplumber"], out)
|
||||||
if code != OK:
|
if code != OK:
|
||||||
logger.warn("Unable to restart InputPlumber: " + _result_text(out))
|
logger.warning("Unable to restart InputPlumber: " + _result_text(out))
|
||||||
|
|
||||||
|
|
||||||
## Returns the session recorded by os-session-select before OpenGamepadUI was
|
## Returns the session recorded by os-session-select before OpenGamepadUI was
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"plugin.id": "chimera-steam-switch",
|
"plugin.id": "chimera-steam-switch",
|
||||||
"plugin.name": "Chimera Steam Switch",
|
"plugin.name": "Chimera Steam Switch",
|
||||||
"plugin.version": "0.1.4",
|
"plugin.version": "0.1.3",
|
||||||
"plugin.min-api-version": "1.1.0",
|
"plugin.min-api-version": "1.1.0",
|
||||||
"plugin.link": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin",
|
"plugin.link": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin",
|
||||||
"plugin.source": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin",
|
"plugin.source": "https://forge.thergic.ar/jose/steam-button-opengamepadui-plugin",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue