Skip to content

Instantly share code, notes, and snippets.

@fbarbeira
Last active August 29, 2015 14:01
Show Gist options
  • Save fbarbeira/df5ea3e6810489a03b58 to your computer and use it in GitHub Desktop.
Save fbarbeira/df5ea3e6810489a03b58 to your computer and use it in GitHub Desktop.
xbmc install
aptitude install python-software-properties pkg-config
aptitude install software-properties-common
add-apt-repository ppa:team-xbmc/ppa
aptitude update
aptitude install xbmc
aptitude install vim nvidia-current xserver-xorg xinit alsa-base alsa-tools
dpkg-reconfigure x11-common
(Select "Anyone")
Create a init file for xbmc:
http://wiki.xbmc.org/index.php?title=HOW-TO:Autostart_XBMC_for_Linux
Configure the XBOX 360 wireless controller with LIRC:
http://forum.xbmc.org/showthread.php?tid=51581
or you can execute the script below.
Finally yout have to install this two addons, which doesn't exist in the official xbmc repositories:
- xbmctorrent
- tvalacarta
#!/bin/bash
# Script To Configure XBOX 360 Universal Remote Control For XBMC
# Make sure only root can run this script
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31;40m To place the lirc configuration files in the system directory this script must be run as ROOT ....Example.....sudo ./XBMC-Remote" 1>&2
echo -e "\033[0m"
exit 1
else
echo -e "\033[32m"
# Create Banner
cat << 'EOF' > /tmp/banner
__ __ ____ _____ __ _____ __ ___
\ \/ / | __ ) / _ \ \/ / |___ / / /_ / _ \
\ / | _ \| | | \ / |_ \| '_ \| | | |
/ \ | |_) | |_| / \ ___) | (_) | |_| |
/_/\_\ |____/ \___/_/\_\ |____/ \___/ \___/
_ _ _ _
| | | |_ __ (_)_ _____ _ __ ___ __ _| |
| | | | '_ \| \ \ / / _ \ '__/ __|/ _` | |
| |_| | | | | |\ V / __/ | \__ \ (_| | |
\___/|_| |_|_| \_/ \___|_| |___/\__,_|_|
____ _
| _ \ ___ _ __ ___ ___ | |_ ___
| |_) / _ \ '_ ` _ \ / _ \| __/ _ \
| _ < __/ | | | | | (_) | || __/
|_| \_\___|_| |_| |_|\___/ \__\___|
EOF
# Display Banner
cat /tmp/banner
echo ""
echo ""
# Check to make sure Lirc is installed..if not, ask user if they want to install.
if [ -d /etc/lirc/ ]
then
echo -e "\033[0mChecking if Lirc is installed"
sleep 1
echo -e "\033[0mLirc is installed"
else
echo -e "\e[1;31;40mLirc is not installed but required"
echo -e "\033[0mWould you like to install it? y/n"
read answer
case "$answer" in
y|Y) apt-get install lirc;;
n|N) exit;;
*) echo "y or n";;
esac
fi
if [ $? -ne 0 ]
then
exit
fi
# Loop until a valid user is input
homedir=1
while [ "$homedir" = 1 ]
do
echo ""
echo ""
echo -e "\033[32m What is the username that will run xbmc?"
read user
if [ -d /home/"$user"/ ]
then
homedir=0
else
echo -e "\e[1;31;40mThe username does not exist.....Here is a list of users"
echo -e "\033[0m"
ls /home
homedir=1
fi
done
echo -e "\033[0m"
# got the required info, clear screen and display banner again
clear
cat /tmp/banner
echo ""
echo ""
sleep 1
# Backup if existing and create /etc/lirc/hardware.conf
echo -e "\033[32m Backing up and creating /etc/lirc/hardware.conf"
mv --backup=numbered /etc/lirc/hardware.conf /etc/lirc/hardware.conf.bak > /dev/null 2>&1
cat << 'EOF' > /etc/lirc/hardware.conf
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE=Microsoft_Xbox360
REMOTE_MODULES=
REMOTE_DRIVER=
REMOTE_DEVICE=/dev/lirc0
REMOTE_LIRCD_CONF=
REMOTE_LIRCD_ARGS=--release
#Chosen IR Transmitter
TRANSMITTER=None
TRANSMITTER_MODULES=
TRANSMITTER_DRIVER=
TRANSMITTER_DEVICE=
TRANSMITTER_LIRCD_CONF=
TRANSMITTER_LIRCD_ARGS=
#Enable lircd
START_LIRCD=true
#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false
#Try to load appropriate kernel modules
LOAD_MODULES=true
# Default configuration files for your hardware if any
LIRCMD_CONF=
#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to false
FORCE_NONINTERACTIVE_RECONFIGURATION=false
START_LIRCMD=
EOF
# Check to see if a file was created with the correct name
if [ -f /etc/lirc/hardware.conf ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
# Backup if existing and create /etc/lirc/lircd.conf
sleep 1
echo -e "\033[32m Backing up and creating /etc/lirc/lircd.conf"
mv --backup=numbered /etc/lirc/lircd.conf /etc/lirc/lircd.conf.bak > /dev/null 2>&1
cat << 'EOF' > /etc/lirc/lircd.conf
# this config file was automatically generated
# using lirc-0.8.0-CVS(mceusb2) on Tue Jan 17 15:14:11 2006
#
#
# brand: Microsoft
# model no. of remote control: Xbox 360 Universal Media Remote
# devices being controlled by this remote: Xbox 360
#
# This probably works for the normal Xbox 360 remote too.
#
# Living, He loved me, dying, He saved me
# Buried, He carried my sins far away
# Rising, He justified freely forever
# One day He's coming, oh, glorious day
#
# TV button sends no signal and toggles Xbox 360/TV mode. TV mode can be
# signals for any device the remote supports. Volume Up, Volume Down and
# Mute always use the TV mode while the Xbox live guide button always sends
# to the xbox.
begin remote
name Microsoft_Xbox360
bits 13
flags RC6|CONST_LENGTH
eps 30
aeps 100
header 2682 906
one 438 451
zero 438 451
pre_data_bits 24
pre_data 0x1BFF80
gap 107066
toggle_bit_mask 0x8000
rc6_mask 0x100000000
begin codes
OpenClose 0x8BD7
XboxFancyButton 0x0B9B
OnOff 0x8BF3
Stop 0x0BE6
Pause 0x8BE7
Rewind 0x0BEA
FastForward 0x8BEB
Prev 0x0BE4
Next 0x8BE5
Play 0x0BE9
Display 0x8BB0
Title 0x0BAE
DVD_Menu 0x8BDB
Back 0x0BDC
Info 0x8BF0
UpArrow 0x0BE1
LeftArrow 0x8BDF
RightArrow 0x0BDE
DownArrow 0x8BE0
OK 0x0BDD
Y 0x8BD9
X 0x0B97
A 0x8B99
B 0x0BDA
PgDown 0x0B92
PgUp 0x0B93
VolDown 0x0bee
VolUp 0x0bef
Mute 0x0bf1
TV 0x0bb9
Start 0x0BF2
Play 0x8BE9
Enter 0x0BF4
Record 0x8BE8
Clear 0x0BF5
1 0x8BFE
2 0x0BFD
3 0x8BFC
4 0x0BFB
5 0x8BFA
6 0x0BF9
7 0x8BF8
8 0x0BF7
9 0x8BF6
100 0x0BE2
0 0x8BFF
Reload 0x8BE3
end codes
end remote
EOF
# Check to see if a file was created with the correct name
if [ -f /etc/lirc/lircd.conf ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
# Backup if existing and create /home/"$user"/.xbmc/userdata/Lircmap.xml
sleep 1
echo -e "\033[32m Backing up and creating /home/"$user"/.xbmc/userdata/Lircmap.xml"
mv --backup=numbered /home/"$user"/.xbmc/userdata/Lircmap.xml /home/"$user"/.xbmc/userdata/Lircmap.xml.bak > /dev/null 2>&1
cat << 'EOF' > /home/"$user"/.xbmc/userdata/Lircmap.xml
<!-- This file contains the mapping of LIRC keys to XBMC keys used in Keymap.xml -->
<!-- -->
<!-- How to add remotes -->
<!-- <remote device=name_Lirc_calls_the_remote> -->
<!-- -->
<!-- For the commands the layout following layout is used -->
<!-- <XBMC_COMMAND>LircButtonName</XBMC_COMMAND> -->
<!-- -->
<!-- For a list of XBMC_COMMAND's check out the <remote> sections of keymap.xml -->
<lircmap>
<remote device=Microsoft_Xbox360>
<left>LeftArrow</left>
<right>RightArrow</right>
<up>UpArrow</up>
<down>DownArrow</down>
<select>OK</select>
<back>Back</back>
<forward>FastForward</forward>
<reverse>Rewind</reverse>
<play>Play</play>
<pause>Pause</pause>
<stop>Stop</stop>
<volumeplus>VolUp</volumeplus>
<volumeminus>VolDown</volumeminus>
<mute>Mute</mute>
<pageminus>PgDown</pageminus>
<pageplus>PgUp</pageplus>
<zero>0</zero>
<one>1</one>
<two>2</two>
<three>3</three>
<four>4</four>
<five>5</five>
<six>6</six>
<seven>7</seven>
<eight>8</eight>
<nine>9</nine>
<power>OnOff</power>
<skipplus>Next</skipplus>
<skipminus>Prev</skipminus>
<display>Display</display>
<record>Record</record>
<start>Start</start>
<info>Info</info>
<menu>DVD_Menu</menu>
<myvideo>Y</myvideo>
<mymusic>X</mymusic>
<mypictures>A</mypictures>
<mytv>B</mytv>
<hash>Enter</hash>
<clear>Clear</clear>
<title>Title</title>
<star>OpenClose</star>
<xbox>XboxFancyButton</xbox>
</remote>
</lircmap>
EOF
# Check to see if a file was created with the correct name
if [ -f /home/"$user"/.xbmc/userdata/Lircmap.xml ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
# This is a user file so we will change ownership back to the specified user because script is run as root
chown "$user":"$user" /home/"$user"/.xbmc/userdata/Lircmap.xml
# Backup if existing and create /home/"$user"/.xbmc/userdata/keymaps/remote.xml
sleep 1
echo -e "\033[32m Backing up and creating /home/"$user"/.xbmc/userdata/keymaps/remote.xml"
mv --backup=numbered /home/"$user"/.xbmc/userdata/keymaps/remote.xml /home/"$user"/.xbmc/userdata/keymaps/remote.xml.bak > /dev/null 2>&1
cat << 'EOF' > /home/"$user"/.xbmc/userdata/keymaps/remote.xml
<!-- This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within XBMC -->
<!-- The <global> section is a fall through - they will only be used if the button is not -->
<!-- used in the current window's section. Note that there is only handling -->
<!-- for a single action per button at this stage. -->
<!-- For joystick/gamepad configuration under linux/win32, see below as it differs from xbox -->
<!-- gamepads. -->
<!-- The format is: -->
<!-- <device> -->
<!-- <button>action</button> -->
<!-- </device> -->
<!-- To map keys from other remotes using the RCA protocol, you may add <universalremote> blocks -->
<!-- In this case, the tags used are <obc#> where # is the original button code (OBC) of the key -->
<!-- You set it up by adding a <universalremote> block to the window or <global> section: -->
<!-- <universalremote> -->
<!-- <obc45>Stop</obc45> -->
<!-- </universalremote> -->
<!-- Note that the action can be a built-in function. -->
<!-- eg <B>XBMC.ActivateWindow(MyMusic)</B> -->
<!-- would automatically go to My Music on the press of the B button. -->
<!-- Joysticks / Gamepads: -->
<!-- See the sample PS3 controller configuration below for the format. -->
<!-- -->
<!-- Joystick Name: -->
<!-- Do 'cat /proc/bus/input/devices' or see your xbmc log file to find the names of -->
<!-- detected joysticks. The name used in the configuration should match the detected name. -->
<!-- -->
<!-- Button Ids: -->
<!-- 'id' is the button ID used by SDL. Joystick button ids of connected joysticks appear -->
<!-- in xbmc.log when they are pressed. Use your log to map custom buttons to actions. -->
<!-- -->
<!-- Axis Ids / Analog Controls -->
<!-- Coming soon. -->
<keymap>
<global>
<remote>
<play>Play</play>
<pause>Pause</pause>
<stop>Stop</stop>
<forward>FastForward</forward>
<reverse>Rewind</reverse>
<left>Left</left>
<right>Right</right>
<up>Up</up>
<down>Down</down>
<select>Select</select>
<enter>FullScreen</enter>
<pageplus>PageUp</pageplus>
<pageminus>PageDown</pageminus>
<back>ParentDir</back>
<menu>ContextMenu</menu>
<title>ContextMenu</title>
<info>Info</info>
<skipplus>SkipNext</skipplus>
<skipminus>SkipPrevious</skipminus>
<display>FullScreen</display>
<start>XBMC.ActivateWindow(Favourites)</start>
<record>Screenshot</record>
<volumeplus>VolumeUp</volumeplus>
<volumeminus>VolumeDown</volumeminus>
<mute>Mute</mute>
<power>XBMC.RestartApp()</power>
<myvideo>XBMC.ActivateWindow(VideoLibrary,MovieTitles)</myvideo>
<mymusic>XBMC.ActivateWindow(Weather)</mymusic>
<mypictures>XBMC.ActivateWindow(MyPictures)</mypictures>
<mytv>XBMC.ActivateWindow(VideoLibrary,TvShowTitles)</mytv>
<zero>XBMC.RestartApp()</zero>
<one>Number1</one>
<two>JumpSMS2</two>
<three>JumpSMS3</three>
<four>JumpSMS4</four>
<five>JumpSMS5</five>
<six>JumpSMS6</six>
<seven>JumpSMS7</seven>
<eight>JumpSMS8</eight>
<nine>JumpSMS9</nine>
<!-- <star>EjectTray()</star> -->
<xbox>scanitem</xbox>
</remote>
</global>
<Home>
<remote>
<info>XBMC.ActivateWindow(SystemInfo)</info>
<clear>XBMC.ActivateWindow(Weather)</clear>
<hash>XBMC.ActivateWindow(Settings)</hash>
</remote>
</Home>
<MyFiles>
<remote>
<clear>Delete</clear>
<zero>Highlight</zero>
<star>Move</star>
<hash>Rename</hash>
</remote>
</MyFiles>
<MyMusicPlaylist>
<remote>
<back>Playlist</back> <!-- Close playlist -->
<clear>Delete</clear>
<zero>Delete</zero>
</remote>
</MyMusicPlaylist>
<MyMusicPlaylistEditor>
<remote>
<zero>Queue</zero>
</remote>
</MyMusicPlaylistEditor>
<MyMusicFiles>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyMusicFiles>
<MyMusicLibrary>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyMusicLibrary>
<FullscreenVideo>
<remote>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<left>StepBack</left>
<right>StepForward</right>
<up>BigStepForward</up>
<down>BigStepBack</down>
<back>SmallStepBack</back>
<menu>OSD</menu>
<start>TakeScreenshot</start>
<select>AspectRatio</select>
<title>CodecInfo</title>
<info>Info</info>
<teletext>XBMC.ActivateWindow(Teletext)</teletext>
<display>ShowSubtitles</display>
<subtitle>ShowSubtitles</subtitle>
<star>EjectTray()</star>
<language>AudioNextLanguage</language>
<hash>AudioNextLanguage</hash>
</remote>
</FullscreenVideo>
<VideoTimeSeek>
<remote>
<select>Select</select>
<enter>Select</enter>
</remote>
</VideoTimeSeek>
<FullscreenInfo>
<remote>
<title>CodecInfo</title>
<info>Close</info>
<menu>OSD</menu>
</remote>
</FullscreenInfo>
<PlayerControls>
<remote>
<menu>Close</menu>
</remote>
</PlayerControls>
<Visualisation>
<remote>
<left>PreviousPreset</left>
<right>NextPreset</right>
<up>IncreaseRating</up>
<down>DecreaseRating</down>
<back>LockPreset</back>
<title>CodecInfo</title>
<select>XBMC.ActivateWindow(VisualisationPresetList)</select>
<menu>XBMC.ActivateWindow(MusicOSD)</menu>
<start>XBMC.ActivateWindow(MusicOSD)</start>
<info>Info</info>
</remote>
</Visualisation>
<MusicOSD>
<remote>
<menu>Close</menu>
<title>Info</title>
<info>CodecInfo</info>
</remote>
</MusicOSD>
<VisualisationSettings>
<remote>
<menu>Close</menu>
<back>Close</back>
</remote>
</VisualisationSettings>
<VisualisationPresetList>
<remote>
<menu>Close</menu>
<back>Close</back>
</remote>
</VisualisationPresetList>
<SlideShow>
<remote>
<zero>ZoomNormal</zero>
<one>ZoomLevel1</one>
<two>ZoomLevel2</two>
<three>ZoomLevel3</three>
<four>ZoomLevel4</four>
<five>ZoomLevel5</five>
<six>ZoomLevel6</six>
<seven>ZoomLevel7</seven>
<eight>ZoomLevel8</eight>
<nine>ZoomLevel9</nine>
<info>CodecInfo</info>
<skipplus>NextPicture</skipplus>
<skipminus>PreviousPicture</skipminus>
<title>Info</title>
<select>Rotate</select>
<back>PreviousMenu</back>
</remote>
</SlideShow>
<ScreenCalibration>
<remote>
<select>NextCalibration</select>
<zero>ResetCalibration</zero>
<display>NextResolution</display>
<xbox>NextResolution</xbox>
</remote>
</ScreenCalibration>
<GUICalibration>
<remote>
<select>NextCalibration</select>
<zero>ResetCalibration</zero>
</remote>
</GUICalibration>
<SelectDialog>
<remote>
<back>Close</back>
</remote>
</SelectDialog>
<VideoOSD>
<remote>
<back>PreviousMenu</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</VideoOSD>
<VideoMenu>
<remote>
<menu>OSD</menu>
<back>PreviousMenu</back>
<info>Info</info>
<title>CodecInfo</title>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<play>Select</play>
</remote>
</VideoMenu>
<OSDVideoSettings>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</OSDVideoSettings>
<OSDAudioSettings>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
</remote>
</OSDAudioSettings>
<VideoBookmarks>
<remote>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
<zero>Delete</zero>
</remote>
</VideoBookmarks>
<MyVideoLibrary>
<remote>
<zero>Queue</zero>
<clear>Delete</clear>
</remote>
</MyVideoLibrary>
<MyVideoFiles>
<remote>
<zero>Queue</zero>
<star>Queue</star>
</remote>
</MyVideoFiles>
<MyVideoPlaylist>
<remote>
<back>Playlist</back> <!-- Close playlist -->
<clear>Delete</clear>
<zero>Delete</zero>
</remote>
</MyVideoPlaylist>
<VirtualKeyboard>
<remote>
<back>BackSpace</back>
<star>Shift</star>
<hash>Symbols</hash>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<enter>Enter</enter>
<pageminus>CursorLeft</pageminus>
<pageplus>CursorRight</pageplus>
</remote>
</VirtualKeyboard>
<ContextMenu>
<remote>
<title>Close</title>
<back>Close</back>
</remote>
</ContextMenu>
<FileStackingDialog>
<remote>
<back>Close</back>
</remote>
</FileStackingDialog>
<Scripts>
<remote>
<info>info</info>
</remote>
</Scripts>
<NumericInput>
<remote>
<zero>Number0</zero>
<one>Number1</one>
<two>Number2</two>
<three>Number3</three>
<four>Number4</four>
<five>Number5</five>
<six>Number6</six>
<seven>Number7</seven>
<eight>Number8</eight>
<nine>Number9</nine>
<enter>Enter</enter>
<back>BackSpace</back>
</remote>
</NumericInput>
<Weather>
<remote>
<back>PreviousMenu</back>
</remote>
</Weather>
<Settings>
<remote>
<back>PreviousMenu</back>
</remote>
</Settings>
<AddonBrowser>
<remote>
</remote>
</AddonBrowser>
<AddonInformation>
<remote>
<back>Close</back>
</remote>
</AddonInformation>
<AddonSettings>
<remote>
<back>Close</back>
</remote>
</AddonSettings>
<TextViewer>
<remote>
<back>Close</back>
</remote>
</TextViewer>
<MyPicturesSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyPicturesSettings>
<MyProgramsSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyProgramsSettings>
<MyWeatherSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyWeatherSettings>
<MyMusicSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyMusicSettings>
<SystemSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</SystemSettings>
<MyVideosSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</MyVideosSettings>
<NetworkSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</NetworkSettings>
<AppearanceSettings>
<remote>
<back>PreviousMenu</back>
</remote>
</AppearanceSettings>
<Profiles>
<remote>
<back>PreviousMenu</back>
</remote>
</Profiles>
<systeminfo>
<remote>
<back>PreviousMenu</back>
</remote>
</systeminfo>
<shutdownmenu>
<remote>
<back>PreviousMenu</back>
</remote>
</shutdownmenu>
<submenu>
<remote>
<back>PreviousMenu</back>
</remote>
</submenu>
<MusicInformation>
<remote>
<back>Close</back>
</remote>
</MusicInformation>
<MovieInformation>
<remote>
<info>Close</info>
<back>Close</back>
</remote>
</MovieInformation>
<LockSettings>
<remote>
<menu>Close</menu>
<back>PreviousMenu</back>
</remote>
</LockSettings>
<ProfileSettings>
<remote>
<menu>Close</menu>
<back>PreviousMenu</back>
</remote>
</ProfileSettings>
<PictureInfo>
<remote>
<skipplus>NextPicture</skipplus>
<skipminus>PreviousPicture</skipminus>
<info>Close</info>
<back>Close</back>
</remote>
</PictureInfo>
<Teletext>
<remote>
<zero>number0</zero>
<one>number1</one>
<two>number2</two>
<three>number3</three>
<four>number4</four>
<five>number5</five>
<six>number6</six>
<seven>number7</seven>
<eight>number8</eight>
<nine>number9</nine>
<info>Info</info>
<back>Close</back>
<menu>Close</menu>
<start>Close</start>
<teletext>Close</teletext>
</remote>
</Teletext>
<Favourites>
<remote>
<back>Close</back>
</remote>
</Favourites>
</keymap>
EOF
# Check to see if a file was created with the correct name
if [ -f /home/"$user"/.xbmc/userdata/keymaps/remote.xml ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
# This is a user file so we will change ownership back to the specified user because script is run as root
chown "$user":"$user" /home/"$user"/.xbmc/userdata/keymaps/remote.xml
# Backup if existing and create /etc/init.d/irexec
echo -e "\033[32m Backing up and creating /etc/init.d/irexec"
mv /etc/init.d/irexec /etc/init.d/irexec.bak > /dev/null 2>&1
cat << 'EOF' > /etc/init.d/irexec
#! /bin/sh
### BEGIN INIT INFO
# Provides: irexec
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts IREXEC daemon.
# Description: irexec executres programs when triggered
# by events in inputlircd (?)
### END INIT INFO
START_IREXEC=true
case "$1" in
start)
if [ "$START_IREXEC" = "true" ]; then
start-stop-daemon --start --quiet --exec /usr/bin/irexec -- -d /home/X123X/.lircrc < /dev/null
fi
;;
stop)
if [ "$START_IREXEC" = "true" ]; then
start-stop-daemon --stop --quiet --exec /usr/bin/irexec
fi
;;
reload|force-reload)
if [ "$START_IREXEC" = "true" ]; then
start-stop-daemon --stop --quiet --signal 1 --exec /usr/bin/irexec
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/irexec {start|stop|reload|restart|force-reload}"
exit 1
esac
exit 0
EOF
# Couldnt pass the $user variable correctly with cat EOF so we will inline edit it with sed
cat /etc/init.d/irexec | sed -e "s/X123X/$user/" >> /etc/init.d/irexec.tmp
mv /etc/init.d/irexec.tmp /etc/init.d/irexec
chmod +x /etc/init.d/irexec
chmod -x /etc/init.d/irexec.bak > /dev/null 2>&1
# Check to see if a file was created with the correct name
if [ -f /etc/init.d/irexec ]
then
echo -e "\033[0mFile Created and updating rc.d irexec defaults"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
update-rc.d irexec defaults > /dev/null 2>&1
# Backup if existing and create /home/"$user"/.lircrc
mv --backup=numbered /home/"$user"/.lircrc //home/"$user"/.lircrc.bak > /dev/null 2>&1
sleep 1
echo -e "\033[32m Creating /home/"$user"/.lircrc"
cat << 'EOF' > /home/"$user"/.lircrc
begin
remote = Microsoft_Xbox360
button = OpenClose
prog = irexec
repeat = 0
config = /home/X123X/restart-xbmc.sh
EOF
# Check to see if a file was created with the correct name
if [ -f /home/"$user"/.lircrc ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
# Couldnt pass the $user variable correctly with cat EOF so we will inline edit it with sed
cat /home/"$user"/.lircrc | sed -e "s/X123X/$user/" >> /home/"$user"/.lircrc.tmp
mv /home/"$user"/.lircrc.tmp /home/"$user"/.lircrc
# This is a user file so we will change ownership back to the specified user because script is run as root
chown "$user":"$user" /home/"$user"/.lircrc
# create /home/"$user"/restart-xbmc.sh"
sleep 1
echo -e "\033[32m Creating /home/"$user"/restart-xbmc.sh"
cat << 'EOF' > /home/"$user"/restart-xbmc.sh
#! /bin/bash
killall -9 xbmc.bin
# Living, He loved me, dying, He saved me
# Buried, He carried my sins far away
# Rising, He justified freely forever
# One day He's coming, oh, glorious day
EOF
# Check to see if a file was created with the correct name
if [ -f /home/"$user"/restart-xbmc.sh ]
then
echo -e "\033[0mFile Created"
else
echo -e "\e[1;31;40mError Creating File.....Something went wrong"
exit
fi
chmod +x /home/"$user"/restart-xbmc.sh
# This is a user file so we will change ownership back to the specified user because script is run as root
chown "$user":"$user" /home/"$user"/restart-xbmc.sh
rm /tmp/banner > /dev/null 2>&1
echo ""
echo ""
echo -e "\e[0;32;40mDone......Your X-BOX 360 universal remote should now work with XBMC :)""\033[0m"
echo ""
echo ""
echo -e "\e[1;31;40mReboot required for changes to take effect"
echo -e "\033[0m"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment