watch --color -n 0.5 "dmesg --color=always | tail -n 30"

KERNEL_VARIANT="$(uname -r | awk -F "-" '{print $NF}')"
KERNEL_VERSION="$(uname -r | sed -e "s/-${KERNEL_VARIANT}//")"

echo "Currently running: ${KERNEL_VERSION}-${KERNEL_VARIANT}"

ALL_VER="$(dpkg --list | grep -e linux-image -e linux-headers | grep -v -e linux-headers-${KERNEL_VARIANT} -e linux-image-${KERNEL_VARIANT} | awk '{print $3}' | sort -uV)"

echo "All installed:" ${ALL_VER}

NUM_INSTALLED="$(echo "${ALL_VER}" | wc -l)"

if [ ${NUM_INSTALLED} -lt 3 ]; then
    echo "2 or fewer kernel versions installed, quitting"

REMOVE_VER="$(echo "${ALL_VER}" | head -n ${NUM_TO_REMOVE})"
REMOVE_PACKAGES="$(dpkg --list | grep -e "${REMOVE_VER}" | grep -v libc | awk '{print $2}')"

echo "Removing:" ${REMOVE_PACKAGES}

sudo apt-get purge ${REMOVE_PACKAGES}

# would be nice: check that the current version is the most recent of installed versions.
#!/bin/bash -ex
sed -i 's/","/"\t"/g' $1
sed -i 's/<br \/>/\n/g' $1
sed -i 's/\&amp;/\&/g' $1
#!/bin/bash -x

iwconfig 2> /dev/null | grep --color=always "Power Management:"

TTLMOD=$(sudo iptables -t mangle -L POSTROUTING | grep TTL)

if [ -z "${TTLMOD}" ]; then
    sudo iptables -t mangle -A POSTROUTING -j TTL --ttl-set 65

exit 0
sudo sed -i 's/wifi.powersave = 3/wifi.powersave = 2/' /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
nmcli connection add ifname enp0s25 con-name StewNAT type ethernet ipv4.method shared ipv4.addresses ipv6.method shared
nmcli connection delete StewNAT
#!/bin/bash -ex

# Found this trick at:

cpupower frequency-info --policy
sudo cpupower frequency-set --max 2500000 --min 800000 --governor powersave
cpupower frequency-info --policy

xbacklight -set 25

# Seems like this is not necessary - no need to add processor.ignore_ppc=1 to kernel command line.

# Not sure if this is necessary: sudo apt install linux-tools-generic-hwe-16.04

# Probably not necessary:
# /etc/modprobe.d/lenovo-acpi.conf
# options thinkpad_acpi fan_control=1

# Other potentially relevant links:
curl -sL | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] any main" > /etc/apt/sources.list.d/atom.list'
sudo apt-get update
watch -n 0.2 'grep "cpu MHz" /proc/cpuinfo'