Having run a raspberry pi as part of my custom weather station set up for many years, I got sick of having to manually restart the pi when it fritzed out, which seemed to happen every few weeks of so.
I did some googling and found out that I wasn’t the only one who was annoyed by this and found that hardware solution had been developed.
Hardware solution
I found the PiWatcher by a company called Omzlo - https://www.omzlo.com/articles/the-piwatcher
I used this without issue for a good few years and it seemed to work with no problems at all. I then when looking for something unrelated came across an article that discussed a secret built in hardware watchdog that all the pi’s had!
Inbuilt software solution
To set up the hardware watchdog, follow these steps. This assumes you are using Raspberry pi OS.
Conky has been around on the linux desktop (and ports to mac) for 15+ years now. A handy bit of screen candy that fills a similar job to neofetch but on the desktop envrionement. Some people spend a lot of time ricing/tweaking their configuration to match with the rest of their system. My config is neither pretty or perfect, but it is functional for me and shows me what I need to know on my system.
As is that tradition, Conkyrc files are often shared and modified online - this is my verison - with a few changes to meet my requirements.
This version of configuration is run on my laptop that is either:
Docked to my main display, power, ethernet and other accessories via usb C.
On battery power away from a charger
Main change from a normal config is a collection of if statement to show certain bits of data depending on situation
Ethernet
This bit of code detects if there is an active ethernet category and if there is, displays the elements within the if statement.
Battery Bar colour
A long nested if to show a different colour of battery bar based on the percentage of the battery, colours will need to be set to what is appropriate for your own set up. Note the slash on the end of the line, this allows the configuration line to contine on the line below for readability but conky will read all this text as a a continious line. Handy unix trick.
Full script content
This is likley to change at some point, I may come back and update this if needed
Neofetch is a handy, slightly cheesy utility that gives some useful summary info about any *nix system from one command in the terminal. Many people, including myself like to have this pop up each time they launch a terminal instance. This behaviour is handy if you have multiple systems that you are accessing via SSH and want to be reminded of where you are in the world!
On modern, powerful hardware, neofetch pops up in a fraction of a second with its handy little summary, however, on lower powered hardware (raspberry pi’s etc) you may find yourself waiting several seconds while it churns away to find out the relevant information. Obviously, this is an unacceptable state of affairs and needs resolving.
There are many ways that we can get round this issue, but the one I have settled on is to run an instance of neofetch every few minutes to update a cached file that is cat’d on start up of a terminal instance. This results in an instant display on any system I have tried so far.
To follow the steps below, you’ll need to have neofetch installed, it is in most repos and can be installed via homebrew on a mac.
First Job
Script to create cache of neofetch output.
Create a hidden shell script in your home directory. Enter the following commands into a terminal.
now paste the following into your newly created shell script (swapping %USER with your username)
or if you are on a mac
Second Job
Set up a cron entry to run every ‘X’ minutes to run the above script
You will need to run this command:
So that you enter the edit mode of your cron config files so that we can add the text below. If given the option, select the nano option to edit the file, the world doesn’t need more VIM evaglesits.
n.b. swapping %USER with your username
or if you are on a mac
Final job
Edit your .bashrc file
In linux and assuming you are running a bash shell, you’ll need to add a command at the end of the .bashrc file to display the content of the cached neofetch output each time a new terminal session is started.
If you are on a mac, I’d suggest adding this to a .bash_profile file if it exists, or you can create your own .bashrc if you like.
*note if you are running a ZSH shell on mac, you’ll need to update your appropriate zsh config files which I think is the .zshrc
This is a handy bit of syntax that redirects any errors to /dev/null, which in practice hides them from appearing in the terminal. This keeps things tidy just in case there is an issue with something in the chain.
If all has gone well, you should now get something like this each time you open a terminal or remote into the system.