Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple API to change settings #865

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

JelleBouma
Copy link

This PR implements a feature described in Issue #864

This adds:
A JSON Patch API that can be used to change any settings at runtime through an API.
Two new settings (not visible in GUI): bool UseApi (off by default, as this feature should be opt-in), and int ApiPort (the port to be used by the API, default 51111)

Example of an API call to change the theme to "Windows XP Silver":
PATCH http://localhost:51111

[
  {
    "op": "replace",
    "path": "/Theme",
    "value": "Windows XP Silver"
  }
]

@dremin
Copy link
Owner

dremin commented Jun 25, 2024

Hi @JelleBouma, thanks for working on this!

I think a web server is a bit of a heavy way to implement this functionality and introduces new security concerns.

Have you considered using window messages instead? RetroBar could register a message using RegisterWindowMessage, and other applications can also use this to send messages to RetroBar. The only complication there is sending the string of the theme name, since we can't receive a string from another process, however there are a few options:

  • Use WM_COPYDATA to copy the string value cross-process
  • Instead of sending the theme name as a string, instead the other app could modify the RetroBar settings.json directly, and the window message simply acts as a notice to reload the settings.

@JelleBouma
Copy link
Author

I will look into WM_COPYDATA.
I had considered faving the other app modify settings.json directly but it seems like a bad idea due to the unnecessary complexity of having to deal with a large file (whose definition likely changes with each release) to change only specific values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants