Wednesday 18 April 2018

Raspberry Pi 3B+ Desktop for an RV


Years ago on one of his visits home from Japan, my son gave me his old Raspberry Pi, because he had just upgraded to the new Pi B+.  It didn't take much messing around with it before I saw some potential and ended up with a Pi B+ as well.  As luck would have it, the Pi 2 was released about a week later, and with the faster processor and double the RAM, I acquired one.  

Then the Raspgerry Pi 3 came out with a faster processor and 4 USB ports, and even more useful - built in Wifi and Bluetooth.  Suddenly I had the basis for something I had wanted.  A low power draw desktop computer for one of the yachts I was living aboard for part of the year.

A wander around the computer stores found me a 15 inch LED TV that used a 12 Volt power supply and had HDMI input and a USB port.  I had thought the USB port could be used to power the Pi, but while it may have been sufficient for the B+, the Pi 2 needs close to 2.5 Amps and the early TV USB port outputs were seldom that high.

The neat thing though, was that this TV used a 2 Amp 12 volt power adapter with a standard D.C. plug end.  It worked fine instead with a car cigarette lighter adapter.  A Pi of course, will run nicely using a cigarette lighter USB charger adapter.

So the electrical requirements were sorted, because the 26 foot Cavalier keel boat I was living on was already set up with 12V cigarette outlets in various places, and solar charging.

A few things happened with my health - mainly three apparent Golden Staph infections in my brain, and a mess of it in my heart,  The brain was stabilised using very strong antibiotics, but the heart was bad and required a replacement Aortic Valve.  That took me off the yacht and screwed up my life for the next 6 years.  After years of suffering from a 1999 spinal injury that the hospital had ignored, then more from the dozen or more fractures in the hit and run incident in 2004, I could do without more health dramas.

My life had been pretty well 'stolen' from me by medical incompetence for years, and now this!  As it turned out, things would get worse.

In 2017, the yacht "Shepherd Moons" was wrecked in cyclone Debbie, and while I was trying to salvage some stuff in the wreck lying in the mangroves, I got infected again.  I ended up with a Golden Staph infection in my heart that was so serious they were doubtful if it could be operated on.  On top of that I had three bleeds into various lobes of the brain.  One in the occipital lobe has affected my eyesight, one might have made me a little dumber, but the other was into the cerebellum and was definitely life threatening of its own accord, because there was a real likelihood that I would return from surgery in a permanent vegetative state.

The surgical team pointed out that this time the Golden Staph infection was not only in the valves of my heart, but had apparently eaten into the 'mitral curtain', and area separating two of the chambers in my heart.  They would not know for sure, but they suspected repair might not be practical.  If it was reparable, they planned to remove a section of my heart containing the root of the Aorta, and the Aortic Valve, and replace the whole piece with a section from a pig's heart.

They also insisted my son, who was now working in Brisbane, fly to Townsville to say 'goodbye'  just in case.  

Despite saying goodbye to the people closest to me, I ended up surviving again.  But my days of living aboard yachts are probably over.  I came through with permanent effects of stroke, and some extended peripheral nerve damage as well as a couple of eyesight problems.  But I can still drive, which is where we get back to this post.


I still have my Toyota HiAce van, and although it is getting a bit long in the tooth, I have spent a bt on it to keep it mechanically sound.  And as much as a laptop might be more practical, I have all the bits here to make a small mobile desktop computer.  So when the new Raspberry Pi 3B+ came out I bought one, because I had given my Pi 3 to my son.

I had a couple of Pi 2 around in cases, and since the cases haven't changed, I fitted one to the Pi 3B+, along with spare heat sinks left from when I overclocked the Pi 3.  I also still had a bluetooth keyboard with a track pad.

All the parts were there, so I hooked it all together,  Immediately I found that the system runs about the same as the overclocked Pi 3.  But it is definitely sucking more power than my 2.4 Amp adapter likes.  That means I will have to look for a 12V 2750ma or 3000ma adapter.

But it works.  Video is ok on Chromium, and great on Kweb with OMXplayer.  I worked on some stuff for Kweb with Gunther Kriedl a couple of years ago, so I like Kweb.

I also found that no matter what I did, VLC and SMplayer will not work properly because unlike OMXplayer, they do not have the appropriate codecs available and do not work with the Pi hardware acceleration.

However Kodi still does, so I can play video at 1080p using OMXplayer or Kodi, and I can watch 1080p or 720p YouTube videos.


The last big difference is that the Pi 3B+ can access my 5GHz WiFi with its built in wireless and bluetooth module, and streaming is now seamless.

The Pi case attaches to the back of the TV using velcro, and I use a very short flat HDMI cable for neatness - not the one shown above.  Sound is though the HDMI cable,but I also have a little gadget that plugs into the audio socket on the Pi and transmits audio to the car radio if I want to play music with decent sound.

