Change background setup to cycle

This commit is contained in:
David Heinemeier Hansson
2025-06-09 11:59:21 +02:00
parent 3a3be9e38f
commit a745ad0862
6 changed files with 27 additions and 11 deletions

22
bin/swaybg-next Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Cycles through the background images available
BACKGROUNDS_DIR="$HOME/.local/share/backgrounds"
NEXT_BACKGROUND_FILE="$HOME/.cache/next_background_index"
BACKGROUNDS=($(find "$BACKGROUNDS_DIR" -type f | sort))
TOTAL=${#BACKGROUNDS[@]}
if [[ ! -f "$NEXT_BACKGROUND_FILE" ]]; then
INDEX=0
else
INDEX=$(<"$NEXT_BACKGROUND_FILE")
fi
# Save next index (wrap around)
echo "$(( (INDEX + 1) % TOTAL ))" > "$NEXT_BACKGROUND_FILE"
# Launch swaybg
pkill -x swaybg
setsid swaybg -i "${BACKGROUNDS[$INDEX]}" -m fill >/dev/null 2>&1 &

View File

@ -19,15 +19,14 @@ bind = SUPER, M, exec, spotify
bind = SUPER, N, exec, alacritty -e nvim
bind = SUPER, T, exec, alacritty -e btop
bind = SUPER SHIFT, SPACE, exec, pkill -SIGUSR1 waybar
bind = SUPER CTRL, SPACE, exec, ~/.local/share/omarchy/bin/swaybg-next
# See https://wiki.hyprland.org/Configuring/Environment-variables/
source = ~/.local/share/omarchy/default/hypr/envs.conf
# Autostart necessary processes (like notifications daemons, status bars, etc.)
exec-once = hypridle & swaync & waybar
# Control backgrounds
source = ~/.local/share/omarchy/default/hypr/backgrounds.conf
exec-once = ~/.local/share/omarchy/bin/swaybg-next
#####################
### LOOK AND FEEL ###

View File

@ -8,5 +8,5 @@ HISTFILESIZE="${HISTSIZE}"
# source /usr/share/bash-completion/bash_completion
# Set complete path
export PATH="./bin:$HOME/.local/bin:$PATH"
export PATH="./bin:$HOME/.local/bin:$HOME/.local/share/omarchy/bin:$PATH"
set +h

View File

@ -1,4 +0,0 @@
# Set a random image from ~/.local/share/backgrounds as the background
# Picks another random background on SUPER + CTRL + SPACE
exec-once = swaybg -i $(find ~/.local/share/backgrounds/ -type f -print0 | shuf -zn1 | xargs -0 printf '%s\n')
bind = SUPER CTRL, SPACE, exec, pkill -x swaybg && setsid swaybg -i $(find ~/.local/share/backgrounds/ -type f -print0 | shuf -zn1 | xargs -0 printf '%s\n')

2
install/backgrounds.sh Normal file
View File

@ -0,0 +1,2 @@
gum spin --title "Downloading background image..." -- curl -sL -o ~/.local/share/backgrounds/Milad-Fakurian-Abstract-Purple-Blue.jpg https://images.unsplash.com/photo-1620207418302-439b387441b0
gum spin --title "Downloading background image..." -- curl -sL -o ~/.local/share/backgrounds/Pawel-Czerwinski-Abstract-Purple-Blue.jpg https://images.unsplash.com/photo-1651870364199-fc5f9f46ac85

View File

@ -1,5 +1,2 @@
# Prefer dark mode everything
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
# Download first background
curl -sL -o ~/.local/share/backgrounds/Milad-Fakurian-Abstract-Purple-Blue.jpg https://unsplash.com/photos/u8Jn2rzYIps/download?ixid=M3wxMjA3fDB8MXxzZWFyY2h8Mnx8YWJzdHJhY3QlMjB3YWxscGFwZXJ8ZW58MHx8fHwxNzQ5Mjc5ODk1fDA