Kodi Starter script for linux: Linux script to start Kodi from Yatse (NeoAcheron)


#1

This post was originally made on previous version of the forum by NeoArcheron


Hi there,

Love your remote app. Its definitely the best XBMC remote ever. However I recently ditched my Windows installation for a linux one and I found that the only feature lacking was a way to let Yatse launch XMBC automatically, just like in Windows with your autostart utility.

So I spent a few minutes writing a little BASH and came up with a script that can be easily started by your linux distribution’s startup manager as a daemon.
PS: Certain distro’s net to install tcpdump separately, so make sure it is installed and working before attempting to run this utility script.

I placed the following into /home/xbmc/autostarter.sh and made the file executable by all:

#!/bin/bash

UDP_PORT=12          # Change this if you need to run this on a different port, just remember to update Yatse's settings as well
RUN_XBMC_AS=xbmc     # Change this if you need to run it as another user

START_PHRASE="YatseStart-Xbmc"    # Do not touch this, unless you know what you are doing...

# The following block checks if the user running this script has the required privileges to listen on the port specified above
   WHO=`whoami` 
   if [ "$WHO" != "root" ]; then
      echo "Unprivileged users may not evesdrop on ports. Cannot start unless running as root."
      exit 1
   fi


echo "Listening on port $UDP_PORT for Yatse remote start command"

while [ true ]; do
   # Wait for a packet to come in from Yatse
   LISTEN=`tcpdump "udp port $UDP_PORT" -A -c 1 2>&1 | grep -o "$START_PHRASE"`
   # Make sure that we received the right command
   if [ "$LISTEN" = "$START_PHRASE" ]; then
      echo "Starting XBMC as $RUN_XBMC_AS"
      # Start XBMC using sudo -u to run it using the username above
      # If you need to you can replace the xbmc command below with xbmc-standalone if you are not using a window manager
      sudo --user=$RUN_XBMC_AS xbmc
   fi 
   # Sleep, to be nice, for unwanted rogue processes writing to our port
   sleep 1
done   

Hope this is as helpful to someone else as it is to me.

Kindest regards,
NeoAcheron


Kodi Starter script for OSX: Remotely launch Kodi on Mac OSX from Yatse (Gonzalo)
#2

I came here looking for the visa versa send a command from linux to open my shield tiv
From what was written here I figured I should just send a UDP packet with the magic string

echo “YatseStart-Xbmc” | nc -w 2 -C -u -N 192.168.1.5 5600

The above did the trick for me


#3

That’s great! I was just looking for such a script :slight_smile:

I had to perform the following 2 modifications in order to get it to work on Kodi18
I changed count (-c option in tcpdump) to 2, as the phrase is actually received on the 2nd packet
LISTEN=tcpdump "udp port $UDP_PORT" -A -c 2 2>&1 | grep -o "$START_PHRASE"

And I had to change the start command to sudo -u, and “xbmc” to “kodi”
sudo -u $RUN_XBMC_AS kodi

Thank you very much NeoAcheron!