Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to launch shell script by clicking a card ? #199

Open
wake0up0ne0 opened this issue Sep 16, 2020 · 1 comment
Open

Is it possible to launch shell script by clicking a card ? #199

wake0up0ne0 opened this issue Sep 16, 2020 · 1 comment

Comments

@wake0up0ne0
Copy link

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!

@KMouratidis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants