uniq_

Run script on NodeMCU to scan for WiFi

I've looked a bit further into using micro python on NodeMCU. I've got a tiny monochromatic SSD1306 OLED display connected to one of my ESP8266 based NodeMCU boards. It's only 128x64 pixels in size, but well supported by micro python. So I thought I'll give it a try and implemented a continous WiFI scanner, that's displaying SSIDs directly on the micro controllers display.

First of all I needed some tooling for uploading my python scripts to my micro controller.

pip install --break-system-packages microdeploy

Here's the WiFi scanner script I came up with ('main.py'):

from time import sleep
from machine import I2C
from ssd1306 import SSD1306_I2C
from network import WLAN, STA_IF

d = SSD1306_I2C(128, 64, I2C(sda=14, scl=12))

sta_if = WLAN(STA_IF)
while True:
    d.fill(0)
    d.text("scanning ...", 0, 0)
    d.show()

    scan_result = sta_if.scan()
    for i in range(len(scan_result)):
        d.fill(0)
        d.text("found WiFi:", 0, 0)
        d.text(scan_result[i][0], 0, 16)
        d.text("({}/{})".format(i+1, len(scan_result)+1), 0, 48)
        d.show()
        sleep(3)

Micro Python will automatically start a script called 'main.py' on boot. So all that's left to do is uploading the script to my micro controller:

microdeploy --port /dev/ttyUSB0 --baud 115200 device put ~/main.py main.py

Micro Python on NodeMCU

NodeMCU is a pretty cheap ESP8266 based WiFi capeable micro controller, with good open source support. I had one stowed away in a box for years. When I re-discovered it the other day I finally gave it a try. It's also supported by Micro Python so getting software running there is pretty effortless

I started by getting the latest version of micro python firmware for Node MCU. From: https://micropython.org/download/ESP8266_GENERIC/

wget https://micropython.org/resources/firmware/ESP8266_GENERIC-20240105-v1.22.1.bin

Next I needed to setup my Debian user to be allowed to open tty devices. Because NodeMCU (like many other micro controllers) uses serial.

# you need to re-login for this change to take effect
sudo adduser $USER dialout

Then I've connected the micro controller to my computer with USB. A good tool for inspecting USB devices is lsusb. The micro controller showed up as /dev/ttyUSB0 for me.

Next I needed to install esptool a script for flashing firmware to mirco controllers. It's not packaged for Debian, but it can be comfortably installed using pip. (pip is pythons package manager and is packaged for Debian sudo apt install python3-pip)

pip install esptool --break-system-packages

Now I we can proceed to flash the previously downloaded pre-compiled micro python firmware.

esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --flash_size=detect --flash_mode qio 0 ./ESP8266_GENERIC-20240105-v1.22.1.bin

(Side note: The manufacturer printed "use 9600 baud" on my board. However esptool runs into a timeout when the baud rate is too low. This was quite confusing to figure out ...)

Micro Python is installed now. To have some quick fun, we can use screen to connect to the micro controller and get an interactive python shell. For testing I've connected a LED to the pin labeled D1 (and G). Here's how to use an interactive shell to make it blink:

screen /dev/ttyUSB0 115200
>>> from time import sleep
>>> from machine import Pin
>>> p = Pin(5, Pin.OUT)
>>> while True:
...     p.value(1 - p.value())
...     sleep(0.5)
...

To interrupt the loop press [Ctrl+c], to quit the screen session press [Ctrl+a] [\] [y]

It was also easy to connect to my WiFi in the interactive shell by just following the instructions of micro pythons built in help().

Here are some docs I found helpful:

create .asc signatures with GPG

This command will make gpg read my.file and create a detached signature for it called my.file.asc. So you can use it to sign pretty much any file. I'm also explicitly specifying which key I'm using for signing. (1234...) Just in case I don't want to use my default signing key here.

gpg --armor --default-key 1234... --detach-sign my.file

This here demonstrates how I'm verifying the signature with gpg. This command assumes that my.file is located in the same directory as my.file.asc.

gpg --verify my.file.asc

customizing Gnome on Debian 12

Here's an update to my favorite Gnome exteions. This time around on Debian 12 (bookworm) with Gnome 40.

In Gnome settings:

  • Keyboard > View and Customize Settings > Navigation > Switch Applications: disabled
  • Keyboard > View and Customize Settings > Navigation > Swtich Windows: Alt+Tab
  • Multitasking > Application Switching: Include Applications from the current workspace only

Additional Gnome extensions:

  • AppIndicator and KStatusNotifierItem Support - IMHO the most important fix all Gnome users need. It adds a status icon area. Some apps I need to use are only accessible through a status icon. (nextcloud, nitrokey app, etc.) I've tried a lot of status icon area extensions over the years. This is the only one which doesn't bug out. Lucky break.
  • Current screen only on windows switcher - does exactly what the name sais. This way alt-tab is less confusing for me.
  • Frippery Move Clock - It's just easier on my eyes, when the clock is not cluttering up the center of my top bar.
  • gTile - This extension allows me to do arrange my windows using keyboard shortcuts instead of having to try hit the edges of windows with the mouse cursor and pull them to the exactly right size.
  • Impatience - Extension for scaling down animation durations. I'm trying to get some work done here. Watching pretty windows fly across the desktop is fun sometimes, but I'd rather navigate quickly.
  • Vitals - So far my favorite system monitor plugin. It's highly customizable and supports monitoring really a lot of things. You could use it to pin your secondary casing fan speed or your wifi chip temperature to gnomes top bar. I've only pinned the most basic things and still numbers it's tracking are 2 clicks away at most. It has proven itself very useful to me time and again.
  • Workspace Matrix - I use a lot of workspaces and prefer a vertical layout. This makes it feasible.

