Compare commits

..
2 Commits
Author SHA1 Message Date
Daniele Fucini ffe2039de5 Clean downloaded sources from AUR clones after aurs
After a successful sync, aurb runs git clean -fx in each clone under the aurutils sync folder, removing downloaded sources and build logs while keeping tracked files and VCS source folders.
2026-10-24 22:17:23 +02:00
Daniele Fucini 638f7e3dd9 Run discover-overlay-wait as a user unit and rework the vidthumb cache
vidthumb names thumbnails by a hash of path, size and mtime instead of a jq index that broke on quotes in filenames; systemd-tmpfiles removes ones unused for 30 days. discover-overlay-wait now runs from a systemd user unit started by xmonad and logs to the journal.
2026-10-24 22:08:49 +02:00
6 changed files with 45 additions and 30 deletions

No files matched your search

@@ -0,0 +1,7 @@
[Unit]
Description=Run discover-overlay while Discord is running
[Service]
ExecStart=%h/.local/bin/discover-overlay-wait
Restart=on-failure
RestartSec=5
+2
View File
@@ -0,0 +1,2 @@
# Remove vidthumb thumbnails (and leftover temp files) not used for 30 days; %C is $XDG_CACHE_HOME.
e %C/vidthumb - - - 30d
+1 -1
View File
@@ -274,7 +274,7 @@ myStartupHook = do
spawnOnce "numlockx"
spawnOnce "blueman-applet"
spawnOnce "adb start-server"
spawnOnce "/home/fuxino/.local/bin/discover-overlay-wait"
spawnOnce "systemctl --user start discover-overlay-wait"
-- Manage hook
myManageHook :: ManageHook
+10
View File
@@ -31,3 +31,13 @@ aur "$cmd" \
--bind-rw "$THINLTO_HOST_DIR" \
--bind "$HOME/.config/aurb" \
"${args[@]}"
status=$?
# After a successful sync, drop downloaded sources and logs from the AUR clones. Without -d,
# git clean keeps untracked directories, so VCS sources (bare clones) survive.
if [[ $cmd == sync && $status -eq 0 ]]; then
for clone in "${AURDEST:-${XDG_CACHE_HOME:-$HOME/.cache}/aurutils/sync}"/*/; do
[[ -d $clone.git ]] && git -C "$clone" clean -fxq
done
fi
exit "$status"
+4 -1
View File
@@ -1,4 +1,7 @@
#!/bin/sh
# Runs discover-overlay while Discord's RPC port is up and stops it when Discord exits.
# Run by discover-overlay-wait.service (started from xmonad); output goes to the journal.
port_up() {
ss -ltn | grep -qE '127\.0\.0\.1:64[67][0-9]'
}
@@ -8,7 +11,7 @@ while true; do
sleep 5
port_up || continue # port vanished again, Discord was still restarting
discover-overlay >> /tmp/discover-overlay.log 2>&1 &
discover-overlay &
pid=$!
while port_up && kill -0 "$pid" 2>/dev/null; do sleep 3; done
+21 -28
View File
@@ -1,36 +1,29 @@
#!/usr/bin/env bash
#!/bin/bash
# Prints a cached thumbnail for the video in $1 (used by the lf preview), creating it if needed.
# Thumbnails are named by a hash of path, size and mtime, so a changed file gets a new one.
# Hits touch the file; systemd-tmpfiles (~/.config/user-tmpfiles.d/vidthumb.conf) removes unused ones.
if ! [ -f "$1" ]; then
exit 1
fi
[[ -f $1 ]] || exit 1
cache="$HOME/.cache/vidthumb"
index="$cache/index.json"
movie="$(realpath "$1")"
cache="${XDG_CACHE_HOME:-$HOME/.cache}/vidthumb"
video=$(realpath -- "$1") || exit 1
stamp=$(stat -c '%s.%Y' -- "$video") || exit 1
key=$(printf '%s\0%s' "$video" "$stamp" | sha256sum)
thumb="$cache/${key%% *}.jpg"
mkdir -p "$cache"
if [ -f "$index" ]; then
thumbnail="$(jq -r ". \"$movie\"" <"$index")"
if [[ "$thumbnail" != "null" ]]; then
if [[ ! -f "$cache/$thumbnail" ]]; then
exit 1
fi
echo "$cache/$thumbnail"
if [[ -s $thumb ]]; then
touch -- "$thumb"
printf '%s\n' "$thumb"
exit 0
fi
fi
thumbnail="$(uuidgen).jpg"
if ! ffmpegthumbnailer -i "$movie" -o "$cache/$thumbnail" -s 0 2>/dev/null; then
mkdir -p -- "$cache" || exit 1
# Write to a temp file first, so an interrupted or concurrent run never leaves a broken thumbnail.
tmp=$(mktemp --suffix=.jpg "$cache/.tmp.XXXXXX") || exit 1
if ffmpegthumbnailer -i "$video" -o "$tmp" -s 0 2> /dev/null && [[ -s $tmp ]]; then
mv -f -- "$tmp" "$thumb"
printf '%s\n' "$thumb"
else
rm -f -- "$tmp"
exit 1
fi
if [[ ! -f "$index" ]]; then
echo "{\"$movie\": \"$thumbnail\"}" >"$index"
fi
json="$(jq -r --arg "$movie" "$thumbnail" ". + {\"$movie\": \"$thumbnail\"}" <"$index")"
echo "$json" >"$index"
echo "$cache/$thumbnail"