Kodi Community Forum
Toggle Screensaver on/off through JSON-RPC? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: Toggle Screensaver on/off through JSON-RPC? (/showthread.php?tid=354784)



Toggle Screensaver on/off through JSON-RPC? - satadru - 2020-05-27

So I've got some video chat apps setup on our main kodi machine for this quarantine, and I'd like to be able to programmatically disable the screensaver timeout in kodi when those apps are active.

I'm running kodi via the stable ppa from inside ubuntu/20.04. I'm not seeing functionality to query or disable/enable the screensaver via the info at https://kodi.wiki/view/JSON-RPC_API/v8 . Would that be a feature request?

Any ideas on a better way to do this? (These settings appear to be separate from the default x11 screensaver settings, which I am able to set/unset without any problem otherwise.

This is my setup currently:
Image


RE: Toggle Screensaver on/off through JSON-RPC? - DaVu - 2020-05-27

As the screensaver setting is not a "toggle" but a setting which has different values it will depend on the screensaver in use how to turn it on again. Anyway...the following is the syntax to turn it "off"

curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"none"},"id":"1"}'

Let's imagine you are using "Black" as the screensaver in use:

curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"screensaver.xbmc.builtin.black"},"id":"1"}'

to check for the "value" you have to enter, simply take a look at guisettings.xml to see what is set if you manually turn the screensaver off or set a value to it.


RE: Toggle Screensaver on/off through JSON-RPC? - satadru - 2020-05-28

(2020-05-27, 23:52)DaVu Wrote: As the screensaver setting is not a "toggle" but a setting which has different values it will depend on the screensaver in use how to turn it on again. Anyway...the following is the syntax to turn it "off"

curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"none"},"id":"1"}'

Let's imagine you are using "Black" as the screensaver in use:

curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"screensaver.xbmc.builtin.black"},"id":"1"}'

to check for the "value" you have to enter, simply take a look at guisettings.xml to see what is set if you manually turn the screensaver off or set a value to it.

Thanks so much!
That's exactly the info I needed. 

I had <setting id="screensaver.mode">screensaver.turnoff</setting> in ~/.kodi/userdata/guisettings.xml

So I'm using this now to turn the screensaver off:
curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"none"},"id":"1"}'
and this to turn it back on:
curl -X POST -H 'Content-Type: application/json' -i http://127.0.0.1:8080/jsonrpc --data '{"jsonrpc":"2.0","method":"Settings.SetSettingValue","params":{"setting":"screensaver.mode","value":"screensaver.turnoff"},"id":"1"}'


RE: Toggle Screensaver on/off through JSON-RPC? - Slomo17 - 2023-05-19

Hey, i am trying to acieve the same thing. Problem is if i use your command the Screensaver Mode setting switches to "none" screensaver when i try to turn it off, but the other screensaver settings (Preview, Waittaim etc. ) remain "active" (see screenshot below). This results in the screensaver still beein activated after the set wait time only it is replaced with a black screen. When i switch the screensaver off manually the other settings get deactivate as well.

ImageImage

I saw there is also the build in function to inhibit the screensaver ( InhibitScreensaver(true/false)) and thought maybe that is an alternative way to achieve this, but i couldn't get it to work as i can't figure out the right command to use it. Maybe soeone can give me a hint what i am doing wrong, or if this is just a bug. I am using the latest Libreelec on a Raspberry pi 4 (20.1 Nexus).

Thanks in advance.


RE: Toggle Screensaver on/off through JSON-RPC? - DaVu - 2023-05-29

I can confirm your problem and unfortunately I don't have a solution for you. It seems to be a problem on the latest Kodi master.

The post above was written in 2020. Kodi 18.x was the stable release at that time. Maybe I tested with Kodi 19 master compiled on my own but, tbh, I can't remember anymore. 

Your best bet is to file a bug report at our bug tracker: https://github.com/xbmc/xbmc/issues

Also please provide as much info as possible in less words as possible Wink


RE: Toggle Screensaver on/off through JSON-RPC? - Slomo17 - 2023-06-01

ok, thanks for confirming, than i will file a bug report.


RE: Toggle Screensaver on/off through JSON-RPC? - Fuchs2468 - 2023-06-12

(2023-05-29, 07:41)DaVu Wrote: I can confirm your problem and unfortunately I don't have a solution for you. It seems to be a problem on the latest Kodi master.

The post above was written in 2020. Kodi 18.x was the stable release at that time. Maybe I tested with Kodi 19 master compiled on my own but, tbh, I can't remember anymore. 

I am currently checking the skin Titan mod for a Nexus update.
I noticed that the sreensaver is not deactivated when listening to music.
I never noticed it because I always have a visualisation + fanart background when listening to music, but when I switch to fanart background only, the sreensaver is activated when listening to music.
It should be controlled by the "script.skin.helper.service", but it doesn't work anymore.

Here is the corresponding code:
python:
    def check_screensaver(self):
        '''Allow user to disable screensaver on fullscreen music playback'''
        if getCondVisibility(
                "Window.IsActive(visualisation) + Skin.HasSetting(SkinHelper.DisableScreenSaverOnFullScreenMusic)"):
            if not self.screensaver_disabled:
                # disable screensaver when fullscreen music active
                self.screensaver_disabled = True
                screensaver_setting = kodi_json('Settings.GetSettingValue', '{"setting":"screensaver.mode"}')
                if screensaver_setting:
                    self.screensaver_setting = screensaver_setting
                    kodi_json('Settings.SetSettingValue', {"setting": "screensaver.mode", "value": None})
                    log_msg(
                        "Disabled screensaver while fullscreen music playback - previous setting: %s" %
                        self.screensaver_setting, xbmc.LOGINFO)
        elif self.screensaver_disabled and self.screensaver_setting:
            # enable screensaver again after fullscreen music playback was ended
            kodi_json('Settings.SetSettingValue', {"setting": "screensaver.mode", "value": self.screensaver_setting})
            self.screensaver_disabled = False
            self.screensaver_setting = None
            log_msg(
                "fullscreen music playback ended - restoring screensaver: %s" %
                self.screensaver_setting, xbmc.LOGINFO)


I have tested with kodi versions (18.9, 19.5,20.1). I assume that this code worked until kodi 17.  
But the code doesn't seem to work anymore.
It would of course be good to have this setting directly in kodi settings.
I found this function "screensaver.disableforaudio" in kodi, that should probably be the function I am missing.

Image


RE: Toggle Screensaver on/off through JSON-RPC? - Slomo17 - 2023-06-14

Actually the value needs to be "" like "value":"" instead of "value":"none". This works for me now.