updated app icon script

This commit is contained in:
Honney
2026-06-08 19:48:59 +02:00
parent b9e57ce208
commit 24eeb0bb32
+53 -9
View File
@@ -6,6 +6,10 @@ if [[ -z "$ID" ]]; then
echo "Usage: $0 Number"
exit 1
fi
# =========================
# ICON MAP (ADD YOUR TABLE HERE)
# =========================
# Command Helper: hyprctl clients -j | jq '.[] | select(.workspace.id == 1)'
# Icons: https://www.nerdfonts.com/cheat-sheet
declare -A MAP=(
@@ -49,9 +53,9 @@ declare -A MAP=(
# App Store
["Octopi"]="󰒚"
# Games
["steam"]=""
["steam*"]=""
["org.prismlauncher.PrismLauncher"]="󰍳"
["Minecraft* 1.21.11"]="󰍳"
["Minecraft*"]="󰍳"
["game"]=""
# Digital Arts
["Blender"]=""
@@ -123,8 +127,38 @@ declare -A MAP=(
["LightBurn"]="󱇣"
)
# =========================
# COLLECT HYPRLAND CLIENTS
# =========================
to_lower() {
echo "${1,,}"
}
match_map() {
local input
input="$(to_lower "$1")"
for key in "${!MAP[@]}"; do
local pattern
pattern="$(to_lower "$key")"
# wildcard + glob match
if [[ "$input" == $pattern ]]; then
echo "${MAP[$key]}"
return 0
fi
done
return 1
}
# APPS=$(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $ID) | .initialTitle")
# =========================
# COLLECT HYPRLAND CLIENTS
# =========================
mapfile -t APPS < <(
hyprctl clients -j |
jq -r ".[] | select(.workspace.id == $ID) | .initialTitle"
@@ -135,19 +169,29 @@ mapfile -t APPS_CLASS < <(
jq -r ".[] | select(.workspace.id == $ID) | .initialClass"
)
# =========================
# MAP ICONS
# =========================
for i in "${!APPS[@]}"; do
if [[ -n "${MAP["${APPS[$i]}"]}" ]]; then
APPS[$i]="${MAP["${APPS[$i]}"]}"
elif [[ -n "${MAP["${APPS_CLASS[$i]}"]}" ]]; then
APPS[$i]="${MAP["${APPS_CLASS[$i]}"]}"
icon=""
icon="$(match_map "${APPS[$i]}")"
if [[ -z "$icon" ]]; then
icon="$(match_map "${APPS_CLASS[$i]}")"
fi
if [[ -n "$icon" ]]; then
APPS[$i]="$icon"
else
APPS[$i]="${APPS_CLASS[$i]}|${APPS[$i]}"
fi
done
# for app in "${APPS[@]}"; do
# echo "$app"
# done
# =========================
# OUTPUT
# =========================
RESULT="$(printf '%s' "${APPS[@]}")"
# RESULT=${RESULT% } # remove trailing space