From 28ea0e3cbe1c0f980a05d6fb13a428bcab2ea1c5 Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Fri, 13 Jun 2025 08:37:31 +0530 Subject: neovim updates --- .local/bin/background-cleanup | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 .local/bin/background-cleanup (limited to '.local/bin/background-cleanup') diff --git a/.local/bin/background-cleanup b/.local/bin/background-cleanup new file mode 100755 index 0000000..c61caec --- /dev/null +++ b/.local/bin/background-cleanup @@ -0,0 +1,27 @@ +#!/bin/sh + +[ -z "$CD_HISTFILE" ] && + export CD_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/cd_history" + +[ -z "$OPEN_HISTFILE" ] && + export OPEN_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/open_history" + +on_ac_power() { [ "$(cat /sys/class/power_supply/ACAD/online)" = 1 ]; } + +sleep 10 +on_ac_power || echo "System not plugged to AC Adapter, waiting..." + +until on_ac_power; do + sleep 10m +done + +echo "[cleanup] Cleaning $CD_HISTFILE" +cleanup-history-file "$CD_HISTFILE" + +echo "[cleanup] Cleaning $OPEN_HISTFILE" +cleanup-history-file "$OPEN_HISTFILE" + +echo "[cleanup] Cleaning orphaned packages..." +pacman -Qtdq | xargs -r sudo pacman -Rns --noconfirm + +echo "[cleanup] Finished Cleaning." -- cgit v1.2.3