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" echo "Usage: $0 Number"
exit 1 exit 1
fi fi
# =========================
# ICON MAP (ADD YOUR TABLE HERE)
# =========================
# Command Helper: hyprctl clients -j | jq '.[] | select(.workspace.id == 1)' # Command Helper: hyprctl clients -j | jq '.[] | select(.workspace.id == 1)'
# Icons: https://www.nerdfonts.com/cheat-sheet # Icons: https://www.nerdfonts.com/cheat-sheet
declare -A MAP=( declare -A MAP=(
@@ -49,9 +53,9 @@ declare -A MAP=(
# App Store # App Store
["Octopi"]="󰒚" ["Octopi"]="󰒚"
# Games # Games
["steam"]="" ["steam*"]=""
["org.prismlauncher.PrismLauncher"]="󰍳" ["org.prismlauncher.PrismLauncher"]="󰍳"
["Minecraft* 1.21.11"]="󰍳" ["Minecraft*"]="󰍳"
["game"]="" ["game"]=""
# Digital Arts # Digital Arts
["Blender"]="" ["Blender"]=""
@@ -123,8 +127,38 @@ declare -A MAP=(
["LightBurn"]="󱇣" ["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") # APPS=$(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $ID) | .initialTitle")
# =========================
# COLLECT HYPRLAND CLIENTS
# =========================
mapfile -t APPS < <( mapfile -t APPS < <(
hyprctl clients -j | hyprctl clients -j |
jq -r ".[] | select(.workspace.id == $ID) | .initialTitle" jq -r ".[] | select(.workspace.id == $ID) | .initialTitle"
@@ -135,19 +169,29 @@ mapfile -t APPS_CLASS < <(
jq -r ".[] | select(.workspace.id == $ID) | .initialClass" jq -r ".[] | select(.workspace.id == $ID) | .initialClass"
) )
# =========================
# MAP ICONS
# =========================
for i in "${!APPS[@]}"; do for i in "${!APPS[@]}"; do
if [[ -n "${MAP["${APPS[$i]}"]}" ]]; then icon=""
APPS[$i]="${MAP["${APPS[$i]}"]}"
elif [[ -n "${MAP["${APPS_CLASS[$i]}"]}" ]]; then icon="$(match_map "${APPS[$i]}")"
APPS[$i]="${MAP["${APPS_CLASS[$i]}"]}"
if [[ -z "$icon" ]]; then
icon="$(match_map "${APPS_CLASS[$i]}")"
fi
if [[ -n "$icon" ]]; then
APPS[$i]="$icon"
else else
APPS[$i]="${APPS_CLASS[$i]}|${APPS[$i]}" APPS[$i]="${APPS_CLASS[$i]}|${APPS[$i]}"
fi fi
done done
# for app in "${APPS[@]}"; do # =========================
# echo "$app" # OUTPUT
# done # =========================
RESULT="$(printf '%s' "${APPS[@]}")" RESULT="$(printf '%s' "${APPS[@]}")"
# RESULT=${RESULT% } # remove trailing space # RESULT=${RESULT% } # remove trailing space