The van has a built in 4G WiFi hotspot access, so I can also have Internet and comms on the move, as well as TV if I am in a reception area.

I'm happy as a pig in stuff.

Friday 6 April 2018

My Linux KDE Video Wallpaper problem SOLVED

I have been using Shantz xwinwrap for years now to have video wallpaper on my Linux systems.  These days with so many 4k UHD video demos for various 4K TV brands available on YouTube, it is possible to have some spectacular video clips, instead of say, a slideshow as a desktop background.

I used VLC wallpaper mode for a while, but when I found xwinwrap, I was in my elephant.  Completely configurable by creating a bash script, and able to be used with, as far as I can see from trials, all common desktop managers.  I have had it running on Mint Cinnamon, Mate, XFCE etc, and even on Elementary OS and others.

But KDE and more recently Plasma 5 are my preference.  Plasma 5 is still horribly messed up, (even at April 2018) but Mint 17.3 KDE edition is wonderful.  Light weight, fast and incredibly customisable.  Just the candidate for a video background, especially since running video wallpaper on it still uses minimal overheads.

As a matter of interest, I have used this on Plasma 5 with various distros including Mint and Kubuntu.

A small oops here.  If you run a different video on each of several Virtual Desktops it uses minimal overhead.  If you do the same thing on several different activities it will eat CPU cores.

However, it wasn't easy to get the thing set up the way I like it.

What I wanted was an easy way to group videos, so I could choose Scenery (silent), Relaxation (with background music), Personal videos from my own camera, Music videos (onviously with sound) and whatever else I felt like.

First things first, I set up a VideoWallpaper folder.  Then I created subfolders for each of my categories.  Of course, I didn't want to just cycle through the videos in a set order - I wanted to play the videos in a folder in random order.  And I wanted the whole thing to repeat, especially if there were only a few shortish videos in a folder.

Sounds easy?  It wasn't.  Shantz provides a starting script, but it didn't do what I wanted.  Lots of googling had me trying all sorts of 'while do;' and 'for' scripts to try to get the random and repeat but working - but no matter what I did, the videos would play until each one gad run once, and them perhaps repeat the last one over and over, or more often simply exit the videos.

There was one more thing.  I could make a video play on ONE Activity or ONE Virtual Desktop - but not all Activities or desktops.  That one I solved accidentally, and I'm still not completely certain I have it right.  For now though, it plays on all Activities, but still lets me have individual Virtual Desktops within those Activities with ordinary images as wallpaper. And within the Activites. I have the music videos playing in an 'eliptical porthole' though the desktop image.

About the one thing that is still unsolved is if I have clickable icons on the desktop, something I rarely do.  But if I want to set a plain colour as a background and allow a little translucency to the video wallpaper, clicking in the icons below works fine.

Ok, first, it is necessary to download and install Shantz xwinwrap.  It comes in 32 or 64 bit.  I use the .deb package, but it is available in .rpm and others as well as source.  Downloads and some instructions are here:
https://shantanugoel.com/2008/09/03/shantz-xwinwrap/

Next, the script.  The code below is what works for me - except the bit about sticking to multiple Activities or desktops (that has to be done differently in KDE).

The code below is a file called "4kscenery-silent".  It is in a folder called Video-Shelf which is in my VideoWallpaper folder.  I made the 'shelf' folder to put all the script files in one place - sort of gives me an index on the panel.

Clicking the Video-shelf folder on the panel shows the various scripts just lie a menu, and clicking '4kscenery-silent' gives me a full screen rectangle video background chosen at random from the videos in the store folder, which is where I add and remove various scenery videos/

