2012-03-12, 20:10
Thank you BradVido88 for your hard work on this. I just set it up this weekend and I love it! I run a Linux server and worked up a little script that will automatically run your program. Since XBMC.MyLibrary depends on XBMC running, I also built in functionality to launch and exit XBMC if it was not already running. If it was already running it just leaves it alone and exits. Here it is for anyone else that's interested.
I've done some commenting to give you an idea of what's going on. It uses 'curl' to send an HTTP exit command to XBMC so you've got to have the correct path to control it. You also need to have correct path information for XBMC.MyLibrary to launch.
Save this script and make it executable (chmod +x scriptname.sh) and it is then possible to use a cron job to run it. Since XBMC will launch a GUI you must specify a display in the cron command. Here is what I set up which runs the script once a day at 7:45am (add this using 'crontab -e'):
I've done some commenting to give you an idea of what's going on. It uses 'curl' to send an HTTP exit command to XBMC so you've got to have the correct path to control it. You also need to have correct path information for XBMC.MyLibrary to launch.
Code:
#!/bin/bash
##########################
#This script will run XBMC.MyLibrary
# Because that program needs XBMC to already be running
# this script will also check to see if it is running,
# launch XBMC if it was not running, then exit or
# leave it running depending on the starting circumstances.
#
# Last revision: 3/12/12
###########################
#Check if XBMC is running
if [ `pidof xbmc.bin` ]; then
echo 'XBMC Already Running'
RUNNING=1
else
echo 'XBMC Not Running - script will start and stop it to facilitate XBMC.MyLibrary'
RUNNING=0
xbmc & #launch XBMC
echo 'Pausing 5 seconds for XBMC to launch'
sleep 5
fi
#Run XBMC.MyLibrary program NOTE: You must set your own paths here!!!!
java -jar "/Lenny/scripts/XBMC.MyLibrary-1.3.1/dist/XBMC.MyLibrary.jar" "/Lenny/scripts/XBMC.MyLibrary-1.3.1/"
#Exit XBMC if this script was responsible for launchig it in the first place
if [ "$RUNNING" == 1 ]; then echo Ending script without exiting XBMC
else
echo 'Exiting XBMC'
#Send HTTP command for XBMC to exit NOTE: You must set your own paths here!!!!
curl 'http://xbmc:[email protected]:8080/xbmcCmds/xbmcHttp?command=Exit()'
fi
Save this script and make it executable (chmod +x scriptname.sh) and it is then possible to use a cron job to run it. Since XBMC will launch a GUI you must specify a display in the cron command. Here is what I set up which runs the script once a day at 7:45am (add this using 'crontab -e'):
Code:
45 07 * * * env DISPLAY=:0 /Lenny/scripts/launch-xbmc-mylibrary.sh