Skip to content

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

Description

@wake0up0ne0

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!

Activity

KMouratidis commented on Jan 14, 2021

@KMouratidis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions