Archive

Posts Tagged ‘Linux’

PS3 Bluetooth Remote with XBMC on Linux

January 14th, 2013 No comments

SONY DSC
 
 
 
 
 
I used my PS3 bluetooth remote for a while to control my XBMC. But not all keys were mapped because by default the device is mapped as a HID device with only several buttons mapped to actual keys. I found this great howto to be able to use and program all buttons on the remote. Follow the basic steps there to build and install the bdremote driver.

I needed to modify several scripts a bit and added an extra script to be able to log the battery level. (And maybe in the future send some sort of notification when it is almost empty)
 
 
 
 
 
I modified the rc.local script a bit:
(Make sure you set your ID correctly, eg: 00:00:00:00:00:00)

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
 
service bluetooth stop
sleep 1
/usr/local/bin/bdremoteng -a 00:00:00:00:00:00 -p 8888 -t 600 -b /home/yourusername/scripts/battery_change.sh &
sleep 1
mkdir /var/run/lirc
/usr/sbin/lircd -H null --connect 127.0.0.1:8888
sleep 1
service bluetooth start
ln -s /var/run/lirc/lircd /dev/lircd
exit 0

Used the default Lircmap.xml (~/.xbmc/userdata/Lircmap.xml):

<lircmap>
  <remote device="SonyBDRemote">
        <obc101>1</obc101>
        <obc102>2</obc102>
        <obc103>3</obc103>
        <obc104>4</obc104>
        <obc105>5</obc105>
        <obc106>6</obc106>
        <obc107>7</obc107>
        <obc108>8</obc108>
        <obc109>9</obc109>
        <obc110>0</obc110>
        <obc111>enter</obc111>
        <obc112>up</obc112>
        <obc113>right</obc113>
        <obc114>down</obc114>
        <obc115>left</obc115>
        <obc116>circle</obc116>
        <obc117>stop</obc117>
        <obc118>pause</obc118>
        <obc119>ps</obc119>
        <obc120>prev</obc120>
        <obc121>next</obc121>
        <obc122>play</obc122>
        <obc123>scanrev</obc123>
        <obc124>scanfwd</obc124>
        <obc125>cross</obc125>
        <obc126>eject</obc126>
        <obc127>select</obc127>
        <obc128>l3</obc128>
        <obc129>r3</obc129>
        <obc130>start</obc130>
        <obc131>l2</obc131>
        <obc132>r2</obc132>
        <obc133>l1</obc133>
        <obc134>r1</obc134>
        <obc135>triangle</obc135>
        <obc136>topmenu</obc136>
        <obc137>time</obc137>
        <obc138>square</obc138>
        <obc139>return</obc139>
        <obc140>clear</obc140>
        <obc141>popup</obc141>
        <obc142>steprev</obc142>
        <obc143>stepfwd</obc143>
        <obc144>subtitle</obc144>
        <obc145>audio</obc145>
        <obc146>angle</obc146>
        <obc147>display</obc147>
        <obc148>blue</obc148>
        <obc149>red</obc149>
        <obc150>green</obc150>
        <obc151>yellow</obc151>
  </remote>
</lircmap>

And I modified the keymap (~/.xbmc/userdata/keymaps/remote.xml) a bit:

