feat: implement modular foundation and core system services
- Update flake.nix with 25.11 release and core inputs - Add dedicated modules for audio (Pipewire), bluetooth, and networking - Update GEMINI.md with the new Modular Merging Architecture blueprint - Configure graphical installer ISO and test VM outputs
This commit is contained in:
@@ -1,50 +1,56 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Cycles through the background images available
|
||||
# Cycles through the background images available for the current theme.
|
||||
# Declarative + Hybrid (instant swww) for Nomarchy NixOS.
|
||||
|
||||
THEME_NAME=$(cat "$HOME/.config/nomarchy/current/theme.name" 2>/dev/null)
|
||||
THEME_BACKGROUNDS_PATH="$HOME/.config/nomarchy/current/theme/backgrounds/"
|
||||
USER_BACKGROUNDS_PATH="$HOME/.config/nomarchy/backgrounds/$THEME_NAME/"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.config/nomarchy/current/background"
|
||||
STATE_DIR="$HOME/.config/home-manager"
|
||||
THEME_STATE_FILE="$STATE_DIR/theme-state.nix"
|
||||
WALLPAPER_STATE_FILE="$STATE_DIR/wallpaper-state.nix"
|
||||
|
||||
mapfile -d '' -t BACKGROUNDS < <(find -L "$USER_BACKGROUNDS_PATH" "$THEME_BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
|
||||
THEME_NAME=$(cat "$THEME_STATE_FILE" 2>/dev/null || echo "dracula")
|
||||
|
||||
if [ -d "/etc/nixos/nomarchy/themes" ]; then
|
||||
THEMES_DIR="/etc/nixos/nomarchy/themes"
|
||||
elif [ -d "/etc/nomarchy/themes" ]; then
|
||||
THEMES_DIR="/etc/nomarchy/themes"
|
||||
else
|
||||
THEMES_DIR="/etc/nixos/themes"
|
||||
fi
|
||||
|
||||
BG_DIR="$THEMES_DIR/$THEME_NAME/backgrounds"
|
||||
|
||||
if [ ! -d "$BG_DIR" ]; then
|
||||
notify-send "No background directory found for theme $THEME_NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t BACKGROUNDS < <(ls "$BG_DIR" | sort)
|
||||
TOTAL=${#BACKGROUNDS[@]}
|
||||
|
||||
if (( TOTAL == 0 )); then
|
||||
notify-send "No background was found for theme" -t 2000
|
||||
pkill -x swaybg
|
||||
setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 &
|
||||
else
|
||||
# Get current background from symlink
|
||||
if [[ -L $CURRENT_BACKGROUND_LINK ]]; then
|
||||
CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
|
||||
else
|
||||
# Default to first background if no symlink exists
|
||||
CURRENT_BACKGROUND=""
|
||||
fi
|
||||
|
||||
# Find current background index
|
||||
INDEX=-1
|
||||
for i in "${!BACKGROUNDS[@]}"; do
|
||||
if [[ ${BACKGROUNDS[$i]} == $CURRENT_BACKGROUND ]]; then
|
||||
INDEX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Get next background (wrap around)
|
||||
if (( INDEX == -1 )); then
|
||||
# Use the first background when no match was found
|
||||
NEW_BACKGROUND="${BACKGROUNDS[0]}"
|
||||
else
|
||||
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
||||
NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
|
||||
fi
|
||||
|
||||
# Set new background symlink
|
||||
ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
|
||||
|
||||
# Relaunch swaybg
|
||||
pkill -x swaybg
|
||||
setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
|
||||
notify-send "No backgrounds found in $BG_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CURRENT_BG=$(cat "$WALLPAPER_STATE_FILE" 2>/dev/null)
|
||||
INDEX=-1
|
||||
for i in "${!BACKGROUNDS[@]}"; do
|
||||
if [[ "$BG_DIR/${BACKGROUNDS[$i]}" == "$CURRENT_BG" ]]; then
|
||||
INDEX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
||||
NEW_BG="$BG_DIR/${BACKGROUNDS[$NEXT_INDEX]}"
|
||||
|
||||
echo "$NEW_BG" > "$WALLPAPER_STATE_FILE"
|
||||
|
||||
# Instant feedback via swww
|
||||
if pgrep -x swww-daemon >/dev/null; then
|
||||
swww img "$NEW_BG" --transition-type outer --transition-pos 0.85,0.97 --transition-step 90
|
||||
else
|
||||
swww init && swww img "$NEW_BG"
|
||||
fi
|
||||
|
||||
echo "Background set to $NEW_BG declaratively."
|
||||
|
||||
Reference in New Issue
Block a user