Friday, April 10, 2015

Bash Script to View HDHomerun Channel Version 2

I rewrote my tv Bash script to utilize the HDHomeRun JSON feed of the channel line up. The source code can be found on Github at https://github.com/pla1/utils/blob/master/tv

The previous version was written before the JSON feed was available. This new version is simpler and doesn't have the hdhomerun_config requirement.

Friday, April 3, 2015

Raspberry Pi Remote Desktop Client with Kiosk

In an earlier post I talked about using Raspberry Pi as a remote desktop client. That set-up was pointing towards a single server. This variation allows the user to choose their terminal server. This is useful where desks are shared by users with different terminal servers.

This version displays a locally stored html file in a Chromium Kiosk. When the user selects their terminal server netcat is waiting for the HTML form post, greps the terminal server value and runs the rdesktop command. This is done in a never ending loop. The matchbox-window-manager is used to get the kiosk full-screen and with a nice looking mouse pointer.

Remote Desktop Kiosk Screenshot

/etc/rc.local

#!/bin/sh -e
su -s /bin/bash -c startx pi&
exit 0

/home/pi/.xinitrc

/home/pi/remoteDesktop.sh

/home/pi/remoteDesktop.sh

#!/bin/bash
logger "$0 Start"
xset s off
xset -dpms
/usr/bin/matchbox-window-manager &
while true
do
  /usr/bin/chromium --incognito --kiosk /home/pi/remoteDesktop.html &
  response=$(echo -e 'HTTP/1.1 200 OK\r\n' | /bin/nc -4 -l 8080)
  logger "$0 After netcat: $response"
  terminalServer=$(echo "$response" | grep 'terminalServer=' | cut -d '=' -f2)
  /usr/bin/rdesktop -r sound:local -u "" -f "$terminalServer"
done

/home/pi/remoteDesktop.html

<html>
<head>
<title>Remote Desktop</title>
<script>
function postIt() {
  setTimeout(function() {close();},1000);
  document.forms[0].submit();
}
</script>
<style>
body, p, h1, h2, h3 {
  font-family:Verdana;
}
h1 {
  font-size:50px;
}
h2 {
  font-size:40px;
}
.radioLine {
  font-size:30px;
  margin:1em;
}
input {
  margin-right:10px;
}
button {
  font-size:30px;
}
.bodyContainer {
  width: 800px;
  margin: 0 auto;
}
</style>
</head>
<body>
<div class="bodyContainer">
<h2>Choose your terminal server</h2>
<form action="http://localhost:8080" method="post">
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts0-vm">ts0-vm</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts2">ts2</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="ts4">ts4</label></div>
<div class="radioLine"><label><input onclick="postIt()" type="radio" name="terminalServer" value="192.168.1.17">Ubuntu</label></div>
</form>
</div>
</body>
</html>