Categories
Development Project Raspberry Pi

I Wanted a Pi to Tell me Useless Stuff About my Computer!

Yep, here we go again – another semi-useless but way over-complicated Raspberry Pi thing…

I had a fantastic idea to make an Android Auto screen for my classic tech car. Did it work? Yes. Did it obscure my windshield? Kinda. Did it over-complicate my audio setup? *sigh*… Yeah.

I’m not a fan of e-waste, so naturally instead of going into the bin, my Raspberry Pi screen got reused… As a paperweight.

Mid-way through COVID-19 2: Electric Boogaloo, I was chilling after playing a computer game when my PC fans ramped up. Perplexed, I wondered if there was a way I could show information about my computer, without using something on-screen.

And what did I discover? Yeah idiot there’s like a trillion ways to do that.

So here comes the trillion and 1th way –

DeskDash

Yep, while trying to think of a name for my desktop dashboard project, I came up with a pretty good name… For an office food delivery company.

My goals for my project were simple:

  • Got a Raspberry Pi.
  • I have a screen.
  • Let’s see some cool things. [citation needed]

I also wanted to keep things consistent. I’m pretty well versed in PHP so I could make a simple PHP webserver, run an instance of Chrome in kiosk mode, and show some SNMP data. Simple right?

So I made a two-split system of a fullscreen scrolling Electron application, with an accompanying Python Daemon API that runs on the PC you want data/interactions from. Thanks for coming to my TED talk.

The API

So I mentioned SNMP. SNMP is Simple Network Management Protocol. The ‘simple’ is subjective – Google SNMP, and tell me how long it takes you to understand it – I’ll wait.

While seriously over-complicated, it would achieve pretty much what I want, cross platform. Sadly, despite being a CCNA qualified network engineer, I completely forgot SNMP existed and lost my ability to use Google, so I made my own way.

Since I wanted to actually interact with the PC too, in theory I saved myself a lot of time here. That’s my defence and I’m sticking with it.

And so the Deskdash Communicator API was born. I decided I wanted the following information:

  • Basic machine info (name, OS, etc).
  • Task Manager level details (CPU, GPU, RAM, the more the better).
  • Added bonus – let me turn my PC off.

Choice of language was a difficult one. I’m a PHP developer by trade but I was by chance learning to program in Java. Could be a fantastic learning project, right?

So yeah I wrote it in Python.

The ‘MVP’ ended up being a Python mini webserver that would garner the desired details through different libraries and scripts, as Python is pretty much famous for. Coming from PHP, it took me ages to understand why PIP wouldn’t let me install dependencies locally… Then the venv penny dropped.

I also added the ability to run shutdown from the script by making a callback with a password you’d set in config. Since shutdown normally needs sudo, I’m still quite surprised to find it works flawlessly… Although I don’t want to question it in case it stops working.

I also set a 5 minute timer so my partner doesn’t prank shutdown my computer… Yeah, that was a lesson learned implementation.

I’ve now got all my info, what about my visuals?

The Application

I decided to make a simple HTML page with some not-so-simple JavaScript stuff. But to help keep things simple layout-wise, I used Bootstrap.

My idea would be to take the worst part of a website – the banner – and make it full-screen. I could make it configurable so that you could make slides. Each slide could show different bits of info, not just stuff about my PC.

I’m not a fan of JQuery in 2020. It was good for the time, but JavaScript has come a long way since. I swapped the Bootstrap JQuery aspects with Bootstrap native, a fantastic library that converts Bootstrap superbly.

I also made an infinite loop that ran every 5 seconds, that could be instructed by the various on-screen components to grab information. I’m in no need for instant information, so I thought a 5 second limiter would help not overload my network and/or PI.

My goal was to display this in Chromium in Kiosk Mode, but I ended up needing a ridiculous number of different plugins and quirks to get a decent application. Since I don’t need to heavily rely on NPM, I used this opportunity to make a very simplistic Electron application.


So after 4-5 months of development work, and the stages of grief over various development choices, deskdash was alive. I watched in awe (and some disgust) as my Raspberry Pi told me my PC was doing fine, it was 4:00am on a Sunday, and that loading up YouTube was bizarrely a big struggle for my GPU.

I’d done it – the Deskdash GUI – now to put it somewhere useful.

Oh god who trusted me with a drill???

My enclosure for my Raspberry Pi screen is a Smartpi Touch 1 (no longer sold). This screen has a normal horizontal placement stand that comes with VESA mounting holes. I looked at the side of my desk, it looked back at me- oh yeah, 4am… Mmm, I should sleep.

Woke up and got straight to work drilling at my desk. As with all great DIY stories, I eyeballed the location of where my Pi screen would go – mounted to the outside edge of my MICKE desk. I drilled into the wooden side panels, and mounted my screen with some spare VESA screws. Perfect, first time!

Some advice – maybe check the height you want it before blindly following my same steps.

Fantastic – my screen is mounted to my desk (slightly lower than it should’ve been)!

Was it worth it?

I’m writing this article 4 months later, and it’s still in use!

It can do a few more things now, like watch my Bitcoins crash into oblivion and let me know when IP addresses join and leave my network (far less useful than I imagined), and I’m gradually making it more useful, one ticket at a time.

Did I build it well? Well- that’s a different story.

Source Code

If you really want to give this a shot for yourself, the source code is available on GitHub under the MIT license. PRs are welcome but I may be pretty particular of the outcome, so independent forks are also completely welcome.

Despite building the code for a Raspberry Pi application, in theory the combination of a Python API + Electron GUI should make this fully cross-platform. Go ahead and try this on a big screen, small screen, horizontal or vertical. Just please – show off your creations below!

By Casey

Casey is a back-end developer specialising in PHP, primarily for WordPress developments. Outside of Spaghetti-hell, he also works a lot with IoT and Raspberry Pis.