From 2107910a56a9f1421992ece09a006c51b39b93c2 Mon Sep 17 00:00:00 2001 From: Avinash Pandey Date: Thu, 21 Sep 2023 13:53:14 +0530 Subject: [PATCH] added sink service --- src/ctl/sinkctl.c | 7 ++++++- systemd/system/miracle-sink.service | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 systemd/system/miracle-sink.service diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index cecf667..a82048c 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -748,9 +748,14 @@ void ctl_fn_peer_disconnected(struct ctl_peer *p) void ctl_fn_link_new(struct ctl_link *l) { - if (cli_running()) + if (cli_running()){ cli_printf("[" CLI_GREEN "ADD" CLI_DEFAULT "] Link: %s\n", l->label); + + // Automatically start the sink on the link. + char *args[1] = {l->label}; + cmd_run(args, 1); + } /* If we're not running but have a bound link, try to find it now and * start running if the link is now available. */ diff --git a/systemd/system/miracle-sink.service b/systemd/system/miracle-sink.service new file mode 100644 index 0000000..5075600 --- /dev/null +++ b/systemd/system/miracle-sink.service @@ -0,0 +1,14 @@ +[Unit] +Description=Miraclecast sink on default link +Before=network.target +After=miracle-wifid.service + +[Service] +Type=simple +ExecStart=/usr/bin/miracle-sinkctl +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +Alias=miracle-sink.service \ No newline at end of file