autoexec script / run addon on startup
#1
How can a script or addon be started automatically when xbmc starts? A use case would be to start the add-on "Wake_On_Lan" every time xbmc is started.
Reply
#2
Found this wiki page saying autoexec.py is obsolete and that an addon can be started using the "start tag".

http://wiki.xbmc.org/index.php?title=HOW...g_services
Reply
#3
autoexec.py is still supported in Eden. Services are a special type of add-on and not generally relevant to your question.

To have your autoexec.py do a wakeonlan, which is an emminently reasonable use of autoexec.py, create the following autoexec.py in your userdata folder:

Code:
import xbmc

xbmc.executebuiltin("WakeOnLan(FF:FF:FF:FF:FF:FF)")

Starting an add-on is slightly, but only slightly, harder because you need to work out what command is needed. To do this add the add-on to your favourites and open favourites.xml in a text editor. For example if I do this with the YouTube add-on, my favourites.xml contains:

Code:
<favourite name="YouTube" thumb="C:\Users\renniej\AppData\Roaming\XBMC\addons\plugin.video.youtube\icon.png">ActivateWindow(10024,&quot;plugin://plugin.video.youtube/&quot;)</favourite>

so the script you need would be:

Code:
import xbmc

xbmc.executebuiltin("ActivateWindow(10024,\"plugin://plugin.video.youtube\")")

JR
Reply
#4
Excellent, thanks a lot!

The built-in function WakeOnLan is exactly what I looked for. Now xbmc on my atv2 brings my NAS out of sleep mode.

Will autoexec.py be supported in the final release of Eden (11.0)? Any plans of removing it in Frodo (12.0), or why the comment of obsolete?

Is there a similar Perl script that is called upon when xbmc quits?
Reply
#5
It's obsolete as a mechanism for addons to start on app launch which it has been misused to for all these years
Reply
#6
xbmc_atv2 Wrote:Is there a similar Perl script that is called upon when xbmc quits?

No.

In principle it would be possible to write a service add-on that used JSON to receive notifications from XBMC, and then you could do whatever you wanted e.g. run specified scripts.

JR
Reply
#7
jhsrennie Wrote:To have your autoexec.py do a wakeonlan, which is an emminently reasonable use of autoexec.py, create the following autoexec.py in your userdata folder:

Code:
import xbmc

xbmc.executebuiltin("WakeOnLan(FF:FF:FF:FF:FF:FF)")

This is exactly what i want to do but how do i create this script and where does it go!

Basicaly i want my NAS to boot up when XBMC starts.

Thanks in advance!
Reply
#8
The autoexec.py needs to go in your userdata directory. The location of this directory depends on your operating system. See http://wiki.xbmc.org/index.php?title=Profile_directory for details. In Windows press Windows-R and in the Run dialog type:

"%appdata%\xbmc\userdata"

(including the quotes) and click OK and this will open an Explorer window showing the contents of the userdata folder.

autoexec.py is just a text file, but with the suffix ".py" instead of ".txt". Create it with Notepad, gedit, or whatever your preferred text editor is. In Windows make sure Notepad doesn't helpfully tack ".txt" onto the file name i.e. save the file as "autoexec.py.txt".

JR
Reply
#9
Thanks JR

Something so easy, my brain cell was obviously taking the day off!!
Reply
#10
(2011-12-06, 10:25)jhsrennie Wrote: autoexec.py is still supported in Eden. Services are a special type of add-on and not generally relevant to your question.

To have your autoexec.py do a wakeonlan, which is an emminently reasonable use of autoexec.py, create the following autoexec.py in your userdata folder:

Code:
import xbmc

xbmc.executebuiltin("WakeOnLan(FF:FF:FF:FF:FF:FF)")

Starting an add-on is slightly, but only slightly, harder because you need to work out what command is needed. To do this add the add-on to your favourites and open favourites.xml in a text editor. For example if I do this with the YouTube add-on, my favourites.xml contains:

Code:
<favourite name="YouTube" thumb="C:\Users\renniej\AppData\Roaming\XBMC\addons\plugin.video.youtube\icon.png">ActivateWindow(10024,&quot;plugin://plugin.video.youtube/&quot;)</favourite>

so the script you need would be:

Code:
import xbmc

xbmc.executebuiltin("ActivateWindow(10024,\"plugin://plugin.video.youtube\")")

JR





So I found the actions in favorites which is the following one:

PlayMedia(“plugin://plugin.video.AliveGR/?action=play&url=https%3A%2F%2Fwww.dailymotion.com%2Fvideo%2Fxqjey2_star-lamia-live-streaming_news&title=STAR+K.E.&image=%2Fhome%2Fosmc%2F.kodi%2Faddons%2Fresource.images.alivegr.logos%2Fresources%2Flogos%2FSTAR+CENTRAL+GR.png&plot=%CE%A7%CF%89%CF%81%CE%AF%CF%82+%CF%80%CE%BB%CE%B7%CF%81%CE%BF%CF%86%CE%BF%CF%81%CE%AF%CE%B5%CF%82&genre=%CE%A4%CE%BF%CF%80%CE%B9%CE%BA%CE%AC”)
And I made it like this one:

import xbmc
xbmc.executebuiltin(“PlayMedia(plugin://plugin.video.AliveGR/?action=play&url=https://www.dailymotion.com/video/xqjey2_star-lamia-live-streaming_news&title=STAR+K.E.&image=/home/osmc/.kodi/addons/resource.images.alivegr.logos/resources/logos/STAR+CENTRAL+GR.png&plot=Χωρίς+πληροφορίες&genre=Τοπικά)”)

Did I made it right you think? (I also saved as the suggested name of the file)

Thank for your precious time, I am looking forward to a response.

P.S. the content of the favorite is a legal video stream from a greek channel which is hosted on dailymotion by the channel itself
Reply



Logout Mark Read Team Forum Stats Members Help
autoexec script / run addon on startup1
This forum uses Lukasz Tkacz MyBB addons.