Some Ubuntu Linux Shell Scripts, Code and Pointers used in TangerineTech DMA/VIBOX Customizations

Regarding the Document:
© 2009-2012 Simone Bianchi, TangerineTech Engineering. License: Free verbatim copy and redistribution.


ITEM 1: Shell script to stop the machine if network is not available for more than 300 sec.


#!/bin/bash
while true; do
sleep 150
if (ping -qc 7 insert machine to ping || ping -qc 7 insert machine to
ping
)
then
echo "OK"
else
sleep 150
if !(ping -qc 7 insert machine to ping || ping -qc 7 insert machine to
ping
)
then
echo "no connection"
insert shutdown command (ie: halt)
else
echo "OK"
fi
fi done

ITEM 2: Shell script to stop the machine when a file on a disk volume is not available. (Tested: Ubuntu 10.04 LTS X86)


#!/bin/bash
while true; do
sleep 60
if test -e /media/insert media to check (ie: sda1)/insert filename to
check (ie:file.txt)

then
echo "OK"
else
echo "KO"
insert shutdown command (ie: halt)
fi
done


ITEM 3: Shell script to run Openoffice Presentation when the machine starts.


#!/bin/bash
mount /dev/insert media to mount (ie:cdrom)
sleep 5
openoffice -show -norestore /media/insert media to check (ie:
cdrom)/insert filename to open (ie:presentation.odp)


ITEM 4: Shell script: if a USB drive named 'switch' is available, start VLC, else start XBMC.


#!/bin/bash
if test -e /media/switch
then
umount /media/switch
vlc --qt-start-minimized
else
xbmc
fi


ITEM 5: Shell script: mount as root ( WARNING WARNING WARNING! TESTING ONLY! SECURITY HAZARD!) a disk labeled 'store' on the directory 'test' of the user 'user'.

#!/bin/bash
echo (insert your password) | sudo -S mount (insert mount options) /dev/disk/bylabel/store /home/user/test


ITEM 6: Shell script: if the disk 'backup' is present copy the contents of the 'test' directory of the 'user' user to it, then umount it. Check every 10 seconds. (Tested: Ubuntu 10.04 LTS X86)


