Linux Autoexec.py skin settings
#1
hello, I need help creating an autoexec file.

I want to autoexec.py delete the skin settings when kodi is terminated and replace with new, is that possible with an autoexec.py?
Reply
#2
I fail to see the logic in that. Why do you need Kodi to generate new skins settings each time? And for which skin?
Reply
#3
I like to experiment with skins. and seek a way to change the skins without much effort
Reply
#4
Yes, it is possible, but an autoexec.py might not be the best choice for that. It would have been nice to know which distro you are using.

In fact, the autoexec.py is executed after Kodi starts and not when Kodi is terminated.

If you, by chance, are using LibreELEC, there's another script, called "shutdown.sh" which is able to execute different things depending on the way you shutdown the device (hibernate, shutdown and such).

If you are using a normal linux distro, it might be way easier to simply delete the skin settings file. Each skin is in fact an add-on. On Ubuntu, for example, the settings files for the add-ons are stored under: ~/.kodi/userdata/addon_data/<name_of_add-on>/settings.xml. For example:

davu@davu-laptop1:~/.kodi/userdata/addon_data/skin.aeon.nox.5$ ls
settings.xml
davu@davu-laptop1:~/.kodi/userdata/addon_data/skin.aeon.nox.5$

if you delete that settings.xml in the specific folder (or the complete folder), the specific skin settings are gone.

If you still want to use the autoexec.py it will be more complicated....let's assume the following scenario:

- you have a skin installed and you are actually using it
- you exit kodi
- you start kodi
- after the start the skin will be loaded (the one you previously used) !!! at this point, the skin is still loaded with its previous settings !!!
- then the autoexec.py will be executed and will then probably delete the specific settings.xml file
- then you exit Kodi again !!! and here the problem starts.... IIRC Kodi does save the skin settings after it's being terminated. So you achieved nothing as the settings didn't have changed and are recreated after deleting them !!!
- so after a new Kodi start, you still will have the same skin settings as before.

As for the reason you can't switch skins via an autoexec.py, you have to switch the skin before you terminate Kodi in order to use some other skin at the next startup. If you then have a specific autoexec.py and Kodi will start with another Skin (let's say Estuary) and the autoexec.py will then delete the settings from the skin you are experimenting with and if you load the other skin, it will be as vanilla as it can be.

But, tbh, that's way too much hassle in comparison to manually do: rm -rf ~/.kodi/userdata/addon_data/<skin.name.of.skin> and be done with it after you exited Kodi.

You could also create a little bash-script which does the job for you.
Reply
#5
Thanks for the note with shutdown.sh seems to be just right. I found the following script

case "$1" in
  halt)
    # your commands here
    ;;
  poweroff)
   *
  
# your commands here
    ;;
  reboot)
    # your commands here
    ;;
  *)
    # your commands here
    ;;
esac


because I would have to use only the right commands in the right place then it should work. unfortunately I only know two ider three commands. delete a command for the settings xml from the skin on power off and a command to download a new settings xml from a url would be great.
could you help me a little? I use librelec
Reply
#6
well, I can do the complete script for you. That's not the problem. But it won't be 100% complete as I

1. don't know the skin name you want to delete the settings for
2. don't know the URL you want to download the settings file from

Downloading something while using the shutdown.sh script might fail, because the network-service is terminated before the shutdown.sh script is executed (or at least it's terminated pretty soon). I said "might" fail, because I'm simply not sure if that's still the case. Anyway, the shutdown process won't wait until the download has finished. I know, it's only a little file and normally it should be done within a little moment...but still...it might either fail because the network-service is terminated or the shutdown process will be done before the download will be finished. I will add the command to the script, just to show you how it might look like, but don't expect it to work.

Generally the script could look like:

bash:

case "$1" in
  halt)
  # your commands here
  ;;
  poweroff)
  #this will delete the settings.xml file
  rm -f /storage/.kodi/userdata/addon_data/<skin.name.of.skin>/settings.xml
  #this will download a settings.xml file and place it at the specific folder. Note: the URL should point directly to the file (settings.xml). Otherwise the "-P" won't work!!
  wget <URL/you/want/to/download/settings.xml> -P /storage/.kodi/userdata/addon_data/<skin.name.of.skin>/
  ;;
  reboot)
  # your commands here
  ;;
  *)
  # your commands here
  ;;
esac

You have to replace <skin.name.of.skin> with the ID of the current skin and <URL/you/want/to/download/settings.xml> with the URL you want to download the settings.xml file from. Also be aware that you don't need the <>. Those are only placeholders in that example.

If the above doesn't work for the download, then you could try the `autostart.sh` script which LibreELEC is also able to use. That should be executed before Kodi starts. The wget-command will be the same. See here for an example for the autostart.sh script:

https://libreelec.wiki/autostart.sh


Good luck.
Reply
#7
Thank you very much!
in which directory do I have to copy the shutdown sh purely that it is executed?
Reply
#8
A little bit of own initiative is something we like to see. 

So, if I already give you a link to a specific wiki where everything is explained, you should at least read it Wink

Otherwise one might think you don't care about learning anything as long as someone does the work for you

* DaVu runs Wink
Reply

Logout Mark Read Team Forum Stats Members Help
Autoexec.py skin settings0