I wanted to revive this thread because I came up with a way to recover the use of the Apple remote when you exit and then restart XBMC after using Hulu Desktop.
What I came up with was a script that runs at the user login and monitors when XBMC starts running and after it has exited it will restart the XBMCHelper if "Allow start of XBMC using the remote" as been enabled.
Create a UNIX shell script called Monitor_XBMC.sh:
Code:
#!/bin/bash
# Algorithm:
#
# Indicate need to check for XBMC running
# Indicate no need to restart XBMCHelper
#
# Loop forever
# if need to check for XBMC running
# then
# if XBMC is running
# then
# Indicate need to restart XBMCHelper
# Indicate no need to check for XBMC running
# end if
# end if
#
# if need to restart XBMCHelper
# then
# if XBMC is not running
# then
# Kill XBMCHelper process
# Start XBMCHelper process
#
# Indicate no need to restart XBMCHelper
# Indicate need to check for XBMC running
# end if
# end if
#
# Go to sleep for 1 second
# end loop
#
# Which XBMC version is being used
XBMC_VER=11
# Different locations for XBMCHelper
XBMC_10_XBMCHelper="osx/XBMCHelper"
XBMC_11_XBMCHelper="runtime/XBMCHelper"
# How to identify if XBMC and XBMCHelper processes are running.
XBMC="MacOS/XBMC"
XBMCHelper=XBMC_${XBMC_VER}_XBMCHelper
XBMCHelper=${!XBMCHelper}
# Different sleep values.
Sleep_Timer=1
TRUE=0
FALSE=1
#
# Function to retrieve the path for a running process.
#
Get_Proc_Path()
{
Proc_Name="$1"
# Get the process list for the user.
ps -a -U `whoami` | grep "${Proc_Name}" | grep -v grep |
# Strip off the path of the process.
while read Process_Info
do
echo "${Process_Info}" | awk '{ print $4 }'
break
done
}
#
# Function to determine if the process is running.
#
Is_Running()
{
# Get the Path where the process is executing.
Proc_Name="$1"
Proc_Path="`Get_Proc_Path ${Proc_Name}`"
Proc_Is_Running=${FALSE}
# If there is no path then the process is not running.
if [ -n "${Proc_Path}" ]
then
Proc_Is_Running=${TRUE}
fi
return ${Proc_Is_Running}
}
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Start by checking if XBMC is running.
Check_For_XBMC_Running=true
Restart_XBMCHelper=false
# Continue to run until stopped.
while (true)
do
# Determine if XBMC is running?
if ($Check_For_XBMC_Running)
then
# Is XBMC running?
if (`Is_Running ${XBMC}`)
then
# Get the path of where XBMCHelper is executing.
XBMCHelper_Path="`Get_Proc_Path ${XBMCHelper}`"
# Don't need to check if XBMC is running.
Check_For_XBMC_Running=false
# Indicate that XBMCHelper needs to be restarted.
Restart_XBMCHelper=true
fi
fi
# Time to restart XBMCHelper?
if ($Restart_XBMCHelper)
then
# Wait for XBMC to exit.
if (! `Is_Running ${XBMC}`)
then
# Only need to restart XBMCHelper if the following is enabled:
# 'Allow start of XBMC using the remote'
if (`Is_Running ${XBMCHelper}`)
then
# Kill the current XBMCHelper process.
killall -9 XBMCHelper
# Restart the XBMCHelper process.
( ( ${XBMCHelper_Path} -x & ) & )
fi
# Start all over again, by determing if XBMC is running.
Check_For_XBMC_Running=true
# Indicate that XBMCHelper does not need to be restarted.
Restart_XBMCHelper=false
fi
fi
# Sleep for a period of time.
sleep $Sleep_Timer
done
I wrote Monitor_XBMC.sh script so that it could work for XBMC 10 and XBMC 11. The location where XBMCHelper resides is different in XBMC 10 and XBMC 11. Set the following line in the shell script (to either 10 or 11) depending on what version of XBMC you are using:
Code:
# Which XBMC version is being used
XBMC_VER=11
Open terminal and "cd" to where the Monitor_XBMC.sh resides. Execute the following from command:
Code:
chmod 755 Monitor_XBMC.sh
Open the AppleScript editor and enter the following:
Code:
do shell script "cd ~; \"Library/Application Support/XBMC/scripts/Monitor_XBMC.sh\""
I place all my scripts pretaining to XBMC in ~/Library/Application Support/XBMC/scripts. This is where I placed the Monitor_XBMC.sh and Monitor_XBMC AppleScript. If you place Monitor_XBMC.sh in a different location make sure to change the Monitor_XBMC AppleScript to reflect that location.
From the AppleScript editor select File -> Save As... Enter Monitor_XBMC as the Save As name and select Application as the File Format. This now creates a application that can be run stand alone.
Open the folder where you created the Monitor_XBMC AppleScript application select Monitor_XBMC, Control-mouse-click and then select "Show Package Contents". Navigate to the Contents folder and open the info.plist with a text editor. Tranverse to the end of the info.plist file and add the following lines just before the last </dict> line:
Code:
<key>NSUIElement</key>
<string>1</string>
Save the info.plist. What you have just now is modified the Monitor_XBMC application so that when you run it it will be hidden from the dock.
The last thing that needs to be done is open System Preferences and add the AppleScript Monitor_XBMC application to login items. The Monitor_XBMC.sh script will be automatically run when you login.
Let me know if there are any issues with using the script.