Software details
I use squeezelite to play music from my squeezeserver. Squeezelite does not have a GUI, but it is fully controlled by the squeezeserver. This way I can control it from any computer, tablet or smartphone. But I wanted to have a functional touchscreen as well.
The resulting code can be downloaded here.
GUI
The display is only 320x240, so it needs a tweaked GUI. I created a GUI with Glade and Python. You can take screenshots of a remote X11 application using ssh and xwd.
The final result:
Current playlist:
Searching:
Connecting to the squeezeserver
The squeezeserver listens on port 9090, and talks a very simple protocol with ascii line based commands and results. You can either listen to events or send commands. I use two threads in the python code, one listens for events on the socket, the other listens for commands in a Python Queue and sends those to the server. A third thread downloads artwork from the server which is provided over http.
The system - reducing boot time
The system runs raspbian Jessie, with systemd I managed to reduce the boot time quite a bit. I created a xinit-login.service that starts immediately after the touchscreen device is available.
[Unit]
Wants=dev-input-touchscreen.device
After=dev-input-touchscreen.device
DefaultDependencies=false
[Service]
Type=simple
ExecStart=/usr/bin/xinit
WorkingDirectory=/home/pi/
User=pi
Group=Users
Environment=PYTHONIOENCODING=utf_8
[Install]
WantedBy=local-fs.target
The PYTHONIOENCODING environment variable ensures that python will not raise an exception if there is a unicode character in stdout or stderr.
In the .xinitrc I only start my python/gtk application, so there is no window manager whatsoever running.
The system runs read-only. Various directories such as /var/log, /var/lib/dhcpcd5 and /var/lock are symlinks to /tmp/ and tmp is mounted as tmpfs. /etc/fstab now looks like:
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
tmpfs /tmp tmpfs defaults,noatime 0 0