I have KODI OSMC 21.2 running on my Pi4.
The Pi has no mouse nor keyboard.
All things are running fine.
What I miss is: How do I change delaytime/staytime of a pictureshow from terminal?
I found the settings when changed are in the file:
/home/osmc/.kodi/userdata/guisettings.xml
Does it work just changing the value (i.e. with xmlstarlet) and/or do I need to restart Kodi or do I need to reboot?
Would be great if someone has some experience on this. Maybe also a complete other idea how to change the displaytime of the picture show. Best would be “on the fly” (w/o interrupting the show).
Best
Juergen
The settings in that file are memory resident and it is overwritten when Kodi exits so to manually edit that file you must stop Kodi, edit, then start Kodi back up again…
systemctl stop mediacenter
nano ~/.kodi/userdata/guisettings.xml
systemctl start mediacenter
Although it would be less effort to just change the setting in the UI at settings>player>pictures, or using the chorus2 web UI which also gives you access to change that setting.
I doubt “on the fly” is possible.
Sounds good,
Not as good as “on the fly” which I will still look around for.
Better then reboot.
My guess was to do a restart Kodi.
But when exiting overwrites the xml val your solution looks best.
I will use a bash script. No nano as It is to errorprone.
The script I used for testing is easyly adoptable to your idea.
For those who might experiment with it here my code so far:
Parameter: go means no asking, nn is delaytime in secs ($1 or $2)
#!/bin/bash
Test:
#myXML=/home/osmc/guisettings2.xml
#Real life:
myXML=/home/osmc/.kodi/userdata/guisettings.xml
myVAL=${1:-5}
go=1
if [ “$1” != “go” ]; then
go=1 # any value works. it defines the var!
printf “\nGuiSettings XML file used is: "%s"\n\n” $myXML
while true; do
printf “\a”
read -p "Do you wish to change OSMC Kodi picture delay time? " yn
case $yn in
[YyJj]* ) break;;
[Nn]* ) exit;;
* ) echo “Please answer yes or no.”;;
esac
done
else
myVAL=${2:-5}
fi
#echo $myVAL
#echo yes
#exit
Funktioniert!!!
xmlstarlet edit -L --update “//setting[@id=‘slideshow.staytime’]” --value $myVAL $myXML
printf “\nGuiSettings XML file used is: "%s"\n” $myXML
printf “\nKodi picture delay time is now set to "
xmlstarlet sel -t -v “//setting[@id=‘slideshow.staytime’]” $myXML
printf " seconds\n\n”
exit 0
#------------------------------------------------------------------------------------------
It seems to work.
When no “on the fly” change is possible:
Can I read the position of the show and start at that position when service is new started?
I was wrong It does NOT work!
running:
#!/bin/bash
myXML=/home/osmc/.kodi/userdata/guisettings.xml
myVAL=${1:-5}
printf “Please wait …\n\n”
#stop Kodi service
systemctl stop mediacenter
sleep 5
#show used XML file
printf “\nGuiSettings XML file used is: "%s"\n” $myXML
#set new delay value
xmlstarlet edit -L --update “//setting[@id=‘slideshow.staytime’]” --value $myVAL $myXML
#read it and display it
printf “\nKodi picture delay time is now set to "
xmlstarlet sel -t -v “//setting[@id=‘slideshow.staytime’]” $myXML
printf " seconds\n\n”
#start Kodi service
systemctl start mediacenter
That shows at the end the val is set.
running a few moments later:
xmlstarlet sel -t -v “//setting[@id=‘slideshow.staytime’]” $myXML
Shows the old val persists
WHY?
My conclusion is that guisettings.xml is not the file where the Kodi service grabs its initial values.
Solved the change of picture delay.
But I am still open for suggestions how to do it on the fly.
Alternatively how to preserve point where pictures are stopped and start picture show there.
My solution
1st the xml file (.kodi/userdata/advancedsettings.xml:
<?xml version="1.0"?>
<advancedsettings version="1.0">
<slideshow>
<staytime>10</staytime>
</slideshow>
</advancedsettings>
2nd the bash script:
#!/bin/bash
myXML=/home/osmc/.kodi/userdata/guisettings.xml
myAdvancedXML=/home/osmc/.kodi/userdata/advancedsettings.xml
myVAL=${1:-5} # default val of 5
#show used XML file
printf “\nGuiSettings XML file used is: "%s"\n” $myAdvancedXML
#set new delay value
sudo xmlstarlet edit -L --update “//staytime” --value $myVAL $myAdvancedXML
printf “Restarting Kodi Service\n”
service mediacenter restart
sleep 1 # needed to make val valid for next cmd
#read it and display it
printf “\nKodi picture delay time is now set to "
xmlstarlet sel -t -v “//setting[@id=‘slideshow.staytime’]” $myXML
printf " seconds\n\n”
I think you will find by using advancedsettings.xml it takes away the GUI option which may not be what you are trying to do. I didn’t try to parse your script but if the setting isn’t taking by manually editing guisettings.xml it is normally because there is an issue with the way the setting was edited. I would examine the file your script puts out and compare it to one where you manually edited that setting. A common error is that when a setting is set on a default setting it will have a “default=“true”” included and not otherwise. If this isn’t respected then when Kodi starts up it will see it, remove the customization and replace it will the default value.
My suspicions about the on-the-fly probably not being possible is because I expect that setting is read at the start of the slideshow which would necessitate at minimum the slideshow being restarted. I couldn’t find any action id for that function so using a physical remote control or kodi-send at the terminal isn’t an option. I think the closest you might get to what you want would be to use JSON RPC to change the setting (this is what the web UI uses) and then have it stop and start the slideshow again. I don’t think there is a lot of knowledge around here regarding how exactly to use JSON RPC if your not already familiar, but there is a few threads to be found on Kodi’s forum to get you started if you wanted to go that route.
Thanks for the explanation. My last solution works. So I could close the case. I will leave it open for some time just in case there has someone an idea for the on-the-fly issue.
A word to the installation: it is a 27" wall mounted monitor with an Pi4 8GB device.
Only for slide shows. No mouse. No keyboard. Just 2 cables: Power and LAN (for time and terminal)
Changing the USB stick restarts the slide show from a “root” dir (/Bilder/)
That dir can hold themes dirs. Either you start (default) from this “root” dir recursively or by a terminal cmd “startOnDir”
On cold start of the Pi there starts a slideshow from the /Bilder root dir.
Now I can change the delay time of pictures. This is not essential but nice to have as I think it will be requested.
All this is done as a gift to my wife which loves to photograph to enjoy her pictures.
So guys thanks for your explanation and help. If nothing shows up here I will close the case in approx 2 wks.
Best
Jürgen
FYI you might be interested in the “slideshow” key id which let you start a slideshow from a specific directory. I’d think that pointing it to different network shares which you could manipulate at will might be advantageous over physically plugging in a drive. Although typically one would use these to keymap a function to a physical remote, they can also be used with a program called kodi-send if you wanted to use them as part of a script or maybe push actions via ssh. It would be used something like…
kodi-send -a `SlideShow("\\server\pics",recursive,random)`
(The above was from memory and if that doesn’t work you may have to play with the formatting a bit or use escape codes)
I use:
xbmc-send --action=“SlideShow($pathToDir,recursive)” >/dev/null
which works well
Where $pathToDir is somewhat like “/media/OSMC4/Bilder/Tiere”
All sticks are named OSMCn
On that stick is always a root dir for Pictures: “Bilder”
There are subdirs for Themes like animals: “Tiere”
Which assembles to the above path.
Does Playlist.PlayOffset reurns/set the picture number in the “list”
My idea still is:
grab the current position of the slideshow
Stop the slideshow
change delaytime
restart kodi
restart the slideshow on the old position.
Is that possible?
Keymap says:
SlideShow(dir[,recursive][,[not]random][,pause][,beginslide=“/path/to/start/slide.jpg”])
Starts a slideshow of pictures in the folder dir. Optional parameters are ‘recursive’, ‘random’ or ‘notrandom’, ‘pause’ and ‘beginslide=“/path/to/some/image.jpg”’ parameters.
So start at that position should be easy.
So I just need to know how to grab the current pic (with path) to restart on the same pic.
There is another topic of interest with my last question:
When I shutdown my Pi in the evening by crontab I can save the old position and restart in the same position when the Pi starts in the morning.
osmc@VeroV:~$ curl -X POST -H "content-type:application/json" -d '{"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1}' http://osmc:osmc@localhost:80/jsonrpc
{"id":1,"jsonrpc":"2.0","result":[{"playerid":2,"playertype":"internal","type":"picture"}]}
osmc@VeroV:~$ curl -X POST -H "content-type:application/json" -d '{"jsonrpc":"2.0","id":1,"method":"Player.GetItem","params":{"playerid":2,"properties":["file"]}}' http://osmc:osmc@localhost:80/jsonrpc
{"id":1,"jsonrpc":"2.0","result":{"item":{"file":"smb://192.168.254.201/Video/Misc/Misc test files/Test Pictures/Screenshot (64).png","label":"Screenshot (64)","type":"picture"}}}
Never used JSON. I have no experience.
So I used just copy n paste. But it does not work.
Guess formatting here spoils your code.
I don’t think so. Did you accidently copy the "osmc@VeroV:~$ " bit? Did you enable your web interface in Kodi first and allow control? Note that those are two commands I input into the terminal via ssh and their respective outputs. The first command is to get the playerid number which is used in the second command. The playerid integer changes depending on if your playing a pic/video/music/???. Hard to say any more without knowing what exactly was returned when you ran it.
I have done just a minimal amount of playing with it and as such wouldn’t be much help generally speaking on the subject, but the above commands do work and return the file path so that should be enough for you to script something up to get you to your happy place. The only other option I could think of would be to enable debug logging in advancedsettings.xml with the overlay disabled and parse the file name from kodi.log but that would be adding a lot of writes to your SD and that log file might swell to a problematic size over time unless you were restarting Kodi on a regular basis.
Most likely I have not enabled the web interface!
I will care for it and give it another try…
Also note that the url at the end of that curl command relates to the credentials and port number set in Kodi’s web interface settings so you would need to make sure those match up.