Difference between revisions of "Sony PS3 BD Remote Battery"
(New page: Please see: [http://www.xbmc.org/forum/showthread.php?t=50717 xbmc_forum_ps3_remote] - Great setup information and also the following information Below is a very simple script I made so t...) |
m (mark for merge) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{Merge|Sony_PS3_BD_Remote}} | ||
+ | |||
Please see: [http://www.xbmc.org/forum/showthread.php?t=50717 xbmc_forum_ps3_remote] - Great setup information and also the following information | Please see: [http://www.xbmc.org/forum/showthread.php?t=50717 xbmc_forum_ps3_remote] - Great setup information and also the following information | ||
Line 10: | Line 12: | ||
Starting with a remote with the battery out: | Starting with a remote with the battery out: | ||
#Detect remote is connected | #Detect remote is connected | ||
+ | #Get updated event handler and update lirc's hardware.conf (remote must be the last connected bluetooth device) | ||
#restart lirc to start using the remote | #restart lirc to start using the remote | ||
#start mythfrontend --service | #start mythfrontend --service | ||
Line 26: | Line 29: | ||
# get first discovery | # get first discovery | ||
− | + | tail /proc/bus/input/devices | grep -i ps3 > /dev/null | |
discovery=$? | discovery=$? | ||
Line 37: | Line 40: | ||
then | then | ||
while [ "$discovery" -eq 1 ] | while [ "$discovery" -eq 1 ] | ||
− | do | + | do tail /proc/bus/input/devices | grep -i ps3 > /dev/null |
discovery=$? | discovery=$? | ||
+ | xset dpms force off | ||
sleep 1 | sleep 1 | ||
done | done | ||
Line 46: | Line 50: | ||
then | then | ||
while [ "$discovery" -eq 0 ] | while [ "$discovery" -eq 0 ] | ||
− | do | + | do tail /proc/bus/input/devices | grep -i ps3 > /dev/null |
discovery=$? | discovery=$? | ||
sleep 1 | sleep 1 | ||
Line 59: | Line 63: | ||
{ | { | ||
echo "Remote Found - Restarting lirc and running mythfrontend" | echo "Remote Found - Restarting lirc and running mythfrontend" | ||
+ | eventnum=`tail /proc/bus/input/devices | grep Handlers | awk '{print $3}'` | ||
+ | sed -i "s/^REMOTE_DEVICE.*$/REMOTE_DEVICE=\"\/dev\/input\/$eventnum\"/" /etc/lirc/hardware.conf | ||
/etc/init.d/lirc restart | /etc/init.d/lirc restart | ||
xset dpms force on | xset dpms force on | ||
Line 95: | Line 101: | ||
Hopefully someone finds this useful. | Hopefully someone finds this useful. | ||
+ | |||
+ | [[Category:Remote Controls]] |
Latest revision as of 16:45, 22 October 2010
Please see: xbmc_forum_ps3_remote - Great setup information and also the following information
Below is a very simple script I made so that when you first boot the machine you run this in a root terminal (I'm sure you could do it any other number of ways too.). Before I get ahead of myself let me just say at what state you should be at before using it.
After your remote is paired and is functioning just how you like it. When you remove the battery it will remote it from /proc/bus/input/devices, then you put the battery in it returns with the same event number.
Now all this script does is check for it being present in that devices list and perform an action and wait for it to go away and perform another action.
Out of my own preference this is what happens: Starting with a remote with the battery out:
- Detect remote is connected
- Get updated event handler and update lirc's hardware.conf (remote must be the last connected bluetooth device)
- restart lirc to start using the remote
- start mythfrontend --service
- forcefully turn on the display (LCD Monitor)
- Start detecting if remote has been disconnected
- Dectect the remote is disconnected
- Stop lirc
- kill mythfrontend.real
- forcefully turn off the display
- start detecting if the remote is connected
#!/bin/bash # get first discovery tail /proc/bus/input/devices | grep -i ps3 > /dev/null discovery=$? # if the discovery = 1 the remote is not attached # if the discovery = 0 the remote is attached remote_discovery() { if [ "$discovery" -eq 1 ] then while [ "$discovery" -eq 1 ] do tail /proc/bus/input/devices | grep -i ps3 > /dev/null discovery=$? xset dpms force off sleep 1 done enabled=1 take_action else if [ "$discovery" -eq 0 ] then while [ "$discovery" -eq 0 ] do tail /proc/bus/input/devices | grep -i ps3 > /dev/null discovery=$? sleep 1 done enabled=0 take_action fi fi } remote_found() { echo "Remote Found - Restarting lirc and running mythfrontend" eventnum=`tail /proc/bus/input/devices | grep Handlers | awk '{print $3}'` sed -i "s/^REMOTE_DEVICE.*$/REMOTE_DEVICE=\"\/dev\/input\/$eventnum\"/" /etc/lirc/hardware.conf /etc/init.d/lirc restart xset dpms force on sleep 1 (gksudo -u akiko '/usr/bin/mythfrontend --service') & remote_discovery } remote_lost() { echo "Remote Lost - Stopping lirc" /etc/init.d/lirc stop killall -9 mythfrontend.real xset dpms force off remote_discovery } take_action() { case $enabled in 1 ) remote_found;; 0 ) remote_lost;; esac } remote_discovery exit 0
To use it just copy the above into a file called something like ps3_remote_finder.sh Run: chmod +x ps3_remote_finder.sh Then in a root terminal: /<path to the file/ps3_remote_finder.sh
You will need to leave the window open, I like to so that I can check if it has been working as expected.
Hopefully someone finds this useful.