The path to the store folder is /VideoWallpaper/UHD-SCENERY/4k-Scenic/store
Since I am starting in the VideoWallpaper folder, the path to the files is:
../UHD-SCENERY/4k-Scenic/store/*


(contents of 4kscenery-silent below)

!#/bin/bash
if ps -e | grep xwinwrap
 then
  killall xwinwrap
  sleep 1
  exit
 fi

# RECTANGLE-Shuffle
 # RECTANGLE
 xwinwrap -ni -o 1.0 -fs -s -st -sp -b -nf -g 1680x1050-0+0 -- mplayer -loop 0 -shuffle -wid WID -nosound -aspect 16:10 ./store/* ../UHD-SCENERY/4k-Scenic/store/*


Now this script after a lot of trial and many errors, gives me a randomly repeating selection of videos, but I need to be able to turn it off.  So Another script needs to me written and made executable, then dragged to the panel and the icon changed to something suitable (in my case a red square with a white X.

I called it Kill-xwinwrap and it contains the following code:

!#/bin/bash
#To enable repeat mode in mplayer by default,
#edit /home/Your_User_Name/.mpalyer/config and add loop=0
#at the end of the file.
#To do that, press Alt+F2 and then type in   gedit .mplayer/config

if ps -e | grep xwinwrap
 then
  killall xwinwrap
  sleep 1
  exit
 fi

Clicking the Icon on the panel kills the video.  There IS a reason for the
  killall xwinwrap   in the main code LEAVE IT IN THERE !!

You might have noticed
-g 1680x1050-0+0  and
-aspect 16:10

The -g flag tells xwinwrap what screen resolution I have set in my Display settings.  -aspect tells mplayer what aspect ratio to play the movie at.  I discovered that adding the -aspect setting close to the resolution aspect (16:10 is pretty close to 1680x1050 and 19:11 is close enough to 1920x1080) makes things go fullscreen nicely.  Something else that I could not find an answer for on Google.

Ok, so the video is playing with no sound.  If I add a new folder in the VideoWallpaper folder called 'Music'  and put some music videos in there, I can play them with sound while I work.  I can make them play though an oval porthole in the desktop if I want to as well.

I have the music videos sorted in separate folders for moods or artists, so my I drag my 'MusicVideos' folder to the panel.  It has the scripts for each artist etc.  and once again clicking on the folder just shows a list of the  scripts in that folder - again, sort of like a menu.
Here's the script for one artist:

!#/bin/bash 
if ps -e | grep xwinwrap
 then
  killall xwinwrap
  sleep 1
  exit
 fi

# Circle-Shuffle
 xwinwrap -ni -o 1.0 -fs -sh circle -s -st -sp -b -nf -g 1680x1050-0+0 -- mplayer -loop 0 -shuffle -wid WID -aspect 16:10 ./store/RoyOrbison/*

So this script is in a folder called 'MusicVideos', which contains a folder called 'store', which contains folder for various artists. And in among those folders there is a folder called RoyOrbison with his videos.

This script also has an argument 
-sh circle
But the geometry and aspect settings make it an oval.  So the video looks like it is playing through a hole in the normal desktop image.

If you compare the script with the first one you will see that the argument 
-nosound 
is missing.  That allows it to play the songs in the videos.

I'll append screen shots below to illustrate some of this stuff.  It took a while to get it all working smoothly and Googling showed me that many other people have tried and failed to get the wrinkles smoothed.

I've still got to explain how to stick it to multiple Activities and Desktops.  And although I can make it accept a different video on each Activity or Virtual Desktop - I don't recommend it, as it really hogs resources and ruins a slick little idea.

Ok, because this is such a long post and I have been double checking things as I go, including reinstalling Plasma 5 (this time Mint 18.3 KDE), I am writing it over several weeks.  Sorry for the mess..

To make the video stick to ALL Activities, or ALL Virtual Desktops - or to both Activities AND Desktops, I created a new Window Rule.  In Mint 17.3 KDE go to System Settings > Window Behaviour >Window Rules
and click the New button.
Now, I do no know why this works, but I'll explain what happened.  At first I thought that since the script runs mplayer, I should make a rule for that.  I soon found out that applying the rule means every time I want to use SMplayer to watch a movie, or Kmplayer for that matter, it plays on every desktop and / or activity.  So I killed that off.

I made a new rule called RossVidWall.  Now the idea was to put in the parameters, and then work out what to call it based on the script (which is NOT actually called RossVidWall.  I entered the settings I wanted, clicked Apply, and then ran the script I created for one artist.  Let's just say the script was called Scenery.

I clicked the executable script called Scenery, and the video began playing as wallpaper on all activities and desktops.

In Window Rules this is what I changed:

On the Window matching tab I changed:
Window class (application) = Exact Match

On the Size & Position tab I changed:
[v] Desktop = Force > All Desktops
[v] Activity = Force > All Activities

Everything else I left as Default!


To see if I could do individual desktops and activities with video -
I went back into Window Rules, clicked on RossVidWall, clicked the Modify button  and unchecked the box for Desktops, hit Apply, and each Virtual Desktop had individual images as wallpaper, except one, which had a video.

I adjusted the settings in the window rules to put the video on only ONE Activity and hit Apply.  Now all Activities had separate images as wallpaper - except one that was playing a video, and the same applied to the Virtual Desktops.

Last, as I mentioned earlier I reinstalled Mint 18.3 KDE and tested the same thing, but this time I simply called the new script xwinwrap.  I have no idea why the or how the window rules thing works, when I don;t link it to a program or a script, so I cannot guarantee that bit will work for you.  But even giving the rulle a different name in Plasma 5, it worked.  It may be because I already had the video background running on one Activity  when I did it, or it may be some other reason.

I apologise for the long winded explanation, and I WILL add some pictures soon.
But I hope reading this will help someone avoid all the hassles making video wallpaper work on Linux, and especially on KDE 4 and Plasma 5.

For now, it works great and I at least, am happy with it.

And a reminder, with the exception of the stuff relating to KDE Virtual Desktops and Activities - it works for me on Cinnamon, Mate, XFCE, Elementary and Zorin.