This manual helps you to set up a freshly installed Raspberry Pi to run this application.
To not run out of disk space during installation make sure you have expanded the file system already!
Also, as a Raspberry PI with a display may use quite a bit of power already, make sure the used power supply can deliver enough current!
In my setup (Raspberry Pi 2B with a 3.5" Touchscreen connected via GPIO) a 2A power supply already ran into under-voltage issues when plugging in a normal USB device that uses the normal specified 500mA. So a 2.5A or a 3A power supply is highly recommended for this setup.
To be able to switch between node versions later on my recommendation would be to install the Node Version Manager. The bets way to install it is by looking at the Installation instructions on GitHub
In case you are executing these commands via SSH you may have to re-connect after installation; else you will not have the nvm
command available...
Now we need to choose a nodeJS version to install; the best would be to go with the latest LTS version. You can install that via nvm install --lts
.
In order to be able to compile the usb-detection
package during the following installation you will need to ensure that two packages are available on the system. I have included them here, but you may want to look for updates at the GitHub readme of the library.
This package should already be there. To check run apt-cache policy build-essential
. The output should be something like this:
build-essential:
Installed: 12.9
Candidate: 12.9
Version table:
*** 12.9 500
500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
100 /var/lib/dpkg/status
If it is not installed you will see the message N: Unable to locate package build-essential
and have to run sudo apt-get install build-essential
to install it.
This package is normally not pre-installed. So directly run sudo apt-get install libudev-dev
. If it is already installed you will get a message that the latest version is already installed, so nothing should break in that case...
In this example the latest code in the main
branch will be cloned - you can also decide to download a specific version manually.
First step is to clone the repository by executing git clone https://github.com/ManuelFeller/simple-usb-checker.git
. Once that is done change into the directory by executing cd simple-usb-checker
.
Then run npm install
do download the dependencies onto that computer and compile everything for the platform. Be aware that this may take a long time (on my Raspberry Pi 2B it took more then 10 minutes).
To make sure that everything works with the freshly added version of Electron you need to do a rebuild for the nodeJS version that is included. To do so run ./node_modules/.bin/electron-rebuild
. This may show a few warning messages, but as long as it ends with ✔ Rebuild Complete
everything should be working fine.
Finally you need to make sure that the Sass compiler is available. Run npm install -g sass
to do so.
In case you want to change any settings run nano src/config.ts
(or any other command line based editor of your choice) and change the settings according to your needs. The comments should explain what each setting does. Also keep in mind that there are limited sanity checks, so don't purposely mess with it
To test if everything works you will need to open a console on the desktop. It is your decision if you want to do this on the device (with keyboard and mouse connected) or via VNC.
-
Open a terminal on the Desktop
-
Change into the directory with the application (normally
cd simple-usb-checker
should do the trick) -
Run it via
npm start
- it may take a bit (on my Raspberry Pi 2B it took about 45 seconds until the application was ready), but at one point you should see the Application being ready
Assuming that you cloned this into the home directory of the user pi
you can from now on use the following command (e.g. in a shortcut) to start the application: /home/pi/simple-usb-checker/node_modules/electron/dist/electron /home/pi/simple-usb-checker/
Currently all updating is done via the git
command - and all changes (e.g. configuration changes you made) will be reverted.
Open an console, switch into the installation directory and execute the following steps:
-
Undo all local changes with
git reset --hard
. -
Update the code base with
git pull
-
Install updated packages
npm install
-
Run
./node_modules/.bin/electron-rebuild
to make sure all modules will work with teh installed version of Electron -
Edit the
src/config.ts
to the settings you want to apply -
Run
npm start
once to see to compile (or transpile) and see if everything works as expected
Once done you can use the shortcuts you may have created - or (in case you have set it up) reboot in to start the new version "automatically"...
If you plan to use this tool as a standalone device there are a few more things to consider
Press the Menu
button on the upper right (Raspberry Pi Icon) -> Preferences
-> Raspberry Pi Configuration
-> Tab Display
-> set the option Screen blanking
to disabled
, confirm with OK
and say Yes
when you are asked for a reboot. But be aware that this may lead to burn-ins of you run the device 24/7...
This example assumes that you have cloned the application into the home directory of the user pi
- if you did not please adjust every path where /home/pi/simple-usb-checker/
is mentioned accordingly!
If you want to autostart the application every time the Raspberry starts follow these steps:
-
Open the autostart file with an editor, e.g. nano:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
-
Add the following line at the end of the file:
@/home/pi/simple-usb-checker/node_modules/electron/dist/electron /home/pi/simple-usb-checker/
-
Save the changes and exit the editor
-
Restart the Raspberry
You may want to protect the system and make if fully read-only (so that any changes done by any Bad USB devices or malware are reverted once you reboot).