boblightd: add possibilty to start / stop addon from addon manager with enable / disable

This commit is contained in:
Stefan Saraev 2012-03-15 11:41:43 +02:00
parent 75011d946b
commit 81a2cedb61
3 changed files with 83 additions and 22 deletions

View File

@ -37,30 +37,43 @@ BOBLIGHT_CONFIG="$ADDON_HOME/boblight.conf"
# Flag file to start boblight-x11 daemon
BOBLIGHT_X11="$ADDON_HOME/boblight.X11"
LOCKDIR="/var/lock/"
LOCKFILE="boblightd.disabled"
export LD_LIBRARY_PATH="$ADDON_DIR/lib:$LD_LIBRARY_PATH"
cp -R $ADDON_DIR/config/*.sample $ADDON_HOME > $LOG_FILE 2>&1
if [ ! "$(pidof boblightd)" ]; then
if [ -e $BOBLIGHT_CONFIG ]; then
# Make sure the xserver has started up
wait_for_xorg
# Start the boblight daemon
boblightd -c $BOBLIGHT_CONFIG -f >> $LOG_FILE 2>&1
fi
if [ -f "$LOCKDIR/$LOCKFILE" ] ; then
rm -rf "$LOCKDIR/$LOCKFILE"
fi
if [ ! "$(pidof boblight-X11)" ]; then
if [ -e $BOBLIGHT_X11 ]; then
if [ -f "$BOBLIGHT_CONFIG" ] ; then
if [ ! "$(pidof boblightd)" ]; then
while [ true ] ; do
if [ -f "$LOCKDIR/$LOCKFILE" ] ; then
break
fi
if [ -e $BOBLIGHT_CONFIG ]; then
# Make sure the xserver has started up
wait_for_xorg
# Start the boblight daemon
boblightd -c $BOBLIGHT_CONFIG >> $LOG_FILE 2>&1
fi
done &
fi
# Make sure the xserver has started up
wait_for_xorg
# Start the boblight daemon
boblight-X11 -f >> $LOG_FILE 2>&1
fi
if [ -e $BOBLIGHT_X11 ]; then
if [ ! "$(pidof boblight-X11)" ]; then
while [ true ] ; do
if [ -f "$LOCKDIR/$LOCKFILE" ] ; then
break
fi
# Make sure the xserver has started up
wait_for_xorg
# Start the boblight daemon
boblight-X11 >> $LOG_FILE 2>&1
done &
fi
fi
fi

View File

@ -0,0 +1,37 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
. /etc/profile
LOCKDIR="/var/lock/"
LOCKFILE="boblightd.disabled"
mkdir -p "$LOCKDIR"
touch "$LOCKDIR/$LOCKFILE"
if [ "$(pidof boblightd)" ];then
killall -9 boblightd
fi
if [ "$(pidof boblight-X11)" ];then
killall -9 boblight-X11
fi

View File

@ -21,12 +21,23 @@
import os
import sys
import xbmcaddon
import time
import subprocess
__scriptname__ = "Boblightd"
__author__ = "OpenELEC"
__url__ = "http://www.openelec.tv"
__settings__ = xbmcaddon.Addon(id='service.multimedia.boblightd')
__cwd__ = __settings__.getAddonInfo('path')
__path__ = xbmc.translatePath( os.path.join( __cwd__, 'bin', "boblightd.service") )
__start__ = xbmc.translatePath( os.path.join( __cwd__, 'bin', "boblightd.start") )
__stop__ = xbmc.translatePath( os.path.join( __cwd__, 'bin', "boblightd.stop") )
os.system(__path__)
#make binary files executable in adson bin folder
subprocess.Popen("chmod -R +x " + __cwd__ + "/bin/*" , shell=True, close_fds=True)
subprocess.Popen(__start__, shell=True, close_fds=True)
while (not xbmc.abortRequested):
time.sleep(0.250)
subprocess.Popen(__stop__, shell=True, close_fds=True)