<keymap>
 
  <global>
    <universalremote>
        <obc101>Number1</obc101>
        <obc102>Number2</obc102>
        <obc103>Number3</obc103>
        <obc104>Number4</obc104>
        <obc105>Number5</obc105>
        <obc106>Number6</obc106>
        <obc107>Number7</obc107>
        <obc108>Number8</obc108>
        <obc109>Number9</obc109>
        <obc110>Number0</obc110>
        <obc111>Select</obc111>
        <obc112>Up</obc112>
        <obc113>Right</obc113>
        <obc114>Down</obc114>
        <obc115>Left</obc115>
        <obc116>PreviousMenu</obc116>
        <obc117>Stop</obc117>
        <obc118>Pause</obc118>
        <obc119>XBMC.ActivateWindow(ShutDownMenu)</obc119>
        <obc120>SkipPrevious</obc120>
        <obc121>SkipNext</obc121>
        <obc122>Play</obc122>
        <obc123>Rewind</obc123>
        <obc124>FastForward</obc124>
        <obc125>Info</obc125>
        <obc126>XBMC.EjectTray()</obc126>
        <obc127>Playlist</obc127>
        <obc128>XBMC.updatelibrary(video)</obc128>
        <obc129>XBMC.updatelibrary(music)</obc129>
        <obc130>Queue</obc130>
        <obc131>VolumeDown</obc131>
        <obc132>VolumeUp</obc132>
        <obc133>PageUp</obc133>
        <obc134>PageDown</obc134>
        <obc135>ContextMenu</obc135>
        <obc136>ShowVideoMenu</obc136>
        <obc137>XBMC.ActivateWindow(settings)</obc137>
        <obc139>PreviousMenu</obc139>
        <obc140>BackSpace</obc140>
        <obc141>ContextMenu</obc141>
        <obc142>StepBack</obc142>
        <obc143>StepForward</obc143>
        <obc144>xbmc.activatewindow(pictures)</obc144>
        <obc145>xbmc.activatewindow(music)</obc145>
        <obc146>xbmc.activatewindow(video)</obc146>
        <obc147>FullScreen</obc147>
        <obc148>XBMC.ActivateWindow(favourites)</obc148>
        <obc149>ToggleWatched</obc149>
        <obc150>DecreaseRating</obc150>
        <obc151>IncreaseRating</obc151>
    </universalremote>
  </global>
 
  <fullscreenvideo>
    <universalremote>
        <obc135>XBMC.ActivateWindow(videoosd)</obc135>
        <obc138>CodecInfo</obc138>
        <obc111>AspectRatio</obc111>
        <obc116>FullScreen</obc116>
        <obc139>FullScreen</obc139>
        <obc144>NextSubtitle</obc144>
        <obc137>ShowTime</obc137>
        <obc145>AudioNextLanguage</obc145>
        <obc146>XBMC.ActivateWindow(OSDVideoSettings)</obc146>
        <obc151>XBMC.ActivateWindow(VideoBookmarks)</obc151>
        <obc112>BigStepForward</obc112>
        <obc113>StepForward</obc113>
        <obc114>BigStepBack</obc114>
        <obc115>StepBack</obc115>
    </universalremote>
  </fullscreenvideo>
 
  <visualisation>
    <universalremote>
        <obc135>XBMC.ActivateWindow(musicosd)</obc135>
        <obc138>CodecInfo</obc138>
        <obc139>FullScreen</obc139>
        <obc116>FullScreen</obc116>
        <obc137>Info</obc137>
        <obc145>XBMC.ActivateWindow(OSDAudioSettings)</obc145>
        <obc146>XBMC.ActivateWindow(visualisationsettings)</obc146>
        <obc144>XBMC.ActivateWindow(visualisationpresetlist)</obc144>
    </universalremote>
  </visualisation>
 
  <videoosd>
    <universalremote>
        <obc135>PreviousMenu</obc135>
        <obc137>ShowTime</obc137>
        <obc144>ShowSubtitles</obc144>
        <obc145>XBMC.ActivateWindow(OSDAudioSettings)</obc145>
        <obc146>XBMC.ActivateWindow(OSDVideoSettings)</obc146>
        <obc151>XBMC.ActivateWindow(VideoBookmarks)</obc151>
    </universalremote>
  </videoosd>
 
  <musicosd>
    <universalremote>
        <obc135>PreviousMenu</obc135>
        <obc137>Info</obc137>
        <obc145>XBMC.ActivateWindow(OSDAudioSettings)</obc145>
        <obc146>XBMC.ActivateWindow(visualisationsettings)</obc146>
        <obc144>XBMC.ActivateWindow(visualisationpresetlist)</obc144>
    </universalremote>
  </musicosd>
 
  <OSDVideoSettings>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
    </universalremote>
  </OSDVideoSettings>
 
  <VideoBookmarks>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
        <obc151>PreviousMenu</obc151>
    </universalremote>
  </VideoBookmarks>
 
  <OSDAudioSettings>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
    </universalremote>
  </OSDAudioSettings>
 
  <visualisationsettings>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
    </universalremote>
  </visualisationsettings>
 
  <visualisationpresetlist>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
    </universalremote>
  </visualisationpresetlist>
 
  <favourites>
    <universalremote>
        <obc137>PreviousMenu</obc137>
        <obc144>PreviousMenu</obc144>
        <obc145>PreviousMenu</obc145>
        <obc146>PreviousMenu</obc146>
        <obc148>PreviousMenu</obc148>
    </universalremote>
  </favourites>
 
  <videolibrary>
    <universalremote>
        <obc139>ParentDir</obc139>
        <obc138>ReplaceWindow(videofiles)</obc138>
    </universalremote>
  </videolibrary>
 
  <videofiles>
    <universalremote>
        <obc139>ParentDir</obc139>
        <obc138>ReplaceWindow(videolibrary)</obc138>
    </universalremote>
  </videofiles>
 
  <musiclibrary>
    <universalremote>
        <obc139>ParentDir</obc139>
        <obc138>ReplaceWindow(musicfiles)</obc138>
        <!--
        <obc102>FilterSMS2</obc102>
        <obc103>FilterSMS3</obc103>
        <obc104>FilterSMS4</obc104>
        <obc105>FilterSMS5</obc105>
        <obc106>FilterSMS6</obc106>
        <obc107>FilterSMS7</obc107>
        <obc108>FilterSMS8</obc108>
        <obc109>FilterSMS9</obc109>
        -->
    </universalremote>
  </musiclibrary>
 
  <musicfiles>
    <universalremote>
        <obc139>ParentDir</obc139>
        <obc138>ReplaceWindow(musiclibrary)</obc138>
        <!-- <obc102>FilterSMS2</obc102>
        <obc103>FilterSMS3</obc103>
        <obc104>FilterSMS4</obc104>
        <obc105>FilterSMS5</obc105>
        <obc106>FilterSMS6</obc106>
        <obc107>FilterSMS7</obc107>
        <obc108>FilterSMS8</obc108>
        <obc109>FilterSMS9</obc109>
        -->
    </universalremote>
  </musicfiles>
 
  <fullscreeninfo>
    <universalremote>
        <obc125>PreviousMenu</obc125>
        <obc137>PreviousMenu</obc137>
    </universalremote>
  </fullscreeninfo>
 
  <filemanager>
    <universalremote>
        <obc139>ParentDir</obc139>
        <!-- <obc102>FilterSMS2</obc102>
        <obc103>FilterSMS3</obc103>
        <obc104>FilterSMS4</obc104>
        <obc105>FilterSMS5</obc105>
        <obc106>FilterSMS6</obc106>
        <obc107>FilterSMS7</obc107>
        <obc108>FilterSMS8</obc108>
        <obc109>FilterSMS9</obc109>
        -->
    </universalremote>
  </filemanager>
 
  <pictures>
    <universalremote>
        <obc139>ParentDir</obc139>
    </universalremote>
  </pictures>
 
  <slideshow>
    <universalremote>
        <obc101>ZoomLevel1</obc101>
        <obc102>ZoomLevel2</obc102>
        <obc103>ZoomLevel3</obc103>
        <obc104>ZoomLevel4</obc104>
        <obc105>ZoomLevel5</obc105>
        <obc106>ZoomLevel6</obc106>
        <obc107>ZoomLevel7</obc107>
        <obc108>ZoomLevel8</obc108>
        <obc109>ZoomLevel9</obc109>
        <obc110>ZoomNormal</obc110>
    </universalremote>
  </slideshow>
 
  <virtualkeyboard>
      <universalremote>
        <obc139>BackSpace</obc139>
    </universalremote>
  </virtualkeyboard>
 
  <shutdownmenu>
    <universalremote>
        <obc119>PreviousMenu</obc119>
    </universalremote>
  </shutdownmenu>
 
  <home>
    <universalremote>
        <obc116>FullScreen</obc116>
        <obc139>FullScreen</obc139>
    </universalremote>
  </home>
 
</keymap>

And the battery_change.sh script:

#!/bin/sh
echo "Current battery level is: $2" > /home/yourusername/battery_level.txt

Happy XBMC-ing! 🙂

Categories: Linux Tags: , , , , ,

Sending commands to detached screens

November 5th, 2007 No comments

For running Azureus headless on my linux machine I use screen so it runs in a separate screen.

The command to do this is the following:

screen -d -m -S azureus su -p azureus -c "/opt/azureus/azureus.sh"

This will create a detached screen with the name “azureus” which will run the command “su -p azureus -c “/opt/azureus/azureus.sh”

To send a command to this detached screen we can use the following command structure: (Which I use to tidily close the process)

screen -S azureus -p 0 -X eval 'stuff quit\015'

-p 0 tells screen to use window 0 on the specified screen. Using the eval function makes sure the \015 char will be evaluated back into an enter character. The stuff command is used to fill the input buffer of the screen program.

After this the command “quit” is sent to the azureus client which will cause it to quit and close the attached screen.

Categories: General Tags: , , ,