diff options
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -15,7 +15,6 @@ set -euo pipefail repo="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" target="$HOME/.config/waybar-udt" udt="$(cd "$repo/../unified-desktop-theme" 2>/dev/null && pwd || true)" -icons="$HOME/.local/share/icons/Material-Black-Plum-Suru" mkdir -p "$target/modules/hyprland" "$target/modules/custom" \ "$target/modules/extras" "$target/modules/image" \ @@ -96,7 +95,7 @@ for f in modules/clock.jsonc \ modules/custom/vmdot.jsonc modules/custom/privacy_dots.jsonc \ modules/custom/presentation.jsonc modules/custom/mail.jsonc \ modules/custom/launcher.jsonc \ - modules/extras/taskbar.jsonc modules/extras/tray.jsonc \ + modules/extras/tray.jsonc \ modules/image/volume.jsonc modules/image/language.jsonc; do ln -sfn "$repo/$f" "$target/$f" done @@ -105,11 +104,37 @@ for f in style.css fonts.css global.css pills.css; do ln -sfn "$repo/styles/$f" "$target/styles/$f" done -# modules.css is generated rather than linked: it carries the icon theme's -# absolute path, which cannot be committed, and the accent-tinted launcher. -sed -e "s|@ICONS@|$icons|g" -e "s|@CONFIG@|$target|g" \ +# modules.css is generated rather than linked: it carries absolute icon paths, +# which cannot be committed, and the accent-tinted launcher. +# +# Each @ICON:name@ is resolved by wb-icon, which reads the desktop's icon theme +# from gsettings. Resolving per name rather than substituting one directory is +# what makes a theme switch work at all: themes disagree about both the +# subdirectory and the file extension (Suru keeps web-browser at +# categories/22/*.svg, elementary-xfce at apps/22/*.png), so only a real icon +# lookup knows the path. An unresolved name is left as-is and reported; the +# selftest below is what turns that into a failed install. +sed -e "s|@CONFIG@|$target|g" \ "$repo/styles/modules.css" > "$target/styles/modules.css" +for name in $(grep -o '@ICON:[a-z0-9-]*@' "$target/styles/modules.css" \ + | sed 's/@ICON:\(.*\)@/\1/' | sort -u); do + if path="$("$repo/bin/wb-icon" --path "$name")"; then + sed -i "s|@ICON:$name@|$path|g" "$target/styles/modules.css" + else + echo "warning: no icon named '$name' in the current icon theme" >&2 + fi +done + +# taskbar.jsonc names the icon theme, which is gsettings' to say, so it is +# generated for the same reason modules.css is. Every other module is a symlink. +# An earlier install symlinked this file into the repo. Writing through that +# link would overwrite the committed source with a generated copy, so the link +# is removed first; the redirect below then creates a real file. +rm -f "$target/modules/extras/taskbar.jsonc" +sed "s|@ICON_THEME@|$("$repo/bin/wb-icon" --theme)|g" \ + "$repo/modules/extras/taskbar.jsonc" > "$target/modules/extras/taskbar.jsonc" + # The launcher module carries no generated path any more: its mark is a CSS # background, so modules.css owns the paths and the module file is a plain # symlink like every other. @@ -149,7 +174,9 @@ ln -sfn "$repo/bin/wb-lang" "$HOME/bin/wb-lang" # ----------------------------------------------------------------- checks -- # A missing icon renders as an empty pill and nothing says why, so the names -# are checked here, while someone is watching. +# are checked here, while someone is watching. The theme is whatever gsettings +# says, so this also catches a switch to a theme that lacks one of these names. +echo "icon theme: $("$repo/bin/wb-icon" --theme)" "$repo/bin/wb-icon" --selftest echo |
