Python script to change xbmc system settings
#1
Question 
Hi,

I'm trying to find a way to change system settings from python.
AFAIK there's no builtin functions for either changing (Video output) Display Mode (for example from FullScreen #1 to Full Screen #2) or Resolution (for example from 1920x1080 to 1024x768).

As these settings can be toggled from the user interface (window systemsettings (WINDOW_SETTINGS_SYSTEM ) ID 10016) I was hoping things could be scripted from python as well.

Any ideas?

TIA
Reply
#2
why a script when you can do it in options?
Reply
#3
ppic Wrote:why a script when you can do it in options?

Objective is to have a 1-click action (on the remote control) to switch monitors. Any alternative is ok with me here - as both HTTP-API and JSON lack this functionality I assumed python coding would be my last resort.

I have edited my xorg.conf in such a way that the 2 resolutions left in xbmc system preferences automatically make the switch between monitors already.

Could you please give me a pointer how this could be done with 'options' (I don't have the faintest clue what you mean with that)
Reply
#4
according to the wiki, http-api does include a way to modify system settings.

Quote:SetGUISetting(type; name; value)

Sets the value of GUI setting name to value. Type specifies whether the setting is of type integer (0), boolean (1) or float (2) which must be set correctly or could cause a crash. For a full list of setting names see GUISettings.cpp.

not sure if this is what you're looking for and i certainly haven't tested it myself, but thought i mention it anyway.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
ronie Wrote:according to the wiki, http-api does include a way to modify system settings.



not sure if this is what you're looking for and i certainly haven't tested it myself, but thought i mention it anyway.
Tried that already; no dice though...
I can successfully retrieve the settings with getGUISetting(0;videoscreen.screen) and getGUISetting(0;videoscreen.resolution).
Setting new settings like setGUISetting(0;videoscreen.screen;0) and setGUISetting(0;videoscreen.resolution;14) even return an OK - but nothing happens. (log does show: DEBUG: HttpApi Start command: setGUISetting paras: setGUISetting; 0;videoscreen.resolution;14)

When ticking the 'resolution' button in the skin, log reports XRANDR being triggered and screens _do_ switch automagically (which is the exact thing I'm trying to accomplish with a 1-button action).

Any ideas?
Reply
#6
walinsky Wrote:Any ideas?

afraid not...

maybe you could create a second profile, with the desired video settings
and just map a button on your remote to switch profiles?
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#7
Gah...
I'm afraid loading a second profile would cause xbmc to stop playing it's current playlist (right?).
The beauty of switching screens from within the XBMC GUI lies within the fact that it keeps playing (music, video, live tv, ....)

Anyone?
Reply
#8
bump...
Reply
#9
walinsky Wrote:Gah...
I'm afraid loading a second profile would cause xbmc to stop playing it's current playlist (right?).

currently yes.
someone came up with a patch to change that behavior:
https://github.com/xbmc/xbmc/pull/177
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#10
So changing settings can be done through the HTTP API...but is there any way to forcefully enable the webserver from a script if it's off? The only ways I can see are both ridiculous: manually modifying guisettings.xml to enable it and then using executebuiltin to restart XBMC (which wouldn't restart the running script), or using the builtin functions to open the settings window with setfocus and sendclick to the proper control to turn it on. Neither are good options.
Image
Channel surfing for your video library
Development Blog Repository
Reply
#11
I always thought that the HTTP API class(through xbmc.executehttpapi() ) was always available to addons even when the webserver is turned off(since addons are 'internal') I know this is how xbmc.executeJSONRPC() works.
Reply
#12
Quite right, executehttpapi does work without the web server enabled. I just tested this and was able to change the web server to on...but only the setting itself...the web server still wasn't accessible until I restarted XBMC. It's odd because before a restart I can go to the system settings and see the tick mark for the server being on, but I still can't access the page itself. Looking at the code this makes sense...it sets the setting but doesn't do anything with it. Any clever tricks I can play to actually turn this on?
Image
Channel surfing for your video library
Development Blog Repository
Reply
#13
Jason102 Wrote:So changing settings can be done through the HTTP API...but is there any way to forcefully enable the webserver from a script if it's off? The only ways I can see are both ridiculous: manually modifying guisettings.xml to enable it and then using executebuiltin to restart XBMC (which wouldn't restart the running script), or using the builtin functions to open the settings window with setfocus and sendclick to the proper control to turn it on. Neither are good options.

Exactly my thoughts... HTTP API being a bad choice anyway as it's obsolete in favor of JSON API.
HTTP API will 'set' changes as requested;
Quote:setGUISetting(0;videoscreen.resolution;14)
returns OK, and querying after having that
Quote:getGUISetting(0;videoscreen.resolution)
will even report the new set value.
However it doesn't seem to change anything system-wise...
Reply
#14
walinsky Wrote:Exactly my thoughts... HTTP API being a bad choice anyway as it's obsolete in favor of JSON API.
HTTP API will 'set' changes as requested;
returns OK, and querying after having that will even report the new set value.
However it doesn't seem to change anything system-wise...

The API works on per profile basis, this is true for all interfaces (JSON-RPC included). It has been suggested, and something we think about, introducing a way for a client to authenticate as any profile in JSON-RPC.

Setting wrapping in JSON-RPC is wanted but it waits for a) secret store and password managager, so we can control access to secrets. b) settings remodel so its easier to introspect settings (for now it would have to be hardcoded, which isn't nice and not manageable).
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#15
ronie Wrote:currently yes.
someone came up with a patch to change that behavior:
https://github.com/xbmc/xbmc/pull/177

So did this patch ever make it into a pre-compiled version of XBMC that can be Downloaded?

If not is there any chance of someone compiling a pre-Eden version with the patch included?

Would be a simple solution to the "switch screens from remote control" problem that has several threads on it here...

Thanks a lot if anyone has any ideas about this!
Reply

Logout Mark Read Team Forum Stats Members Help
Python script to change xbmc system settings1