Advertisement
Guest User

mediaremote.sh

a guest
Apr 30th, 2015
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script To Configure XBOX 360 Universal Remote Control For kodi
  4.  
  5.  
  6. # Make sure only root can run this script
  7. if [[ $EUID -ne 0 ]]; then
  8. 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
  9. echo -e "\033[0m"
  10. exit 1
  11.  
  12. else
  13. echo -e "\033[32m"
  14.  
  15. # Create Banner
  16.  
  17. cat << 'EOF' > /tmp/banner
  18. __ __ ____ _____ __ _____ __ ___
  19. \ \/ / | __ ) / _ \ \/ / |___ / / /_ / _ \
  20. \ / | _ \| | | \ / |_ \| '_ \| | | |
  21. / \ | |_) | |_| / \ ___) | (_) | |_| |
  22. /_/\_\ |____/ \___/_/\_\ |____/ \___/ \___/
  23. _ _ _ _
  24. | | | |_ __ (_)_ _____ _ __ ___ __ _| |
  25. | | | | '_ \| \ \ / / _ \ '__/ __|/ _` | |
  26. | |_| | | | | |\ V / __/ | \__ \ (_| | |
  27. \___/|_| |_|_| \_/ \___|_| |___/\__,_|_|
  28. ____ _
  29. | _ \ ___ _ __ ___ ___ | |_ ___
  30. | |_) / _ \ '_ ` _ \ / _ \| __/ _ \
  31. | _ < __/ | | | | | (_) | || __/
  32. |_| \_\___|_| |_| |_|\___/ \__\___|
  33. EOF
  34.  
  35. # Display Banner
  36.  
  37. cat /tmp/banner
  38. echo ""
  39. echo ""
  40.  
  41. # Check to make sure Lirc is installed..if not, ask user if they want to install.
  42.  
  43. if [ -d /etc/lirc/ ]
  44. then
  45. echo -e "\033[0mChecking if Lirc is installed"
  46. sleep 1
  47. echo -e "\033[0mLirc is installed"
  48. else
  49. echo -e "\e[1;31;40mLirc is not installed but required"
  50. echo -e "\033[0mWould you like to install it? y/n"
  51.  
  52. read answer
  53. case "$answer" in
  54. y|Y) apt-get install lirc;;
  55. n|N) exit;;
  56. *) echo "y or n";;
  57. esac
  58. fi
  59. if [ $? -ne 0 ]
  60. then
  61. exit
  62. fi
  63.  
  64.  
  65. # Loop until a valid user is input
  66.  
  67. homedir=1
  68. while [ "$homedir" = 1 ]
  69. do
  70. echo ""
  71. echo ""
  72. echo -e "\033[32m What is the username that will run KODI?"
  73. read user
  74.  
  75.  
  76. if [ -d /home/"$user"/ ]
  77. then
  78. homedir=0
  79. else
  80. echo -e "\e[1;31;40mThe username does not exist.....Here is a list of users"
  81. echo -e "\033[0m"
  82. ls /home
  83. homedir=1
  84. fi
  85. done
  86.  
  87. echo -e "\033[0m"
  88.  
  89. # got the required info, clear screen and display banner again
  90.  
  91. clear
  92. cat /tmp/banner
  93. echo ""
  94. echo ""
  95. sleep 1
  96.  
  97. # Backup if existing and create /etc/lirc/hardware.conf
  98.  
  99. echo -e "\033[32m Backing up and creating /etc/lirc/hardware.conf"
  100.  
  101. mv --backup=numbered /etc/lirc/hardware.conf /etc/lirc/hardware.conf.bak > /dev/null 2>&1
  102. cat << 'EOF' > /etc/lirc/hardware.conf
  103.  
  104. # /etc/lirc/hardware.conf
  105. #
  106. #Chosen Remote Control
  107. REMOTE=Microsoft_Xbox360
  108. REMOTE_MODULES=
  109. REMOTE_DRIVER=
  110. REMOTE_DEVICE=/dev/lirc0
  111. REMOTE_LIRCD_CONF=
  112. REMOTE_LIRCD_ARGS=--release
  113.  
  114. #Chosen IR Transmitter
  115. TRANSMITTER=None
  116. TRANSMITTER_MODULES=
  117. TRANSMITTER_DRIVER=
  118. TRANSMITTER_DEVICE=
  119. TRANSMITTER_LIRCD_CONF=
  120. TRANSMITTER_LIRCD_ARGS=
  121.  
  122. #Enable lircd
  123. START_LIRCD=true
  124.  
  125. #Don't start lircmd even if there seems to be a good config file
  126. #START_LIRCMD=false
  127.  
  128. #Try to load appropriate kernel modules
  129. LOAD_MODULES=true
  130.  
  131. # Default configuration files for your hardware if any
  132. LIRCMD_CONF=
  133.  
  134. #Forcing noninteractive reconfiguration
  135. #If lirc is to be reconfigured by an external application
  136. #that doesn't have a debconf frontend available, the noninteractive
  137. #frontend can be invoked and set to parse REMOTE and TRANSMITTER
  138. #It will then populate all other variables without any user input
  139. #If you would like to configure lirc via standard methods, be sure
  140. #to leave this set to false
  141. FORCE_NONINTERACTIVE_RECONFIGURATION=false
  142. START_LIRCMD=
  143.  
  144. EOF
  145.  
  146. # Check to see if a file was created with the correct name
  147.  
  148. if [ -f /etc/lirc/hardware.conf ]
  149. then
  150. echo -e "\033[0mFile Created"
  151. else
  152. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  153. exit
  154. fi
  155.  
  156. # Backup if existing and create /etc/lirc/lircd.conf
  157.  
  158. sleep 1
  159. echo -e "\033[32m Backing up and creating /etc/lirc/lircd.conf"
  160.  
  161. mv --backup=numbered /etc/lirc/lircd.conf /etc/lirc/lircd.conf.bak > /dev/null 2>&1
  162. cat << 'EOF' > /etc/lirc/lircd.conf
  163.  
  164. # this config file was automatically generated
  165. # using lirc-0.8.0-CVS(mceusb2) on Tue Jan 17 15:14:11 2006
  166. #
  167. #
  168. # brand: Microsoft
  169. # model no. of remote control: Xbox 360 Universal Media Remote
  170. # devices being controlled by this remote: Xbox 360
  171. #
  172. # This probably works for the normal Xbox 360 remote too.
  173. #
  174. # Living, He loved me, dying, He saved me
  175. # Buried, He carried my sins far away
  176. # Rising, He justified freely forever
  177. # One day He's coming, oh, glorious day
  178. #
  179. # TV button sends no signal and toggles Xbox 360/TV mode. TV mode can be
  180. # signals for any device the remote supports. Volume Up, Volume Down and
  181. # Mute always use the TV mode while the Xbox live guide button always sends
  182. # to the xbox.
  183.  
  184. begin remote
  185.  
  186. name Microsoft_Xbox360
  187. bits 13
  188. flags RC6|CONST_LENGTH
  189. eps 30
  190. aeps 100
  191.  
  192. header 2654 886
  193. one 432 458
  194. zero 432 458
  195. pre_data_bits 24
  196. pre_data 0x1BFF80
  197. gap 106453
  198. min_repeat 1
  199. # suppress_repeat 1
  200. # uncomment to suppress unwanted repeats
  201. toggle_bit_mask 0x8000
  202. rc6_mask 0x100000000
  203.  
  204. begin codes
  205. KEY_DISPLAYTOGGLE 0x0BB0
  206. KEY_BACK 0x0BDC
  207. KEY_TITLE 0x0BAE
  208. KEY_INFO 0x0BF0
  209. KEY_MENU 0x0BDB
  210. KEY_PLAY 0x0BE9
  211. KEY_OPEN 0x0BD7
  212. KEY_STOP 0x0BE6
  213. KEY_PAUSE 0x0BE7
  214. KEY_FASTFORWARD 0x0BEB
  215. KEY_REWIND 0x0BEA
  216. KEY_POWER 0x0BF3
  217. KEY_PAGEUP 0x0BED
  218. KEY_PAGEDOWN 0x0BEC
  219. KEY_Y 0x0BD9
  220. KEY_B 0x0BDA
  221. KEY_FRAMEFORWARD 0x0BE5
  222. KEY_FRAMEBACK 0x0BE4
  223. KEY_OPTION 0x0B9B
  224. KEY_OK 0x0BDD
  225. KEY_LEFT 0x0BDF
  226. KEY_RIGHT 0x0BDE
  227. KEY_DOWN 0x0BE0
  228. KEY_UP 0x0BE1
  229. KEY_RECORD 0x0BE8
  230. KEY_HP 0x0BF2
  231. end codes
  232.  
  233. end remote
  234.  
  235. EOF
  236.  
  237. # Check to see if a file was created with the correct name
  238.  
  239. if [ -f /etc/lirc/lircd.conf ]
  240. then
  241. echo -e "\033[0mFile Created"
  242. else
  243. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  244. exit
  245. fi
  246.  
  247. # Backup if existing and create /home/"$user"/.kodi/userdata/Lircmap.xml
  248.  
  249. sleep 1
  250. echo -e "\033[32m Backing up and creating /home/"$user"/.kodi/userdata/Lircmap.xml"
  251.  
  252. mv --backup=numbered /home/"$user"/.kodi/userdata/Lircmap.xml /home/"$user"/.kodi/userdata/Lircmap.xml.bak > /dev/null 2>&1
  253. cat << 'EOF' > /home/"$user"/.kodi/userdata/Lircmap.xml
  254.  
  255.  
  256.  
  257. <!-- This file contains the mapping of LIRC keys to KODI keys used in Keymap.xml -->
  258. <!-- -->
  259. <!-- How to add remotes -->
  260. <!-- <remote device=name_Lirc_calls_the_remote> -->
  261. <!-- -->
  262. <!-- For the commands the layout following layout is used -->
  263. <!-- <KODI_COMMAND>LircButtonName</KODI_COMMAND> -->
  264. <!-- -->
  265. <!-- For a list of KODI_COMMAND's check out the <remote> sections of keymap.xml -->
  266.  
  267. <lircmap>
  268. <remote device=Microsoft_Xbox360>
  269. <left>KEY_LEFT</left>
  270. <right>KEY_RIGHT</right>
  271. <up>KEY_UP</up>
  272. <down>KEY_DOWN</down>
  273. <select>KEY_OK</select>
  274. <back>KEY_BACK</back>
  275. <forward>KEY_FASTFORWARD</forward>
  276. <reverse>KEY_REWIND</reverse>
  277. <play>KEY_PLAY</play>
  278. <pause>KEY_PAUSE</pause>
  279. <stop>KEY_STOP</stop>
  280. <mute>KEY_OPEN</mute>
  281. <pageminus>KEY_PAGEDOWN</pageminus>
  282. <pageplus>KEY_PAGEUP</pageplus>
  283. <power>KEY_POWER</power>
  284. <skipplus>KEY_FRAMEFORWARD</skipplus>
  285. <skipminus>KEY_FRAMEBACK</skipminus>
  286. <display>KEY_DISPLAYTOGGLE</display>
  287. <record>KEY_RECORD</record>
  288. <start>KEY_HP</start>
  289. <info>KEY_INFO</info>
  290. <menu>KEY_MENU</menu>
  291. <title>KEY_TITLE</title>
  292. <xbox>KEY_OPTION</xbox>
  293. <guide>KEY_Y</guide>
  294. <mytv>KEY_B</mytv>
  295. </remote>
  296. </lircmap>
  297. EOF
  298.  
  299. # Check to see if a file was created with the correct name
  300.  
  301. if [ -f /home/"$user"/.kodi/userdata/Lircmap.xml ]
  302. then
  303. echo -e "\033[0mFile Created"
  304. else
  305. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  306. exit
  307. fi
  308.  
  309. # This is a user file so we will change ownership back to the specified user because script is run as root
  310.  
  311. chown "$user":"$user" /home/"$user"/.kodi/userdata/Lircmap.xml
  312.  
  313. # Backup if existing and create /home/"$user"/.kodi/userdata/keymaps/remote.xml
  314.  
  315. sleep 1
  316. echo -e "\033[32m Backing up and creating /home/"$user"/.kodi/userdata/keymaps/remote.xml"
  317.  
  318. mv --backup=numbered /home/"$user"/.kodi/userdata/keymaps/remote.xml /home/"$user"/.kodi/userdata/keymaps/remote.xml.bak > /dev/null 2>&1
  319. cat << 'EOF' > /home/"$user"/.kodi/userdata/keymaps/remote.xml
  320.  
  321. <!-- This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within KODI -->
  322. <!-- The <global> section is a fall through - they will only be used if the button is not -->
  323. <!-- used in the current window's section. Note that there is only handling -->
  324. <!-- for a single action per button at this stage. -->
  325. <!-- For joystick/gamepad configuration under linux/win32, see below as it differs from xbox -->
  326. <!-- gamepads. -->
  327.  
  328. <!-- The format is: -->
  329. <!-- <device> -->
  330. <!-- <button>action</button> -->
  331. <!-- </device> -->
  332.  
  333. <!-- To map keys from other remotes using the RCA protocol, you may add <universalremote> blocks -->
  334. <!-- In this case, the tags used are <obc#> where # is the original button code (OBC) of the key -->
  335. <!-- You set it up by adding a <universalremote> block to the window or <global> section: -->
  336. <!-- <universalremote> -->
  337. <!-- <obc45>Stop</obc45> -->
  338. <!-- </universalremote> -->
  339.  
  340. <!-- Note that the action can be a built-in function. -->
  341. <!-- eg <B>KODI.ActivateWindow(MyMusic)</B> -->
  342. <!-- would automatically go to My Music on the press of the B button. -->
  343.  
  344. <!-- Joysticks / Gamepads: -->
  345. <!-- See the sample PS3 controller configuration below for the format. -->
  346. <!-- -->
  347. <!-- Joystick Name: -->
  348. <!-- Do 'cat /proc/bus/input/devices' or see your KODI log file to find the names of -->
  349. <!-- detected joysticks. The name used in the configuration should match the detected name. -->
  350. <!-- -->
  351. <!-- Button Ids: -->
  352. <!-- 'id' is the button ID used by SDL. Joystick button ids of connected joysticks appear -->
  353. <!-- in KODI.log when they are pressed. Use your log to map custom buttons to actions. -->
  354. <!-- -->
  355. <!-- Axis Ids / Analog Controls -->
  356. <!-- Coming soon. -->
  357. <keymap>
  358. <global>
  359. <remote>
  360. <play>Play</play>
  361. <pause>Pause</pause>
  362. <stop>Stop</stop>
  363. <forward>FastForward</forward>
  364. <reverse>Rewind</reverse>
  365. <left>Left</left>
  366. <right>Right</right>
  367. <up>Up</up>
  368. <down>Down</down>
  369. <select>Select</select>
  370. <pageplus>PageUp</pageplus>
  371. <pageminus>PageDown</pageminus>
  372. <back>ParentDir</back>
  373. <menu>ContextMenu</menu>
  374. <title>ShowSubtitles</title>
  375. <info>Info</info>
  376. <skipplus>SkipNext</skipplus>
  377. <skipminus>SkipPrevious</skipminus>
  378. <display>FullScreen</display>
  379. <start>ActivateWindow(Home)</start>
  380. <record>Screenshot</record>
  381. <volumeplus>VolumeUp</volumeplus>
  382. <volumeminus>VolumeDown</volumeminus>
  383. <mute>Mute</mute>
  384. <power>ShutDown()</power>
  385. <mytv>ActivateWindow(VideoLibrary,TvShowTitles)</mytv>
  386. <xbox>ContextMenu</xbox>
  387. </remote>
  388. </global>
  389. <Home>
  390. <remote>
  391. <info>ActivateWindow(SystemInfo)</info>
  392. </remote>
  393. </Home>
  394. <MyFiles>
  395. <remote>
  396. </remote>
  397. </MyFiles>
  398. <MyMusicPlaylist>
  399. <remote>
  400. </remote>
  401. </MyMusicPlaylist>
  402. <MyMusicPlaylistEditor>
  403. <remote>
  404. </remote>
  405. </MyMusicPlaylistEditor>
  406. <MyMusicFiles>
  407. <remote>
  408. </remote>
  409. </MyMusicFiles>
  410. <MyMusicLibrary>
  411. <remote>
  412. </remote>
  413. </MyMusicLibrary>
  414. <FullscreenVideo>
  415. <remote>
  416. <left>StepBack</left>
  417. <right>StepForward</right>
  418. <up>BigStepForward</up>
  419. <down>BigStepBack</down>
  420. <back>SmallStepBack</back>
  421. <menu>OSD</menu>
  422. <start>TakeScreenshot</start>
  423. <select>AspectRatio</select>
  424. <title>ShowSubtitles</title>
  425. <info>CodecInfo</info>
  426. <display>AspectRatio</display>
  427. </remote>
  428. </FullscreenVideo>
  429. <VideoTimeSeek>
  430. <remote>
  431. <select>Select</select>
  432. <enter>Select</enter>
  433. </remote>
  434. </VideoTimeSeek>
  435. <FullscreenInfo>
  436. <remote>
  437. <title>CodecInfo</title>
  438. <info>Close</info>
  439. <menu>OSD</menu>
  440. </remote>
  441. </FullscreenInfo>
  442. <PlayerControls>
  443. <remote>
  444. <menu>Close</menu>
  445. </remote>
  446. </PlayerControls>
  447. <Visualisation>
  448. <remote>
  449. <left>PreviousPreset</left>
  450. <right>NextPreset</right>
  451. <up>IncreaseRating</up>
  452. <down>DecreaseRating</down>
  453. <back>LockPreset</back>
  454. <title>CodecInfo</title>
  455. <select>ActivateWindow(VisualisationPresetList)</select>
  456. <menu>ActivateWindow(MusicOSD)</menu>
  457. <start>ActivateWindow(MusicOSD)</start>
  458. <info>Info</info>
  459. </remote>
  460. </Visualisation>
  461. <MusicOSD>
  462. <remote>
  463. <menu>Close</menu>
  464. <title>Info</title>
  465. <info>CodecInfo</info>
  466. </remote>
  467. </MusicOSD>
  468. <VisualisationSettings>
  469. <remote>
  470. <menu>Close</menu>
  471. <back>Close</back>
  472. </remote>
  473. </VisualisationSettings>
  474. <VisualisationPresetList>
  475. <remote>
  476. <menu>Close</menu>
  477. <back>Close</back>
  478. </remote>
  479. </VisualisationPresetList>
  480. <SlideShow>
  481. <remote>
  482. <right>NextPicture</right>
  483. <left>PreviousPicture</left>
  484. <skipplus>NextPicture</skipplus>
  485. <skipminus>PreviousPicture</skipminus>
  486. <title>Info</title>
  487. <display>Rotate</display>
  488. <back>PreviousMenu</back>
  489. <select>Pause</select>
  490. <pageplus>ZoomIn</back>
  491. <pageminus>ZoomOut</pageminus>
  492. </remote>
  493. </SlideShow>
  494. <ScreenCalibration>
  495. <remote>
  496. <select>NextCalibration</select>
  497. <zero>ResetCalibration</zero>
  498. <display>NextResolution</display>
  499. <xbox>NextResolution</xbox>
  500. </remote>
  501. </ScreenCalibration>
  502. <GUICalibration>
  503. <remote>
  504. <select>NextCalibration</select>
  505. <zero>ResetCalibration</zero>
  506. </remote>
  507. </GUICalibration>
  508. <SelectDialog>
  509. <remote>
  510. <back>Close</back>
  511. </remote>
  512. </SelectDialog>
  513. <VideoOSD>
  514. <remote>
  515. <back>PreviousMenu</back>
  516. <menu>Close</menu>
  517. <start>Close</start>
  518. </remote>
  519. </VideoOSD>
  520. <VideoMenu>
  521. <remote>
  522. <menu>OSD</menu>
  523. <back>PreviousMenu</back>
  524. <info>Info</info>
  525. <title>CodecInfo</title>
  526. <zero>Number0</zero>
  527. <one>Number1</one>
  528. <two>Number2</two>
  529. <three>Number3</three>
  530. <four>Number4</four>
  531. <five>Number5</five>
  532. <six>Number6</six>
  533. <seven>Number7</seven>
  534. <eight>Number8</eight>
  535. <nine>Number9</nine>
  536. <play>Select</play>
  537. </remote>
  538. </VideoMenu>
  539. <OSDVideoSettings>
  540. <remote>
  541. <back>Close</back>
  542. <menu>Close</menu>
  543. <start>Close</start>
  544. </remote>
  545. </OSDVideoSettings>
  546. <OSDAudioSettings>
  547. <remote>
  548. <back>Close</back>
  549. <menu>Close</menu>
  550. <start>Close</start>
  551. </remote>
  552. </OSDAudioSettings>
  553. <VideoBookmarks>
  554. <remote>
  555. <back>Close</back>
  556. <menu>Close</menu>
  557. <start>Close</start>
  558. <zero>Delete</zero>
  559. </remote>
  560. </VideoBookmarks>
  561. <MyVideoLibrary>
  562. <remote>
  563. <zero>Queue</zero>
  564. <clear>Delete</clear>
  565. </remote>
  566. </MyVideoLibrary>
  567. <MyVideoFiles>
  568. <remote>
  569. <zero>Queue</zero>
  570. <star>Queue</star>
  571. </remote>
  572. </MyVideoFiles>
  573. <MyVideoPlaylist>
  574. <remote>
  575. <back>Playlist</back> <!-- Close playlist -->
  576. <clear>Delete</clear>
  577. <zero>Delete</zero>
  578. </remote>
  579. </MyVideoPlaylist>
  580. <VirtualKeyboard>
  581. <remote>
  582. <back>BackSpace</back>
  583. <star>Shift</star>
  584. <hash>Symbols</hash>
  585. <zero>Number0</zero>
  586. <one>Number1</one>
  587. <two>Number2</two>
  588. <three>Number3</three>
  589. <four>Number4</four>
  590. <five>Number5</five>
  591. <six>Number6</six>
  592. <seven>Number7</seven>
  593. <eight>Number8</eight>
  594. <nine>Number9</nine>
  595. <enter>Enter</enter>
  596. <pageminus>CursorLeft</pageminus>
  597. <pageplus>CursorRight</pageplus>
  598. </remote>
  599. </VirtualKeyboard>
  600. <ContextMenu>
  601. <remote>
  602. <title>Close</title>
  603. <back>Close</back>
  604. </remote>
  605. </ContextMenu>
  606. <FileStackingDialog>
  607. <remote>
  608. <back>Close</back>
  609. </remote>
  610. </FileStackingDialog>
  611. <Scripts>
  612. <remote>
  613. <info>info</info>
  614. </remote>
  615. </Scripts>
  616. <NumericInput>
  617. <remote>
  618. <zero>Number0</zero>
  619. <one>Number1</one>
  620. <two>Number2</two>
  621. <three>Number3</three>
  622. <four>Number4</four>
  623. <five>Number5</five>
  624. <six>Number6</six>
  625. <seven>Number7</seven>
  626. <eight>Number8</eight>
  627. <nine>Number9</nine>
  628. <enter>Enter</enter>
  629. <back>BackSpace</back>
  630. </remote>
  631. </NumericInput>
  632. <Weather>
  633. <remote>
  634. <back>PreviousMenu</back>
  635. </remote>
  636. </Weather>
  637. <Settings>
  638. <remote>
  639. <back>PreviousMenu</back>
  640. </remote>
  641. </Settings>
  642. <AddonBrowser>
  643. <remote>
  644. </remote>
  645. </AddonBrowser>
  646. <AddonInformation>
  647. <remote>
  648. <back>Close</back>
  649. </remote>
  650. </AddonInformation>
  651. <AddonSettings>
  652. <remote>
  653. <back>Close</back>
  654. </remote>
  655. </AddonSettings>
  656. <TextViewer>
  657. <remote>
  658. <back>Close</back>
  659. </remote>
  660. </TextViewer>
  661. <MyPicturesSettings>
  662. <remote>
  663. <back>PreviousMenu</back>
  664. </remote>
  665. </MyPicturesSettings>
  666. <MyProgramsSettings>
  667. <remote>
  668. <back>PreviousMenu</back>
  669. </remote>
  670. </MyProgramsSettings>
  671. <MyWeatherSettings>
  672. <remote>
  673. <back>PreviousMenu</back>
  674. </remote>
  675. </MyWeatherSettings>
  676. <MyMusicSettings>
  677. <remote>
  678. <back>PreviousMenu</back>
  679. </remote>
  680. </MyMusicSettings>
  681. <SystemSettings>
  682. <remote>
  683. <back>PreviousMenu</back>
  684. </remote>
  685. </SystemSettings>
  686. <MyVideosSettings>
  687. <remote>
  688. <back>PreviousMenu</back>
  689. </remote>
  690. </MyVideosSettings>
  691. <NetworkSettings>
  692. <remote>
  693. <back>PreviousMenu</back>
  694. </remote>
  695. </NetworkSettings>
  696. <AppearanceSettings>
  697. <remote>
  698. <back>PreviousMenu</back>
  699. </remote>
  700. </AppearanceSettings>
  701. <Profiles>
  702. <remote>
  703. <back>PreviousMenu</back>
  704. </remote>
  705. </Profiles>
  706. <systeminfo>
  707. <remote>
  708. <back>PreviousMenu</back>
  709. </remote>
  710. </systeminfo>
  711. <shutdownmenu>
  712. <remote>
  713. <back>PreviousMenu</back>
  714. </remote>
  715. </shutdownmenu>
  716. <submenu>
  717. <remote>
  718. <back>PreviousMenu</back>
  719. </remote>
  720. </submenu>
  721. <MusicInformation>
  722. <remote>
  723. <back>Close</back>
  724. </remote>
  725. </MusicInformation>
  726. <MovieInformation>
  727. <remote>
  728. <info>Close</info>
  729. <back>Close</back>
  730. </remote>
  731. </MovieInformation>
  732. <LockSettings>
  733. <remote>
  734. <menu>Close</menu>
  735. <back>PreviousMenu</back>
  736. </remote>
  737. </LockSettings>
  738. <ProfileSettings>
  739. <remote>
  740. <menu>Close</menu>
  741. <back>PreviousMenu</back>
  742. </remote>
  743. </ProfileSettings>
  744. <PictureInfo>
  745. <remote>
  746. <skipplus>NextPicture</skipplus>
  747. <skipminus>PreviousPicture</skipminus>
  748. <info>Close</info>
  749. <back>Close</back>
  750. </remote>
  751. </PictureInfo>
  752. <Teletext>
  753. <remote>
  754. <zero>number0</zero>
  755. <one>number1</one>
  756. <two>number2</two>
  757. <three>number3</three>
  758. <four>number4</four>
  759. <five>number5</five>
  760. <six>number6</six>
  761. <seven>number7</seven>
  762. <eight>number8</eight>
  763. <nine>number9</nine>
  764. <info>Info</info>
  765. <back>Close</back>
  766. <menu>Close</menu>
  767. <start>Close</start>
  768. <teletext>Close</teletext>
  769. </remote>
  770. </Teletext>
  771. <Favourites>
  772. <remote>
  773. <back>Close</back>
  774. </remote>
  775. </Favourites>
  776. </keymap>
  777. EOF
  778.  
  779. # Check to see if a file was created with the correct name
  780.  
  781. if [ -f /home/"$user"/.kodi/userdata/keymaps/remote.xml ]
  782. then
  783. echo -e "\033[0mFile Created"
  784. else
  785. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  786. exit
  787. fi
  788.  
  789. # This is a user file so we will change ownership back to the specified user because script is run as root
  790.  
  791. chown "$user":"$user" /home/"$user"/.kodi/userdata/keymaps/remote.xml
  792.  
  793. # Backup if existing and create /etc/init.d/irexec
  794.  
  795. echo -e "\033[32m Backing up and creating /etc/init.d/irexec"
  796.  
  797. mv /etc/init.d/irexec /etc/init.d/irexec.bak > /dev/null 2>&1
  798. cat << 'EOF' > /etc/init.d/irexec
  799. #! /bin/sh
  800.  
  801. ### BEGIN INIT INFO
  802. # Provides: irexec
  803. # Required-Start: $remote_fs $syslog
  804. # Required-Stop: $remote_fs $syslog
  805. # Default-Start: 2 3 4 5
  806. # Default-Stop: 0 1 6
  807. # Short-Description: Starts IREXEC daemon.
  808. # Description: irexec executres programs when triggered
  809. # by events in inputlircd (?)
  810. ### END INIT INFO
  811.  
  812.  
  813.  
  814. START_IREXEC=true
  815.  
  816. case "$1" in
  817. start)
  818. if [ "$START_IREXEC" = "true" ]; then
  819. start-stop-daemon --start --quiet --exec /usr/bin/irexec -- -d /home/X123X/.lircrc < /dev/null
  820.  
  821. fi
  822. ;;
  823. stop)
  824. if [ "$START_IREXEC" = "true" ]; then
  825. start-stop-daemon --stop --quiet --exec /usr/bin/irexec
  826.  
  827. fi
  828. ;;
  829. reload|force-reload)
  830. if [ "$START_IREXEC" = "true" ]; then
  831. start-stop-daemon --stop --quiet --signal 1 --exec /usr/bin/irexec
  832. fi
  833. ;;
  834. restart)
  835. $0 stop
  836. sleep 1
  837. $0 start
  838. ;;
  839. *)
  840. echo "Usage: /etc/init.d/irexec {start|stop|reload|restart|force-reload}"
  841. exit 1
  842. esac
  843.  
  844. exit 0
  845. EOF
  846.  
  847. # Couldnt pass the $user variable correctly with cat EOF so we will inline edit it with sed
  848.  
  849. cat /etc/init.d/irexec | sed -e "s/X123X/$user/" >> /etc/init.d/irexec.tmp
  850. mv /etc/init.d/irexec.tmp /etc/init.d/irexec
  851. chmod +x /etc/init.d/irexec
  852. chmod -x /etc/init.d/irexec.bak > /dev/null 2>&1
  853.  
  854. # Check to see if a file was created with the correct name
  855.  
  856. if [ -f /etc/init.d/irexec ]
  857. then
  858. echo -e "\033[0mFile Created and updating rc.d irexec defaults"
  859. else
  860. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  861. exit
  862. fi
  863.  
  864. update-rc.d irexec defaults > /dev/null 2>&1
  865.  
  866. # Backup if existing and create /home/"$user"/.lircrc
  867.  
  868. mv --backup=numbered /home/"$user"/.lircrc //home/"$user"/.lircrc.bak > /dev/null 2>&1
  869.  
  870. sleep 1
  871. echo -e "\033[32m Creating /home/"$user"/.lircrc"
  872. cat << 'EOF' > /home/"$user"/.lircrc
  873. begin
  874. remote = Microsoft_Xbox360
  875. button = OpenClose
  876. prog = irexec
  877. repeat = 0
  878. config = /home/X123X/restart-kodi.sh
  879. EOF
  880.  
  881. # Check to see if a file was created with the correct name
  882.  
  883. if [ -f /home/"$user"/.lircrc ]
  884. then
  885. echo -e "\033[0mFile Created"
  886. else
  887. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  888. exit
  889. fi
  890.  
  891. # Couldnt pass the $user variable correctly with cat EOF so we will inline edit it with sed
  892.  
  893. cat /home/"$user"/.lircrc | sed -e "s/X123X/$user/" >> /home/"$user"/.lircrc.tmp
  894. mv /home/"$user"/.lircrc.tmp /home/"$user"/.lircrc
  895.  
  896. # This is a user file so we will change ownership back to the specified user because script is run as root
  897.  
  898. chown "$user":"$user" /home/"$user"/.lircrc
  899.  
  900. # create /home/"$user"/restart-kodi.sh"
  901.  
  902. sleep 1
  903. echo -e "\033[32m Creating /home/"$user"/restart-kodi.sh"
  904.  
  905. cat << 'EOF' > /home/"$user"/restart-kodi.sh
  906. #! /bin/bash
  907. killall -9 kodi.bin
  908. # Living, He loved me, dying, He saved me
  909. # Buried, He carried my sins far away
  910. # Rising, He justified freely forever
  911. # One day He's coming, oh, glorious day
  912. EOF
  913.  
  914. # Check to see if a file was created with the correct name
  915.  
  916. if [ -f /home/"$user"/restart-kodi.sh ]
  917. then
  918. echo -e "\033[0mFile Created"
  919. else
  920. echo -e "\e[1;31;40mError Creating File.....Something went wrong"
  921. exit
  922. fi
  923.  
  924.  
  925.  
  926. chmod +x /home/"$user"/restart-kodi.sh
  927.  
  928. # This is a user file so we will change ownership back to the specified user because script is run as root
  929.  
  930. chown "$user":"$user" /home/"$user"/restart-kodi.sh
  931. rm /tmp/banner > /dev/null 2>&1
  932. echo ""
  933. echo ""
  934. echo -e "\e[0;32;40mDone......Your X-BOX 360 universal remote should now work with kodi :)""\033[0m"
  935. echo ""
  936. echo ""
  937. echo -e "\e[1;31;40mReboot required for changes to take effect"
  938. echo -e "\033[0m"
  939. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement