Building a CO2 sensor using a Pi PicoW & automating a home ventilation system part 2
The second in a 3-part series giving a walk-through of creating a custom co2 sensor using the raspberry pi picow and hooking it up to a home ventilation system.
Do you ever get annoyed that your Downloads folder gets cluttered with all types of files and folders? Are your images scattered across various places on your machine and you just wish they could be organised into one place?
Switchboard is a tool here to help you organise files on your machine.
As aptly described above, I built switchboard out of a frustration with the sporadic mess of files strewn throughout my machines and network servers.
In my particular case - I use Kubernetes running a couple of raspberry Pis which hosts deluge, a torrent download client. I have another Pi in turn which specifically runs Open Media Vault and Plex, for NFS and file sharing. Now, my problem, is that Deluge will explicitly download all file types to a downloads folder on my NFS - which means I have to ssh into my Pi NAS every time I (legally) download a video, and move it across to my videos folder so as Plex can pick it up and sync.
This can get tedious. So, to fix it, I built Switchboard.
Switchboard works by monitoring a directory you provide (or list of directories using a configuration file), and utilizes file system notifications to move a matched file to the appropriate destination directory of your choosing.
Under the hood, I use fsnotify which is a handy package to allow for cross-platform file system notifications. However, the cross-platform nature of the package has some limitations. For instance, for Windows and MacOS systems there is no concept of a IN_CLOSE_WRITE
event as there is in Linux. Allow me to explain why this can be a problem with a simple example.
Imagine you are in the process of downloading a rather large file to your systems Downloads folder. We can use the Ubuntu 20.04 LTS ISO as our example. What will happen when you click that download button and save the file to your Downloads folder? A CREATE
event will be sent, followed by susequent WRITE
events to the file as it downloads. But, how do we know the file has finished being written to?
How do we know when a file has finished being writtten to?
Here in lies the crux of the problem outside of Linux. So, in order to mitigate this switchboard implements a polling solution. Events will be added to a queue, wherein a poller will check every x number of seconds when the file was last modified. If the file was modified within the last x number of seconds, we will continue polling, otherwise, switchboard will assume the operation has completed, and the file is valid.
This obviously does not cover all scenarios, for example, you might be downloading a file and halfway through you may loose internet connectivity. In this instance, the file will be moved, and may very well be invalid. That being said, I believe this change will greatly improve switchboard compared to how it currently stands.
You can install switchboard pre-compiled binary in a number of ways.
You can also upgrade the version of switchboard
you already have installed by doing the following.
You can download the pre-compiled binary for your specific OS type from the OSS releases page. You will need to copy these and extract the binary, then move it to you local bin directory. See the example below for extracting a zipped version.
Using switchboard is pretty easy. Below lists the set of commands and flags you can pass in.
To get started quickly, you can run the following command, passing in the path, destination, and file extenstion you want to watch for. See the example below.
Some progress has already been made towards a new release which will negate the need for any polling on linux systems and incorporate the IN_CLOSE_WRITE
event operation. Polling will remain as a feature however for Windows & MacOS architectures.
At some point in the near future, I hope to release a pro version of switchboard. This version will incorporate a whole host of features whcih I currently have plans for, and will be made available at a modest price. Best of all, you can join the wait-list now by sponsoring me on Github and receive a free copy of the pro version once it’s released!
You can also visit https://goswitchboard.io for a full list of tips, tricks and examples to get you started using switchboard. Happy organising :)