#!/bin/bash
while true; do
sleep 10
if test -e /media/backup/
then
cp -r /home/user/test/* /media/backup/
echo "OK"
umount /media/backup
else
echo "KO"
fi done


ITEM 7: Start NVIDIA accelerated drivers on a Live CD. (Tested: Ubuntu 10.04 LTS X86)

Before mastering the CD insert in the rc.local file of the master system this command:
nvidia-xconfig
NVIDIA drivers must be installed on the master system.


ITEM 8: ALSA .asoundrc file to create an Audio DSP processed out. (Tested: Ubuntu 12.04 LTS X86)

tt_dsp_alias is the output to select in the audio player programs in order to have processed audio.

ladspadspplugin is the label of the DSP plugin which has to be located in /usr/lib/ladspa. (In this particular case the plugins used in the DMA/VIBOX machines load their parameters from an autonomous config file)

slave.pcm "hw:0,0" assigns to a hardware device (in this case the first output of the first system sound board) the task to reproduce the signal.

The audio signal is expanded to 32 bits floating point in order to be processed, and the sampling rate is not converted (ie. it is the same of the source material). LADSPA plugins used in DMA/VIBOX have proved to run optimally at all of the sampling rates used in the source material.

 

#----------start of .asoundrc file-----------

pcm.tt_outhw_alias {
type plug
slave.pcm "hw:0,0"
}


#------------------------------------------

pcm.tt_dsp {
type ladspa
slave.pcm "tt_outhw_alias";
path "/usr/lib/ladspa";
plugins [{
label ladspadspplugin
input {
}
}]
}

#------------------------------------------

pcm.tt_dsp_alias {
type plug
slave.pcm "tt_dsp"
}

#------------------------------------------

ITEM 9: XBMC AND LIRC CONFIGURATION FOR APPLE REMOTE (Tested August 2014)

To use an Apple Remote on XBMC for Linux:

1: install XBMC and LIRC via package managers. Configure it for a suitable receiver (ie. Manta TR1 for Apple Remote)

2: create /etc/lirc/lircd.conf as follows

#This configuration has been automatically generated via
#the Ubuntu LIRC package maintainer scripts.
#
#It includes the default configuration for the remote and/or
#transmitter that you have selected during package installation.
#
#Feel free to add any custom remotes to the configuration
#via additional include directives or below the existing
#Ubuntu include directives from your selected remote and/or
#transmitter.

#Configuration for the Windows Media Center Transceivers/Remotes (all) remote:
include "/usr/share/lirc/remotes/mceusb/lircd.conf.mceusb"

begin remote
name Apple_A1156
bits 8
flags SPACE_ENC
eps 30
aeps 100

header 9065 4484
one 574 1668
zero 574 547
ptrail 567
repeat 9031 2242
pre_data_bits 16
pre_data 0x77E1
post_data_bits 8
post_data 0xC5
gap 37600
toggle_bit 0
ignore_mask 0x80ff

begin codes
KEY_PLAY 0x20
KEY_UP 0xD0
KEY_RIGHT 0xE0
KEY_LEFT 0x10
KEY_DOWN 0xB0
KEY_MENU 0x40
end codes

end remote

 

3: INSERT IN XBMC keymaps folder the file remote.xml as follows

<!-- 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>Back</back>
<menu>PreviousMenu</menu>
<title>ContextMenu</title>
<info>Info</info>
<skipplus>SkipNext</skipplus>
<skipminus>SkipPrevious</skipminus>
<display>FullScreen</display>
<start>PreviousMenu</start>
<record>Screenshot</record>
<volumeplus>VolumeUp</volumeplus>
<volumeminus>VolumeDown</volumeminus>
<mute>Mute</mute>
<power>XBMC.ShutDown()</power>
<myvideo>XBMC.ActivateWindow(MyVideos)</myvideo>
<mymusic>XBMC.ActivateWindow(MyMusic)</mymusic>
<mypictures>XBMC.ActivateWindow(MyPictures)</mypictures>
<mytv>XBMC.ActivateWindow(VideoLibrary,TvShows)</mytv>
<red>XBMC.ActivateWindow(Home)</red>
<green>XBMC.ActivateWindow(MyVideos)</green>
<yellow>XBMC.ActivateWindow(MyMusic)</yellow>
<blue>XBMC.ActivateWindow(MyPictures)</blue>
<zero>Number0</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>
</remote>
</global>
<Home>
<remote>
<info>XBMC.ActivateWindow(SystemInfo)</info>
<clear>XBMC.ActivateWindow(Weather)</clear>
<hash>XBMC.ActivateWindow(Settings)</hash>
<up>VolumeUp</up>
<down>VolumeDown</down>
<menu>XBMC.ActivateWindow(shutdownmenu)</menu>
</remote>
</Home>
<MyFiles>
<remote>
<clear>Delete</clear>
<zero>Highlight</zero>
<star>Move</star>
<hash>Rename</hash>
</remote>
</MyFiles>
<MyMusicPlaylist>
<remote>
<clear>Delete</clear>
<zero>Delete</zero>
</remote>
</MyMusicPlaylist>
<MyMusicPlaylistEditor>
<remote>
<zero>Queue</zero>
</remote>
</MyMusicPlaylistEditor>
<MyMusicFiles>
<remote>
<zero>Queue</zero>
<star>Queue</star>
<select>RunScript(special://masterprofile/keymaps/playfullscreen.py)</select>
</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>VolumeUp</up>
<down>VolumeDown</down>
<back>SmallStepBack</back>
<menu>OSD</menu>
<start>OSD</start>
<select>Pause</select>
<title>CodecInfo</title>
<info>Info</info>
<teletext>XBMC.ActivateWindow(Teletext)</teletext>
<subtitle>NextSubtitle</subtitle>
<star>NextSubtitle</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>Back</info>
<menu>OSD</menu>
</remote>
</FullscreenInfo>
<PlayerControls>
<remote>
<menu>Back</menu>
</remote>
</PlayerControls>
<Visualisation>
<remote>
<left>SkipPrevious</left>
<right>SkipNext</right>
<up>VolumeUp</up>
<down>VolumeDown</down>
<back>LockPreset</back>
<title>CodecInfo</title>
<select>Pause</select>
<menu>XBMC.ActivateWindow(MusicOSD)</menu>
<start>XBMC.ActivateWindow(MusicOSD)</start>
<info>Info</info>
</remote>
</Visualisation>
<MusicOSD>
<remote>
<menu>Back</menu>
<title>Info</title>
<info>CodecInfo</info>
</remote>
</MusicOSD>
<VisualisationSettings>
<remote>
<menu>Back</menu>
</remote>
</VisualisationSettings>
<VisualisationPresetList>
<remote>
<menu>Back</menu>
</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>
</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>
<VideoOSD>
<remote>
<menu>Back</menu>
<start>Back</start>
</remote>
</VideoOSD>
<VideoMenu>
<remote>
<menu>OSD</menu>
<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>
<menu>Back</menu>
<start>Back</start>
</remote>
</OSDVideoSettings>
<OSDAudioSettings>
<remote>
<menu>Back</menu>
<start>Back</start>
</remote>
</OSDAudioSettings>
<VideoBookmarks>
<remote>
<menu>Back</menu>
<start>Back</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>
<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>Back</title>
</remote>
</ContextMenu>
<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>
<MusicInformation>
<remote>
<info>Back</info>
</remote>
</MusicInformation>
<MovieInformation>
<remote>
<info>Back</info>
</remote>
</MovieInformation>
<LockSettings>
<remote>
<menu>Back</menu>
</remote>
</LockSettings>
<ProfileSettings>
<remote>
<menu>Back</menu>
</remote>
</ProfileSettings>
<PictureInfo>
<remote>
<skipplus>NextPicture</skipplus>
<skipminus>PreviousPicture</skipminus>
<info>Back</info>
</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>
<red>Red</red>
<green>Green</green>
<yellow>Yellow</yellow>
<blue>Blue</blue>
<info>Info</info>
<menu>Back</menu>
<start>Back</start>
<teletext>Back</teletext>
</remote>
</Teletext>
<AddonSettings>
<remote>
<clear>Delete</clear>
</remote>
</AddonSettings>
</keymap>

4: INSERT IN XBMC keymaps folder the file lircmap.xml as follows

<lircmap>
<remote device="Apple_A1156">
<up>KEY_UP</up>
<down>KEY_DOWN</down>
<left>KEY_LEFT</left>
<right>KEY_RIGHT</right>
<menu>KEY_MENU</menu>
<select>KEY_PLAY</select>
</remote>
</lircmap>

5: INSERT IN XBMC keymaps folder the file playfullscreen.py as follows

import xbmc

xbmc.executebuiltin("Action(Select)")
xbmc.executebuiltin("Action(Fullscreen)")

THIS CONFIGURATION ALLOWS THE USE OF A SUITABLE RECEIVER (IE. MANTA TR1) + APPLE REMOTE TO MANAGE XBMC MEDIA CENTER ON LINUX. MADE BY SIMONE BIANCHI USING FREELY AVAILABLE ELEMENTS. IN PARTICULAR PLAYFULLSCREEN.PY ALLOWS TO START MUSIC REPRODUCTION DIRECTLY IN FULLSCREEN WITH VOLUME CONTROL. THIS CONFIGURATION HAS ALSO FULL VOLUME CONTROL IN THE INITIAL XBMC SCREEN. APPLE REMOTE ID IS DISABLED, EVERY APPLE REMOTE WILL BE RECOGNISED AS VALID.

 

SOME WEB POINTERS:

http://alsa.opensrc.org/.asoundrc
http://www.ladspa.org/
http://www.tangerinetech.net
http://www.littlesvr.ca/isomaster/
http://www.len.ro/2008/12/remastering-ubuntu/
http://www.ubuntu.com/
http://www.geekconnection.org/remastersys/remastersystool.html
http://unetbootin.sourceforge.net/
http://www.pendrivelinux.com/ubuntu-remove-the-prompt-to-eject-cd

 

NOTES:

-Mount directories may vary.
-Web links may become outdated.
-Be sure to ping machines you have permission to.
-For some pointers on allowing a non-root user to shutdown a system using console, please see: http://wiki.archlinux.org/index.php/Allow_users_to_shutdown.