aur/hamr.install
2025-12-20 16:36:55 +00:00

70 lines
2.6 KiB
Text

post_install() {
local config_dir="$HOME/.config/hamr"
local state_dir="$HOME/.local/state/quickshell/hamr"
mkdir -p "$config_dir"
mkdir -p "$state_dir"
if [ ! -f "$config_dir/colors.json" ]; then
cp /etc/xdg/quickshell/hamr/defaults/colors.json "$config_dir/colors.json"
fi
echo ""
echo "==> Hamr has been installed to /etc/xdg/quickshell/hamr"
echo ""
echo "==> To start hamr, run:"
echo " hamr"
echo ""
echo "==> User config and plugins: ~/.config/hamr/"
echo "==> Persistent state: ~/.local/state/quickshell/hamr/"
echo ""
echo "==> Color theme:"
echo " Edit ~/.config/hamr/colors.json directly, or"
echo " configure matugen/wallust to output to this path, or"
echo " symlink to your existing colors (e.g. for end-4/dots-hyprland):"
echo " ln -sf ~/.local/state/quickshell/user/generated/colors.json ~/.config/hamr/colors.json"
echo ""
echo "==> Add to your Hyprland config:"
echo " exec-once = hamr"
echo " bind = Ctrl, Space, global, quickshell:hamrToggle"
echo ""
}
post_upgrade() {
local config_file="$HOME/.config/hamr/hamr.json"
# Migrate: remove old prefix config if it matches system defaults
if [ -f "$config_file" ]; then
local default_prefix='{"action":"/","app":">","clipboard":";","emojis":":","file":"~","math":"=","shellCommand":"$","shellHistory":"!","webSearch":"?"}'
local current_prefix
current_prefix=$(jq -c '.search.prefix // empty' "$config_file" 2>/dev/null)
if [ -n "$current_prefix" ]; then
# Normalize both for comparison (sort keys)
local current_sorted
local default_sorted
current_sorted=$(echo "$current_prefix" | jq -cS '.' 2>/dev/null)
default_sorted=$(echo "$default_prefix" | jq -cS '.' 2>/dev/null)
if [ "$current_sorted" = "$default_sorted" ]; then
# Remove the old prefix config since it's the default
jq 'del(.search.prefix)' "$config_file" > "$config_file.tmp" && mv "$config_file.tmp" "$config_file"
echo "==> Migrated: removed default prefix config (now using actionBarHints)"
fi
fi
fi
echo ""
echo "==> Hamr has been upgraded."
echo "==> Restart quickshell to apply changes."
echo ""
}
post_remove() {
echo ""
echo "==> User data has been preserved. Remove manually if no longer needed:"
echo " rm -rf ~/.config/hamr"
echo " rm -rf ~/.local/state/quickshell/hamr"
echo ""
}