Migrate dotfiles to Omarchy 4
Claude-Session: https://claude.ai/code/session_014ADhvRXuiTvrXSbConxUey
This commit is contained in:
+13
-19
@@ -1,13 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Configuration files to modify
|
||||
ACTIVE_CONF="$HOME/.config/hypr/looknfeel.conf"
|
||||
REPO_CONF="$HOME/Documents/dotfiles/hypr/looknfeel.conf"
|
||||
# Window transparency toggle. Omarchy's toggles directory is loaded after
|
||||
# ~/.config/hypr/looknfeel.lua, so dropping a flag file here re-enables the
|
||||
# default translucency that looknfeel.lua overrides away.
|
||||
|
||||
# The rule to enforce solid opacity
|
||||
OVERRIDE_RULE="windowrule = opacity 1.0 override 1.0 override, match:tag default-opacity"
|
||||
# A marker comment
|
||||
MARKER="# Remove default window transparency"
|
||||
FLAG_FILE="$HOME/.local/state/omarchy/toggles/hypr/blob-glass.lua"
|
||||
|
||||
ACTION=$1
|
||||
|
||||
@@ -16,19 +13,16 @@ if [ -z "$ACTION" ]; then
|
||||
fi
|
||||
|
||||
enable_glass() {
|
||||
# Remove the rules
|
||||
sed -i "/$MARKER/d" "$ACTIVE_CONF" "$REPO_CONF" 2>/dev/null
|
||||
sed -i "/opacity 1.0 override/d" "$ACTIVE_CONF" "$REPO_CONF" 2>/dev/null
|
||||
mkdir -p "$(dirname "$FLAG_FILE")"
|
||||
cat > "$FLAG_FILE" <<'LUA'
|
||||
o.window({ tag = "default-opacity" }, { opacity = "0.985 0.96" })
|
||||
LUA
|
||||
echo "Transparency enabled (glass on)."
|
||||
hyprctl reload >/dev/null
|
||||
}
|
||||
|
||||
disable_glass() {
|
||||
# Add the rules if they don't exist
|
||||
if ! grep -q "opacity 1.0 override" "$ACTIVE_CONF"; then
|
||||
echo -e "\n$MARKER\n$OVERRIDE_RULE" >> "$ACTIVE_CONF"
|
||||
echo -e "\n$MARKER\n$OVERRIDE_RULE" >> "$REPO_CONF"
|
||||
fi
|
||||
rm -f "$FLAG_FILE"
|
||||
echo "Transparency disabled (glass off)."
|
||||
hyprctl reload >/dev/null
|
||||
}
|
||||
@@ -38,12 +32,12 @@ if [ "$ACTION" == "on" ]; then
|
||||
elif [ "$ACTION" == "off" ]; then
|
||||
disable_glass
|
||||
elif [ "$ACTION" == "toggle" ]; then
|
||||
if grep -q "opacity 1.0 override" "$ACTIVE_CONF"; then
|
||||
enable_glass
|
||||
else
|
||||
if [ -f "$FLAG_FILE" ]; then
|
||||
disable_glass
|
||||
else
|
||||
enable_glass
|
||||
fi
|
||||
else
|
||||
echo "Usage: blob_glass [on|off|toggle]"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Regular → Executable
+37
-4
@@ -6,7 +6,7 @@
|
||||
|
||||
THEME_DIR="$HOME/.config/omarchy/themes/blob-dynamic"
|
||||
USER_THEMES_DIR="$HOME/.config/omarchy/themes"
|
||||
CURRENT_DIR="$HOME/.config/omarchy/current"
|
||||
CURRENT_DIR="$HOME/.local/state/omarchy/current"
|
||||
|
||||
# Used only when a bare id is passed instead of a full share link.
|
||||
# Override with: export BLOB_THEME_URL="https://your-deployment.vercel.app"
|
||||
@@ -16,6 +16,10 @@ slugify() {
|
||||
echo "$1" | tr '[:upper:]' '[:lower:]' | tr ' ' '-'
|
||||
}
|
||||
|
||||
prettify() {
|
||||
echo "$1" | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g'
|
||||
}
|
||||
|
||||
current_mode() {
|
||||
local name
|
||||
name=$(cat "$CURRENT_DIR/theme.name" 2>/dev/null)
|
||||
@@ -32,6 +36,30 @@ theme_exists_locally() {
|
||||
[ -d "$USER_THEMES_DIR/$slug" ] || [ -d "$OMARCHY_PATH/themes/$slug" ]
|
||||
}
|
||||
|
||||
# Rows for omarchy-menu-select, as "<label><TAB><slug>". The menu returns the
|
||||
# label and the subtext, so the slug comes back as a stable key.
|
||||
list_theme_rows() {
|
||||
printf 'Dynamic (from wallpaper)\tblob-dynamic\n'
|
||||
|
||||
{
|
||||
find "$USER_THEMES_DIR" -mindepth 1 -maxdepth 1 -type d 2>/dev/null
|
||||
find "$OMARCHY_PATH/themes" -mindepth 1 -maxdepth 1 -type d 2>/dev/null
|
||||
} | while read -r theme_dir; do
|
||||
[ -f "$theme_dir/colors.toml" ] || continue
|
||||
slug=$(basename "$theme_dir")
|
||||
[ "$slug" = "blob-dynamic" ] && continue
|
||||
printf '%s\t%s\n' "$(prettify "$slug")" "$slug"
|
||||
done | sort -u -t$'\t' -k2,2
|
||||
}
|
||||
|
||||
select_theme() {
|
||||
local selection slug
|
||||
selection=$(list_theme_rows | omarchy-menu-select "Select Theme" -- --width 800) || return 1
|
||||
slug=$(printf '%s' "$selection" | cut -f2)
|
||||
[ -n "$slug" ] || return 1
|
||||
echo "$slug"
|
||||
}
|
||||
|
||||
apply_static() {
|
||||
local name="$1"
|
||||
# Clean up a lingering gif-animation daemon from a previous dynamic
|
||||
@@ -55,7 +83,12 @@ case "$1" in
|
||||
ags toggle theme-picker
|
||||
;;
|
||||
--menu)
|
||||
omarchy-launch-walker -m menus:blobThemeSelector --width 800 --minheight 400 -p "Select Theme…"
|
||||
selected=$(select_theme) || exit 0
|
||||
if [ "$selected" = "blob-dynamic" ]; then
|
||||
apply_dynamic
|
||||
else
|
||||
apply_static "$selected"
|
||||
fi
|
||||
;;
|
||||
--mode)
|
||||
current_mode
|
||||
@@ -69,7 +102,7 @@ case "$1" in
|
||||
# awk always terminates the last line with a newline, even if the
|
||||
# source file doesn't. Omarchy's template engine reads colors.toml
|
||||
# with a bash `while read` loop, which silently drops a final line
|
||||
# missing its newline (e.g. color15) — some built-in themes are
|
||||
# missing its newline (e.g. color15) - some built-in themes are
|
||||
# missing it too, so this guards every theme saved via --print.
|
||||
awk '1' "$CURRENT_COLORS"
|
||||
;;
|
||||
@@ -124,7 +157,7 @@ return {
|
||||
}
|
||||
EOF
|
||||
|
||||
# Apply the Blob-Dynamic theme (reloads waybar, ags, etc.)
|
||||
# Apply the Blob-Dynamic theme (reloads the Omarchy shell, ags, etc.)
|
||||
omarchy-theme-set "blob-dynamic"
|
||||
|
||||
echo "Applied shared theme to blob-dynamic."
|
||||
|
||||
+34
-17
@@ -2,6 +2,7 @@
|
||||
|
||||
WALLPAPER_DIR="$HOME/wallpapers"
|
||||
THEME_DIR="$HOME/.config/omarchy/themes/blob-dynamic"
|
||||
CURRENT_DIR="$HOME/.local/state/omarchy/current"
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
mkdir -p "$WALLPAPER_DIR"
|
||||
@@ -15,14 +16,28 @@ mkdir -p "$THEME_DIR/backgrounds"
|
||||
echo "PATH=$PATH"
|
||||
} >> "$HOME/.cache/blob-wallpaper.log"
|
||||
|
||||
# Rows for omarchy-menu-select, as "<label><TAB><path>". The menu returns the
|
||||
# label and the subtext, so the full path comes back as a stable key.
|
||||
list_wallpaper_rows() {
|
||||
find "$WALLPAPER_DIR" -maxdepth 1 -type f \
|
||||
\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.bmp' -o -iname '*.webp' \) \
|
||||
2>/dev/null | sort | while read -r background; do
|
||||
name=$(basename "$background")
|
||||
label=$(echo "${name%.*}" | sed -E 's/^[0-9]+//; s/^[-_]//; s/[-_]/ /g; s/(^| )([a-z])/\1\u\2/g')
|
||||
printf '%s\t%s\n' "$label" "$background"
|
||||
done
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
# Open the AGS wallpaper selector widget
|
||||
ags toggle wall-picker
|
||||
exit 0
|
||||
elif [ "$1" = "--menu" ]; then
|
||||
# Fallback: walker dmenu selection
|
||||
omarchy-launch-walker -m menus:blobBackgroundSelector --width 800 --minheight 400 -p "Select Wallpaper…"
|
||||
exit 0
|
||||
selection=$(list_wallpaper_rows | omarchy-menu-select "Select Wallpaper" -- --width 800) || exit 0
|
||||
IMAGE_PATH=$(printf '%s' "$selection" | cut -f2)
|
||||
if [ -z "$IMAGE_PATH" ] || [ ! -f "$IMAGE_PATH" ]; then
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# Check if the argument is a file in the wallpapers directory
|
||||
if [ -f "$WALLPAPER_DIR/$1" ]; then
|
||||
@@ -88,43 +103,45 @@ EOF
|
||||
# Only switch the active color theme to blob-dynamic if you're already
|
||||
# in dynamic mode. The palette above and the background below are kept
|
||||
# up to date regardless, so `blob_theme --dynamic` always reflects the
|
||||
# latest wallpaper — but picking a wallpaper while on a static theme
|
||||
# latest wallpaper - but picking a wallpaper while on a static theme
|
||||
# should change the wallpaper, not silently pull you out of it.
|
||||
#
|
||||
# When it does apply, skip omarchy-theme-set's own background step: it
|
||||
# launches swaybg asynchronously, which races with the gif handling
|
||||
# below and can leave a static swaybg frame on top of an animated gif.
|
||||
CURRENT_THEME_NAME=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
|
||||
# picks a background out of the theme folder and runs its own transition,
|
||||
# which would race with the background handling below.
|
||||
CURRENT_THEME_NAME=$(cat "$CURRENT_DIR/theme.name" 2>/dev/null)
|
||||
if [ "$CURRENT_THEME_NAME" = "blob-dynamic" ]; then
|
||||
OMARCHY_THEME_SKIP_BACKGROUND=1 omarchy-theme-set "blob-dynamic"
|
||||
fi
|
||||
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
|
||||
ln -nsf "$THEME_DIR/backgrounds/$(basename "$IMAGE_PATH")" "$CURRENT_BACKGROUND_LINK"
|
||||
NEW_BACKGROUND="$THEME_DIR/backgrounds/$(basename "$IMAGE_PATH")"
|
||||
|
||||
# Stop whichever daemon was previously rendering the background before
|
||||
# starting the one this wallpaper needs. `awww kill` shuts the daemon down
|
||||
# via its own IPC so it cleans up its socket, unlike a raw `pkill`.
|
||||
pkill -x swaybg 2>/dev/null
|
||||
# Stop a gif daemon left over from a previous wallpaper. `awww kill` shuts the
|
||||
# daemon down via its own IPC so it cleans up its socket, unlike a raw `pkill`.
|
||||
awww kill --all >/dev/null 2>&1
|
||||
pkill -x awww-daemon 2>/dev/null
|
||||
|
||||
# omarchy-theme-bg-set updates ~/.local/state/omarchy/current/background and
|
||||
# tells the running Omarchy shell to repaint, which is what draws the desktop
|
||||
# background in Omarchy 4 (swaybg is no longer involved).
|
||||
omarchy-theme-bg-set "$NEW_BACKGROUND"
|
||||
|
||||
if [[ "${IMAGE_PATH,,}" == *.gif ]]; then
|
||||
# The shell renders a still frame from the symlink above; awww layers the
|
||||
# animation on top of it.
|
||||
echo "GIF detected, using awww for animation..."
|
||||
setsid uwsm-app -- awww-daemon >>"$HOME/.cache/awww-daemon.log" 2>&1 &
|
||||
|
||||
# Poll until the daemon's IPC socket is ready instead of guessing a fixed sleep
|
||||
IMG_ERROR=""
|
||||
for _ in {1..15}; do
|
||||
IMG_ERROR=$(awww img "$CURRENT_BACKGROUND_LINK" 2>&1) && break
|
||||
IMG_ERROR=$(awww img "$NEW_BACKGROUND" 2>&1) && break
|
||||
sleep 0.3
|
||||
done
|
||||
if [[ -n "$IMG_ERROR" ]]; then
|
||||
echo "awww failed to set the wallpaper: $IMG_ERROR"
|
||||
echo "See $HOME/.cache/awww-daemon.log for daemon output."
|
||||
fi
|
||||
else
|
||||
setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
echo "Wallpaper and dynamic theme applied successfully: $IMAGE_PATH"
|
||||
echo "Wallpaper and dynamic theme applied successfully: $IMAGE_PATH"
|
||||
|
||||
Reference in New Issue
Block a user