Promote shell to its own top-level directory

This commit is contained in:
David Heinemeier Hansson
2026-05-18 14:56:59 +02:00
parent d782705878
commit 0fe985b45d
83 changed files with 50 additions and 28 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
image_dirs=${1:-}
cache_dir=${XDG_CACHE_HOME:-$HOME/.cache}/omarchy/image-selector
index_file="$cache_dir/index.tsv"
mkdir -p "$cache_dir"
thumbnail_for() {
local image="$1"
local signature hash thumbnail legacy_hash
signature=$(stat -Lc '%s:%Y' "$image") || return
hash=$(awk -F '\t' -v path="$image" -v sig="$signature" '$1 == path && $2 == sig { print $3; exit }' "$index_file" 2>/dev/null)
if [[ -z $hash ]]; then
hash=$(printf '%s\t%s' "$image" "$signature" | md5sum | cut -d ' ' -f 1)
fi
thumbnail="$cache_dir/$hash.jpg"
if [[ ! -f $thumbnail ]]; then
# Older on-demand picker code keyed fallback thumbnails by file content.
# Keep finding those if a user still has them cached.
legacy_hash=$(md5sum "$image" 2>/dev/null | cut -d ' ' -f 1)
[[ -n $legacy_hash && -f $cache_dir/$legacy_hash.jpg ]] && thumbnail="$cache_dir/$legacy_hash.jpg"
fi
if [[ -f $thumbnail ]]; then
printf '%s' "$thumbnail"
else
printf '%s' "$image"
fi
}
while IFS= read -r dir; do
[[ -n $dir && -d $dir ]] || continue
find -L "$dir" -maxdepth 1 -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.bmp' -o -iname '*.webp' \) \
-print0 2>/dev/null
done <<<"$image_dirs" | sort -z | while IFS= read -r -d '' image; do
thumbnail=$(thumbnail_for "$image")
[[ -n $thumbnail ]] || continue
printf '%s\t%s\n' "$image" "$thumbnail"
done
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
if pgrep -x hypridle >/dev/null; then
echo '{"text": ""}'
else
echo '{"text": "󱫖", "tooltip": "Idle lock disabled", "class": "active"}'
fi
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
state=$(omarchy-shell notifications isDnd 2>/dev/null || echo off)
if [[ $state == "on" ]]; then
echo '{"text": "󰂛", "tooltip": "Notifications silenced", "class": "active"}'
else
echo '{"text": ""}'
fi
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
if pgrep -f "^gpu-screen-recorder" >/dev/null; then
echo '{"text": "󰻂", "tooltip": "Stop recording", "class": "active"}'
else
echo '{"text": ""}'
fi
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
icon=$(omarchy-weather-icon 2>/dev/null)
if [[ -n $icon ]]; then
icon=$(printf '%s' "$icon" | sed 's/["\\]/\\&/g')
printf '{"text":"%s"}\n' "$icon"
else
printf '{"text":"","class":"unavailable"}\n'
fi