DashMachine
DashMachine copied to clipboard
Is it possible to launch shell script by clicking a card ?
I have some useful sh scripts on my home media server (e.g. force restart kodi, poweroff monitor). Can I launch them by clicking a card?
Probably this is a bit unsecure, but my server is in trusted LAN.
I can put those scripts it DashMachine folder if needed.
P.S.: great software, thank you, author!
Why not just make a dummy server to accept rpc calls? Here's a quick Python example:
app.py
import flask
import subprocess
app = flask.Flask("my_server")
@app.route("/kodi/restart")
def restart_kodi():
subprocess.run(["/bin/bash", "restart_kodi.sh"])
@app.route("/monitor/poweroff")
def restart_kodi():
subprocess.run(["/bin/bash", "poweroff_monitor.sh"])
app.run(port=5001) # run on 5001 (or other) to avoid collisions
And you run it on localhost:
python app.py
Then you define a card like this:
[Restart Kodi]
prefix = http://
url = 127.0.0.1:5001
description = Run "restart_kodi.sh"
open_in = new_tab
...
When you click it, it will send a GET request to Flask which will run the Python code. If the only thing you need is running bash scripts (on the same host!) the code above should be fine as it is.