Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script To Configure XBOX 360 Universal Remote Control For kodi
- # 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 ./KODI-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 KODI?"
- 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 2654 886
- one 432 458
- zero 432 458
- pre_data_bits 24
- pre_data 0x1BFF80
- gap 106453
- min_repeat 1
- # suppress_repeat 1
- # uncomment to suppress unwanted repeats
- toggle_bit_mask 0x8000
- rc6_mask 0x100000000
- begin codes
- KEY_DISPLAYTOGGLE 0x0BB0
- KEY_BACK 0x0BDC
- KEY_TITLE 0x0BAE
- KEY_INFO 0x0BF0
- KEY_MENU 0x0BDB
- KEY_PLAY 0x0BE9
- KEY_OPEN 0x0BD7
- KEY_STOP 0x0BE6
- KEY_PAUSE 0x0BE7
- KEY_FASTFORWARD 0x0BEB
- KEY_REWIND 0x0BEA
- KEY_POWER 0x0BF3
- KEY_PAGEUP 0x0BED
- KEY_PAGEDOWN 0x0BEC
- KEY_Y 0x0BD9
- KEY_B 0x0BDA
- KEY_FRAMEFORWARD 0x0BE5
- KEY_FRAMEBACK 0x0BE4
- KEY_OPTION 0x0B9B
- KEY_OK 0x0BDD
- KEY_LEFT 0x0BDF
- KEY_RIGHT 0x0BDE
- KEY_DOWN 0x0BE0
- KEY_UP 0x0BE1
- KEY_RECORD 0x0BE8
- KEY_HP 0x0BF2
- 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"/.kodi/userdata/Lircmap.xml
- sleep 1
- echo -e "\033[32m Backing up and creating /home/"$user"/.kodi/userdata/Lircmap.xml"
- mv --backup=numbered /home/"$user"/.kodi/userdata/Lircmap.xml /home/"$user"/.kodi/userdata/Lircmap.xml.bak > /dev/null 2>&1
- cat << 'EOF' > /home/"$user"/.kodi/userdata/Lircmap.xml
- <!-- This file contains the mapping of LIRC keys to KODI 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 -->
- <!-- <KODI_COMMAND>LircButtonName</KODI_COMMAND> -->
- <!-- -->
- <!-- For a list of KODI_COMMAND's check out the <remote> sections of keymap.xml -->
- <lircmap>
- <remote device=Microsoft_Xbox360>
- <left>KEY_LEFT</left>
- <right>KEY_RIGHT</right>
- <up>KEY_UP</up>
- <down>KEY_DOWN</down>
- <select>KEY_OK</select>
- <back>KEY_BACK</back>
- <forward>KEY_FASTFORWARD</forward>
- <reverse>KEY_REWIND</reverse>
- <play>KEY_PLAY</play>
- <pause>KEY_PAUSE</pause>
- <stop>KEY_STOP</stop>
- <mute>KEY_OPEN</mute>
- <pageminus>KEY_PAGEDOWN</pageminus>
- <pageplus>KEY_PAGEUP</pageplus>
- <power>KEY_POWER</power>
- <skipplus>KEY_FRAMEFORWARD</skipplus>
- <skipminus>KEY_FRAMEBACK</skipminus>
- <display>KEY_DISPLAYTOGGLE</display>
- <record>KEY_RECORD</record>
- <start>KEY_HP</start>
- <info>KEY_INFO</info>
- <menu>KEY_MENU</menu>
- <title>KEY_TITLE</title>
- <xbox>KEY_OPTION</xbox>
- <guide>KEY_Y</guide>
- <mytv>KEY_B</mytv>
- </remote>
- </lircmap>
- EOF
- # Check to see if a file was created with the correct name
- if [ -f /home/"$user"/.kodi/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"/.kodi/userdata/Lircmap.xml
- # Backup if existing and create /home/"$user"/.kodi/userdata/keymaps/remote.xml
- sleep 1
- echo -e "\033[32m Backing up and creating /home/"$user"/.kodi/userdata/keymaps/remote.xml"
- mv --backup=numbered /home/"$user"/.kodi/userdata/keymaps/remote.xml /home/"$user"/.kodi/userdata/keymaps/remote.xml.bak > /dev/null 2>&1
- cat << 'EOF' > /home/"$user"/.kodi/userdata/keymaps/remote.xml
- <!-- This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within KODI -->
- <!-- 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>KODI.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 KODI 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 KODI.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>
- <pageplus>PageUp</pageplus>
- <pageminus>PageDown</pageminus>
- <back>ParentDir</back>
- <menu>ContextMenu</menu>
- <title>ShowSubtitles</title>
- <info>Info</info>
- <skipplus>SkipNext</skipplus>
- <skipminus>SkipPrevious</skipminus>
- <display>FullScreen</display>
- <start>ActivateWindow(Home)</start>
- <record>Screenshot</record>
- <volumeplus>VolumeUp</volumeplus>
- <volumeminus>VolumeDown</volumeminus>
- <mute>Mute</mute>
- <power>ShutDown()</power>
- <mytv>ActivateWindow(VideoLibrary,TvShowTitles)</mytv>
- <xbox>ContextMenu</xbox>
- </remote>
- </global>
- <Home>
- <remote>
- <info>ActivateWindow(SystemInfo)</info>
- </remote>
- </Home>
- <MyFiles>
- <remote>
- </remote>
- </MyFiles>
- <MyMusicPlaylist>
- <remote>
- </remote>
- </MyMusicPlaylist>
- <MyMusicPlaylistEditor>
- <remote>
- </remote>
- </MyMusicPlaylistEditor>
- <MyMusicFiles>
- <remote>
- </remote>
- </MyMusicFiles>
- <MyMusicLibrary>
- <remote>
- </remote>
- </MyMusicLibrary>
- <FullscreenVideo>
- <remote>
- <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>ShowSubtitles</title>
- <info>CodecInfo</info>
- <display>AspectRatio</display>
- </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>ActivateWindow(VisualisationPresetList)</select>
- <menu>ActivateWindow(MusicOSD)</menu>
- <start>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>
- <right>NextPicture</right>
- <left>PreviousPicture</left>
- <skipplus>NextPicture</skipplus>
- <skipminus>PreviousPicture</skipminus>
- <title>Info</title>
- <display>Rotate</display>
- <back>PreviousMenu</back>
- <select>Pause</select>
- <pageplus>ZoomIn</back>
- <pageminus>ZoomOut</pageminus>
- </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"/.kodi/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"/.kodi/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-kodi.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-kodi.sh"
- sleep 1
- echo -e "\033[32m Creating /home/"$user"/restart-kodi.sh"
- cat << 'EOF' > /home/"$user"/restart-kodi.sh
- #! /bin/bash
- killall -9 kodi.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-kodi.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-kodi.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-kodi.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 kodi :)""\033[0m"
- echo ""
- echo ""
- echo -e "\e[1;31;40mReboot required for changes to take effect"
- echo -e "\033[0m"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement