Setting up a raspberry pi photo viewer (with music)
Posted by Kristian Golding on February 9, 2020
I set up a Raspberry Pi photo viewer at work to display photos from members of the photo club. Members were instructed to put their photos on a Google Drive location (accessible only within the company VPN) and then the viewer would sync down the photos at a predetermined schedule. To get access to Google Drive, I used rclone. To display I used ‘feh’, which was also used to put text indicating the name of the photo.
curl https://rclone.org/install.sh | sudo bash
rclone config
// choose google, team drive. Follow the prompts
// To sync:
rclone sync -v motofoto:SoftwareKitchenPhotos /home/pi/Pictures/SoftwareKitchenPhotos/
// remember: that’s rclone sync -v <source> <destination>! I have wiped out my local directory by syncing with an empty google drive folder!
// Setting up cronjob:
crontab -e
30 2 * * * /usr/bin/rclone sync motofoto:SoftwareKitchenPhotos /home/pi/Pictures/SoftwareKitchenPhotos/
// this runs the job at 2:30 every morning
Two scripts are set to launch on boot. One plays music, the other starts feh.
The directory structure was such that from the root folder to be synced, photographers created a folder with their name and put their photos within it. I requested that the photos have creative names. Given this format, I could put a watermark on each photo in the bottom left by doing the following:
feh –recursive –slideshow-delay 10 –info “echo %F | rev | cut -d’/’ -f1-2 | rev | sed -r ‘s/[.].*//’ | sed -r ‘s/\// – /'”
I want to get the author name (lowest-level directory) and photo name (name of jpg file), strip off the jpg extension, and replace the directory separate “/” with a spaced hyphen ” – “. To do this, I:
- Get the path of the currently displayed photo “echo %F”.
- To get the lowest level directory, I want to grab the directory and filename at the end. I don’t know how many directories deep this will be, but if reversed, I know it will be the first and second elements (if “/” is considered as a separator: rev | cut -d’/’ -f1-2
- I then want to reverse the result back, and strip off the .jpg from the filename (really, anything starting with “.”): rev | sed -r ‘s/[.].*//’
- Finally, I want to replace the “/” with a hyphen, so it will be “Firstname Lastname – Name of photo”: sed -r ‘s/\// – /’
TODO: Starting photo viewer and music player on boot.
2020 New Year in Atlanta
Posted by Kristian Golding on January 5, 2020
A journey with “Embedded programming with Android”: part 1
Posted by Kristian Golding on November 13, 2019
I purchased the Kindle edition of this book: https://www.amazon.com/Embedded-Programming-Android-Bringing-Scratch-ebook/dp/B013IQGX3A
and since I’m going through the book in 2019, there are a few gaps to bridge.  The first was creating an emulator. I did this via command line, and step 1 was to get a basic Android SDK downloaded. I use Vagrant/Virtualbox for my development, so this was used to set up the SDK
put this here
Once that’s done, I need to configure my emulator to use Android API 15. To get an idea of what I can install, I use the sdkmanager tool to list all the available options:
$ANDROID_HOME/tools/bin/sdkmanager --list
Which gives a bunch of output, but I’m only interested in the android-15 results:
system-images;android-15;default;armeabi-v7a | 5 | ARM EABI v7a System Image system-images;android-15;default;x86 | 5 | Intel x86 Atom System Image system-images;android-15;google_apis;armeabi-v7a | 6 | Google APIs ARM EABI v7a System Image system-images;android-15;google_apis;x86 | 6 | Google APIs Intel x86 Atom System Image
The book says we’ll be developing for arm, and I don’t think I’ll need Google APIs, so Ihoose the armeabi-v7a. I don’t know how this is all going to fly in Virtualbox either, so I yolo by running the following command and accepting license with “y”.
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-15;default;armeabi-v7a"
Cool.  Now to create an emulator image, right? I don’t have any idea of how to configure it via command line, but I’ll try and feel my way through:
$ANDROID_HOME/tools/bin/avdmanager create avd --name mytestavd --abi default/armeabi-v7a --package "system-images;android-15;default;armeabi-v7a"
Which results in “Error: “emulator” package must be installed!”
Ok, let’s install that (and wait!):
$ANDROID_HOME/tools/bin/sdkmanager emulator
And then I try re-running the command to create the avd, this time successfully. I answer “no” to creating a custom hardware profile, as I answered “yes” the first time and didn’t know what to answer for some of the questions. I believe I can play around with this at a later time. Now where did that go?  Find out with this command:
$ANDROID_HOME/tools/bin/avdmanager list avd Output: Available Android Virtual Devices: Name: mytestavd Path: /home/vagrant/.android/avd/mytestavd.avd Target: Based on: Android 4.0.3 (IceCreamSandwich) Tag/ABI: default/armeabi-v7a
So, it seems like we may have some basic steps done. More will be done in a part 2 of this post, hopefully in the New Year.
Server performance monitoring with “Netdata”
Posted by Kristian Golding on November 12, 2019
I run a couple of servers at work for my skunkworks projects, and I was trying to find a good monitoring tool to see how much stress I was putting them under. I already use “monit” (https://mmonit.com/monit/), running on a Raspberry Pi, to monitor whether a server (and services running on it) is there at all, but for more detailed monitoring, Netdata (https://github.com/netdata/netdata) was the killer app for me. It’s super easy to install, and once up and running you just go to <servername>:19999 to check the status. If you leave it idle for a while, it’ll stop updating (nice!), which I thought was good because it does provide a metric ton of information. The really nice thing is that because my servers host a bunch of Docker containers, I can see what *each container* is doing. Too awesome.
Example shot for one of the containers: