Enable Run button for Service add-on in Kodi - add-on

I am contributing to the Kodi PartyMode AutoStart add-on.
I would like to add the option to manually trigger the plugin using Kodi's existing "Run" button for add-ons (which is disabled at the moment), so that users can test their settings without having to reboot the device.
I assume that the button is disabled because the add-on is a Service add-on, which are designed to run (per Kodi documentation) at startup or upon login.
My question: is there something I can set in the .py or settings file to enable this Run button, and trigger the plugin, or would I need to change the entire add-on type?

You can define multiple extension points in your addon.xml so your service can also have a script extension point and act on that. So you would have both these.
<extension point="xbmc.python.script" library="defaultscript.py">
<provides>executable</provides>
</extension>
See:
https://github.com/trakt/script.trakt/blob/master/addon.xml#L10-L13

Related

How to make my browser (such as Firefox) open a custom File Manager?

My system is Windows 11 build 22621. Now I use Tablacus Explorer to manage my files instead of Explorer.exe, however, many apps (such as Firefox or Control Panel) will still use Explorer.exe when I try to open directory or other something in those apps,even though I used some Tablacus's plugins such as Shell Execute Hook.
Are there better methods to let other apps to auto open Tablacus as more as possible?
Add "Open Instead" and "System Tray" plugin to solve the problem.

How to install unpacked extension in firefox & chrome?

i have created extension by using crossrider they gave me xpi & crx file which i extracted and want to install manually by copying data to the browser's extension path.
I've read & tried many posts regarding this but they are not helpful because i think some posts are old & not able to find target paths & registry.
like in many posts they say create the following key in the registry here
32-bit Windows: HKEY_LOCAL_MACHINE\Software\Google\Chrome\Extensions
but i couldn't find that on my windows registry & i am using 32bit.
i want something like i copy my extension data to the browser's extension directory & inject some registry value thats all. if it possible then How?
For firefox just add the xpi or unpacked folder to the profile folder. No need for registry so its cross platform.
It can't be automatic as spyware would be all over that. After placing xpi in the extensions folder of the profile, on next startup of Firefox it will prompt saying it found an unauthorized by user add-on, and gives user a chance to enable it, or keep it disabled.
If you want to do it without startup, just launch the file path to the xpi or unpacked folder (if unpacked folder doesnt work, then point it to the install.rdf) in the browser, user will be prompted if they want to install.
There are some registry options though: Install Firefox extension using Windows registry
In Chrome, it's no longer possible to add an extension programmatically on Windows unless the extension is actually published in the Store.
This is for security reasons: previous registry-based (and otherwise) methods were open to malware abuse.
If your extension is published in the store, you can add it semi-automatically via registry. The user will still be asked whether to enable it on the next load.
You can also install extensions silently using Enterprise policy (only if the machine is part of a Windows domain and you have admin rights on the domain policy), on other OSes, or load it unpacked for testing with the --load-extension command line switch (will not persist after Chrome is restarted).
In Chrome go to
chrome://extensions
Enable Developer Mode at the top and click on the button to load an extracted extension.

Run command on client side from browser

For our intraNET we need to run application, when user clicks on link. Security is done another way (apache, firewall). This is only for users in our company. Operation system is WindowsXP+ (some Linux).
I tried link to script file (http://intranet.domain.com/run.bat):
Chrome
can't change mimetype
browser downloads it, and after doubleclick and warning it works with .bat
Opera
with mimetypes tunning, it works with .lnk file, immediatly after click
Firefox
with mimetypes tunning, it works with .lnk file, immediatly after click
Explorer
.bat file works after warning and click on 'Run'
Safari
.bat file works after warning and click on 'Run'
It works, but with warnings and clicking. Maybe there are some other solutions (i read here) using AIR2 plugin or NPAPI plugin, but i have no experiences.
I am looking for ready to use plugin written for this purpose (commercial too). Of course we can install any application/plugin on client computer. Plugin which i can render on webpage and configure to run some command with parameters on click event (command and parameters could change on every page load, can not be compiled in plugin).
I know, there are some questions on this topic, but.. i did not find good solution. Thank you for any help.
All those warnings are there for a reason! If you could run a batch file in this way without warning this would be a huge security risk.
The best way to get this to work would be to write a signed ActiveX control that users download to their PC, install (which would require that the user confirm that they wish to install the control) and then have the ActiveX control run the batch file. This would then allow the ActiveX control to run batch files without prompting the user, however is probably way more hassle than its worth for a one-off action.

Correct way to restore Firefox preferences when Add-On uninstalled by external application

I have written an application suite on Windows which amongst other things installs a Firefox add-on which once run modifies the Firefox network preferences by interfacing with nsIPrefService.
The extension itself resides in a folder under Program Files along with other parts of the application which work together with each other.
Since the application consists of a number of components, the correct way to uninstall it is via the Control Panel or via an uninstall shortcut I provide for the users.
I have no control over whether Firefox will be running or not when the user chooses to uninstall (possibly I could try to detect if it's running in the uninstaller and request the user close it to continue).
Since the purposes of the uninstaller is to remove all traces of the program from the end-users system i.e:
all the files under the Program Files folder, including the extension components
remove the add-on from Firefox (by removing the registry key under HKEY_CURRENT_USER\Software\Mozilla\Firefox\Extensions, causing the add-on to unregister on next Firefox restart)
remove application specific registry keys
Then after uninstall there isn't any of my code left on the users system capable of restoring the network preferences to what they were before the component was installed. This results in end-users not being able to browse the web and being very frustrated!
The only way I can figure out how to do this at the moment is to have my component write to the window's registry the location of the users profile folder - which I can do with my add-on:
Components.classes["#mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties).get("ProfD",
Components.interfaces.nsIFile).path
And then have my uninstaller modify the prefs.js file in that location directly. But this will only work if I can guarantee Firefox isn't running during uninstall (since prefs.js is re-written on FF close)
To me this is not an elegant solution:
It seems not to be future proof since it is dependent on the format and symbols used prefs.js which may change in future FF releases.
Firefox has a nasty habbit of not always closing properlly (sometimes other installed add-ons prevent it from completely unloading from memory. This would break my uninstaller).
This wouldn't work (without elaborate modification) if the user has multiple FF profiles setup all using my add-on.
Is there a better or "standard" way to achieve this simple task?
Did you try to package defaults files (defaults/preferences/myprefs.js) in your extension? I didn't check if it works for overriding Firefox-wide defaults, but it should.
Can't the uninstaller "insist" that Firefox be closed? eg,
check if FireFox is open
if open, inform user "FF must be closed, or cancel uninstall" ok/cancel
loop
I've had several installers do this to me. Not unistallers, though, that I can remember.
Also, this doesn't future-proof the solution, nor deal with profiles.

Programmatically start application on login

What's the best way to programmatically start an application on login for Windows? I know you can do it by adding an item to the startup folder in the start menu, but I want to have an option in my application to turn it off and on.
This is how you could do it in C#:
Registry.SetValue(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
"MyStartUp",
#"C:\StartUpApp.exe");
You basically need to add a registry entry. The above one works on start-up. There are a few more. I recommend that you download a tool like Autoruns to see all possible locations.
How about installing your program as a Windows service? Services can be switched between 'disabled', 'manual' and 'automatic', and you can access services from within your code (even from a Java application) and manipulate its state.
Just a thought.
Yuval =8-)

Resources