Forget autoexec.py: the right way to automatically starts addons - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Forget autoexec.py: the right way to automatically starts addons (/showthread.php?tid=92751) Pages:
1
2
|
- malte - 2011-06-02 I am using autoexec.py in Rom Collection Browser in two scenarios: - relaunching RCB when emulator is used in solo mode (quit XBMC -> start emu -> play game -> quit emu -> start XBMC -> launch RCB) - start scraping games at XBMC startup (background scraping while watching movies etc.) What is the suggested way to get this working with the new service mechanism? 1. Add extension point "xbmc.service" to the original addon pointing to a little startup module that checks what to do (do nothing, launch RCB or start scraping) 2. Add one or two additional service addons that perform the tasks. In this case: How do I enable/disable a service from python code? Edit: Nevermind, I decided to go with the second option. - vikjon0 - 2011-06-04 Quote:What is the suggested way to get this working with the new service mechanism?I am also interested in best practise for this situation. - malte - 2011-06-07 Not sure, if this is the official way, but I did it like this and it was accepted to go into the repo: - In main addon write a setting with the action for the service - On XBMC startup the service checks the setting and disables the setting again - The service does its job Example service code is here. How should service scripts started at login be terminated? - Steve Evans - 2011-09-06 I've followed the guidance at http://wiki.xbmc.org/index.php?title=HOW-TO:_Automatically_start_addons_using_services and have an issue using an autologout service started at login. Before explaining the issue, see the script shown below for reference. addon.xml: Code: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> default.py: Code: import xbmc,time I use profiles to manage who gets to watch what, and also have assigned the red button on my remote to logout by tweaking .xbmc/userdata/keymaps/remote.xml by adding the following. Code: <red>System.LogOff</red> Should I forget to hit the red button after viewing something I don't want the kids watching, the above script will log off automatically after 5 minutes on inactivity. Everything appears OK, however, should I remember to log off, this script, launched at logon, isn't terminated. If I log into and out of a few profiles, several copies of the script end up running at the same time, evidenced by the following appearing in the log 5 minutes later: Code: 19:48:41 T:3069180784 NOTICE: autologout: Logging off In the above example there were clearly three copies of the script still running. So, my question is, how should service scripts started at login be terminated? Steve - paddycarey - 2011-09-26 Is there a way to pass an argument to my script at startup using this method? - Steve Evans - 2011-10-06 Come on guys... I hate to be impatient, but... The URL quoted above describes how to terminate a service launched at startup; ie terminate on XBMC shutdown, but I'm still in the dark about how to terminate a service started at login. There needs to be a function that reports that we're logging out, or have logged out. Steve - _BJ1 - 2011-10-07 I have solved this with a pid-file. if a pid-file isn't present, the process runs at first time, otherwise your process is already running. Don't forget to delete the pid-file if your process terminate correctly otherwise a new process will not start. Code: import os The pid-file is located at ~/.<USER>/temp/script.program.youraddon/youraddon.PID Hope this helps _BJ1 - queeup - 2011-10-27 Is there any way to execute script before exit or stop xbmc? I am trying to stop bash script I started with xbmc.servise on XBMC start. Code: <extension point="xbmc.service" - LakersFan - 2012-01-28 Code: <extension point="xbmc.service" Is there any way I can get it to start with a keyboard button as opposed to login, startup, and/or stop? - Martijn - 2012-01-28 queeup Wrote:Is there any way to execute script before exit or stop xbmc? I am trying to stop bash script I started with xbmc.servise on XBMC start. LakersFan Wrote: Do not use "startup" and "login" at the same time!! Either use "startup" and the script will be run at startup or use "login" and it will be started on login and stopped on logout (logout only from beta3 and up) RE: Forget autoexec.py: the right way to automatically starts addons - leechguy - 2012-10-20 Please be aware that the 'startup' option contains a design flaw when using multiple profiles! Code: <extension point="xbmc.service" Let's assume we have three profiles (Master user, Alice and Bob) and we are using the login screen at startup of XBMC. At startup of XBMC, the service will start automatically and you will be presented with the login screen (if enabled). Now, with no one logged in yet, from which profile will your addon load its settings? Well, actually someone is already logged in and this can be either Master user, Alice or Bob depending on who was logged in during the last session. So when using multiple profiles, the configuration of your addon must be exactly the same for all profiles, otherwise you won't know what your addon will do. One time it will use the settings from Alice, the next time from Bob and another time the settings from the Master user may be used. In my opinion, addon services starting at startup must always use the settings from the Master user, should only be configurable by the master user and should only be enabled/disabled by the master user. Services that require profile specific settings should use the 'login' start type. Any thoughts on this? RE: Forget autoexec.py: the right way to automatically starts addons - Spinner65 - 2012-11-28 Having some form of autoexec.py to auto launch external programs, would great in future releases. I'm using autoexec.py to run some bash scripts (they run xmodmap and hidd commands). If the autoexec.py function is removed after Eden... how would I do the same thing ? RE: Forget autoexec.py: the right way to automatically starts addons - ignisuti - 2013-05-15 Follow-up to Steve Evan's post on 2011-09-06 21:05 concerning the "autologout" script... Where do I place the addon.xml and default.py files? RE: Forget autoexec.py: the right way to automatically starts addons - leechguy - 2013-05-20 (2013-05-15, 05:17)ignisuti Wrote: Follow-up to Steve Evan's post on 2011-09-06 21:05 concerning the "autologout" script... If you want to do auto logout on idle, you may want to check out my addon: Load a configurable default profile on startup of XBMC |