get Android debug signing key fingerprint

Here's how to retreive the SHA1 and SHA256 fingerprints for debug.keystore. That's what Android Studio / gradle is using to sign APKs for testing and debugging.

./gradlew signingReport

Alternatively, this is how to get the same fingerprints using javas keytool directly:

keytool -list -v \
    -keystore ~/.android/debug.keystore \
    -alias androiddebugkey \
    -storepass android -keypass android

This assumes that the standard debug keystore config wasn't changed.

Flash Samsung phone with LinageOS from a Debian computer.

This is not a complete guide, this just documents how I got things done. I'm using heimdall instead of Samsungs official odin tool. Follow the official Linage guide for your specific Samsung device from LinageOS wiki. There's what I ended up doing to get my phone flashed:

sudo apt install adb heimdall

# make sure phone is fully chared
# boot phone into fastboot mode
# connect phone with usb to my computer

heimdall flash --RECOVERY recovery.img

# boot phone into recovery mode
# do a fatory reset on the phone as discribed in the wiki in recovery
# start sideload mode in recovery

adb sideload Downloads/lineage-...-signed.zip

install vargarnt + libvirt + kvm on debian 11

I want to run vagrant up on Debian. However I don't want to install VirtualBox and use KVM instead. I kept forgetting which packages I need to install so here we go:

sudo apt install --no-install-recommends \
    bridge-utils \
    busybox \
    dnsmasq-base \
    ebtables \
    libguestfs-tools \
    libvirt-clients \
    libvirt-daemon \
    libvirt-daemon-system \
    netcat-openbsd \
    nfs-kernel-server \
    qemu-kvm \
    vagrant \
    vagrant-libvirt

I also had to add my user to the libvirt group to make it work smoothly:

sudo adduser $USER libvirt

Then all that's left is to start libvirt and maybe also tell systemd to start it on boot:

sudo systemctl start libvirtd.service
sudo systemctl enable libvirtd.service

That's it vagrant up --provider libvirt should work now.

On a side note: On rare occasion virt-manager is a quite handy tool for working with libvirt VMs. It's also in Debian an can be installed with apt.

use already set up gpg smart-card

When you've got an smart-card which is already set-up with your private key and you'd like to use it with gpg, here's how to get gpg to use it:

  1. make sure scdaemon is installed
  2. import your key gpg --import 1234...asc or fetch it from a key-server gpg --recv-key 1234...
  3. connect your smart card to your computer and run gpg --card-status
  4. check if the key is now available gpg --list-secret-keys

fav Gnome extensions

Gnome comes with hardly any customization options. For the vast majority of users this probably is a good thing. Personally I feel a lot more comfortable and efficient with a couple of customizations. To work efficiently I need to keep a vast amount of windows (~100 at peak times) open at the same time and switch between them with minimal effort.

Here's my current list of Gnome extensions that make using gnome a lot more tolerable for me. I'm running Gnome 3.38 right now and didn't really look into Gnome 40 yet.

  • AlternateTab - because trying to switch though grouped windows steals a lot of time and quite frankly makes me angry. So this is an easy but important UX fix.
  • AppIndicator and KStatusNotifierItem Support - IMHO the most important fix all Gnome users need. It adds a status icon area. Some apps I need to use are only accessible through their status icon. (nextcloud, nitrokey app, etc.) I've tried a lot of status icon area extensions over the years. This is the only one which doesn't bug out. Lucky break.
  • Audio Switcher - I've got a couple of audio sinks (like external sound cards on my docking station, various bluetooth devices) This make switching bewteen them considerably less annoying. It also add a handy microphone volume indicator, so I can always if my microphone is turned on.
  • Current screen only on windows switcher - does exactly what the name sais. This way alt-tab is less confusing for me.
  • Frippery Move Clock - It's just easier on my eyes, when the clock is not cluttering up the center of my top bar.
  • Impatience - Extension for scaling down animation durations. I'm trying to get some work done here. Watching pretty windows fly across the desktop is fun sometimes, but I'd rather navigate quickly.
  • Vitals - So far my favorite system monitor plugin. It's highly customizable and supports monitoring really a lot of things. You could use it to pin your secondary casing fan speed or your wifi chip temperature to gnomes top bar. I've only pinned the most basic things and still numbers it's tracking are 2 clicks away at most. It has proven itself very useful to me time and again.
  • Workspace Matrix - I use a lot of workspaces and prefer a vertical layout. This makes it feasible.

Disable Gnome 3 file previews

When browsing files in gnome 3 I occasionally hit the space bar by accident. Nautilus the file browser of gnome then tries to display a preview. This is pretty anoying to me for most files already. However when this happens on a video file, the preview feature is totally bugged. It will open a videoplayer which can not be closed again, because every time I close the preview window it will start another one.

It's quite amazing how gnome 3 manages to look good overall, but at the same time add flaws which make using it a genuine pita.

The file preview feature is shipped in a package calle gnome-sushi and I usually fixed my UX by just uninstalling it. On a recent Debian 11 install however removing that package with apt would have also removed gnome alotogether. So I just uninstalled it without touching any dependencies:

sudo dpkg --purge --force-depends gnome-sushi

Sofar it seems to work as expected. I'm not sure if updates will inflict this UX scurge upon me once more.