some changes (also have pretty fast hyprland animations now!)
This commit is contained in:
parent
44034ef61a
commit
fe875b3321
2 changed files with 96 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash --norc
|
#!/usr/bin/env bash
|
||||||
# ╭───────────────╮
|
# ╭───────────────╮
|
||||||
# │ SWWW-settings │
|
# │ SWWW-settings │
|
||||||
# ╰───────────────╯
|
# ╰───────────────╯
|
||||||
|
@ -17,70 +17,108 @@ export SWWW_TRANSITION=center
|
||||||
_swww() {
|
_swww() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
# ─< random wallpaper selection >─────────────────────────────────────────────────────────
|
# ─< random wallpaper selection >─────────────────────────────────────────────────────────
|
||||||
local wall_dir="$HOME/.wallpapers"
|
local wall_dir="$HOME/.wallpaper"
|
||||||
|
|
||||||
# ─< Create an array of directories to exclude >──────────────────────────────────────────
|
# ─< Create an array of directories to exclude >──────────────────────────────────────────
|
||||||
IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS"
|
IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS"
|
||||||
|
|
||||||
# ─< Build the find command with exclusions >─────────────────────────────────────────────
|
# # ─< Build the find command with exclusions >─────────────────────────────────────────────
|
||||||
local find_cmd="find \"$wall_dir\" -type f \( -iname \"*.png\" -o -iname \"*.jpg\" -o -iname \"*.gif\" -o -iname \"*.PNG\" -o -iname \"*.JPG\" -o -iname \"*.GIF\" \) -not -path \"*/\.git/*\""
|
# local find_cmd="find \"$wall_dir\" -type f \( -iname \"*.png\" -o -iname \"*.jpg\" -o -iname \"*.jpeg\" -o -iname \"*.gif\" \)"
|
||||||
|
#
|
||||||
for dir in "${EXCLUDED_DIRS[@]}"; do
|
# # Add directory exclusions
|
||||||
find_cmd+=" -not -path \"$wall_dir/$dir/*\""
|
# for dir in "${EXCLUDED_DIRS[@]}"; do
|
||||||
|
# find_cmd+=" -not \( -path \"$wall_dir/$dir/*\" -prune \)"
|
||||||
|
# done
|
||||||
|
#
|
||||||
|
# # Add final exclusions
|
||||||
|
# find_cmd+=" -not -path \"*/\.git/*\""
|
||||||
|
#
|
||||||
|
# # ─< Select a random picture >────────────────────────────────────────────────────────────
|
||||||
|
# local pic=$(eval "$find_cmd" | shuf -n 1)
|
||||||
|
# Alternative approach using shopt
|
||||||
|
shopt -s globstar nullglob
|
||||||
|
local pics=()
|
||||||
|
for pic in "$wall_dir"/**/*.{png,jpg,jpeg,gif}; do
|
||||||
|
# Skip excluded directories
|
||||||
|
for dir in "${EXCLUDED_DIRS[@]}"; do
|
||||||
|
[[ $pic == "$wall_dir/$dir/"* ]] && continue 2
|
||||||
|
done
|
||||||
|
pics+=("$pic")
|
||||||
done
|
done
|
||||||
|
|
||||||
# ─< Select a random picture >────────────────────────────────────────────────────────────
|
local pic=$(printf "%s\n" "${pics[@]}" | shuf -n 1)
|
||||||
local pic=$(eval $find_cmd | shuf -n 1)
|
# Check if we found any picture
|
||||||
|
# notify-send "pic" "$pic"
|
||||||
|
if [ -z "$pic" ]; then
|
||||||
|
notify-send "ERROR" "No wallpapers found in $wall_dir (excluding: $SWWW_EXCLUDED_DIRS)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# swww img "$pic" --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"
|
||||||
# ─< checking for swww >──────────────────────────────────────────────────────────────────
|
# ─< checking for swww >──────────────────────────────────────────────────────────────────
|
||||||
if command -v swww >/dev/null 2>&1; then
|
if ! command -v swww >/dev/null 2>&1; then
|
||||||
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
|
|
||||||
if ! pgrep -x "swww" >/dev/null; then
|
|
||||||
notify-send "SWWW" "swww not running - starting it now"
|
|
||||||
swww-daemon
|
|
||||||
sleep 1 # Give the daemon a second to start
|
|
||||||
if pgrep -x "swww" >/dev/null; then
|
|
||||||
notify-send "SWWW" "started successfully"
|
|
||||||
else
|
|
||||||
notify-send "ERROR" "seems like swww didn't come up as exspected"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─< checking the wall_dir variable >─────────────────────────────────────────────────────
|
|
||||||
if [[ -d "$wall_dir" ]]; then
|
|
||||||
# ─< executing swww with the random $pic >────────────────────────────────────────────────
|
|
||||||
swww img "$pic"
|
|
||||||
# --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"
|
|
||||||
notify-send " " "Changed wallpaper to $pic"
|
|
||||||
notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS"
|
|
||||||
else
|
|
||||||
notify-send "ERROR" "$wall_dir path not found"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
notify-send "ERROR" "swww was not found on the system"
|
notify-send "ERROR" "swww was not found on the system"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
|
||||||
|
if ! pgrep -x "swww-daemon" >/dev/null; then
|
||||||
|
notify-send "SWWW" "swww not running - starting it now"
|
||||||
|
swww-daemon
|
||||||
|
sleep 1 # Give the daemon a second to start
|
||||||
|
if ! pgrep -x "swww" >/dev/null; then
|
||||||
|
notify-send "ERROR" "seems like swww didn't start as expected"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
notify-send "SWWW" "started successfully"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─< checking the wall_dir variable >─────────────────────────────────────────────────────
|
||||||
|
# if [[ ! -d "$wall_dir" ]]; then
|
||||||
|
# notify-send "ERROR" "$wall_dir path not found"
|
||||||
|
# return 1
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# ─< executing swww with the random $pic >────────────────────────────────────────────────
|
||||||
|
if swww img "$pic" --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"; then
|
||||||
|
notify-send " " "Changed wallpaper to ${pic##*/}"
|
||||||
|
notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS"
|
||||||
|
else
|
||||||
|
notify-send "ERROR" "Failed to set wallpaper: $pic"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if command -v swww >/dev/null 2>&1; then
|
if ! command -v swww >/dev/null 2>&1; then
|
||||||
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
|
notify-send "ERROR" "swww was not found on the system"
|
||||||
if ! pgrep -x "swww" >/dev/null; then
|
return 1
|
||||||
notify-send "SWWW" "swww not running - starting it now"
|
fi
|
||||||
swww-daemon
|
|
||||||
sleep 1 # Give the daemon a second to start
|
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
|
||||||
if pgrep -x "swww" >/dev/null; then
|
if ! pgrep -x "swww-daemon" >/dev/null; then
|
||||||
notify-send "SWWW" "started successfully"
|
notify-send "SWWW" "swww not running - starting it now"
|
||||||
else
|
swww-daemon
|
||||||
notify-send "ERROR" "seems like swww didn't come up as exspected"
|
sleep 1 # Give the daemon a second to start
|
||||||
fi
|
if ! pgrep -x "swww-daemon" >/dev/null; then
|
||||||
|
notify-send "ERROR" "seems like swww didn't start as expected"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
# ─< executing swww with the random $pic >────────────────────────────────────────────────
|
notify-send "SWWW" "started successfully"
|
||||||
swww img "$1"
|
fi
|
||||||
# --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"
|
|
||||||
notify-send " " "Changed wallpaper to $1"
|
# Check if file exists
|
||||||
|
if [[ ! -f "$1" ]]; then
|
||||||
|
notify-send "ERROR" "File not found: $1"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─< executing swww with the random $pic >────────────────────────────────────────────────
|
||||||
|
if swww img "$1" --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"; then
|
||||||
|
notify-send " " "Changed wallpaper to ${1##*/}"
|
||||||
else
|
else
|
||||||
notify-send "ERROR" "$1 not found"
|
notify-send "ERROR" "Failed to set wallpaper: $1"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_swww "$@"
|
_swww "$@"
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
# │ and setup my hyprland environment │
|
# │ and setup my hyprland environment │
|
||||||
# ╰───────────────────────────────────────────────────╯
|
# ╰───────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
# ╭──────────╮
|
||||||
|
# │ security │
|
||||||
|
# ╰──────────╯
|
||||||
|
# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
|
||||||
# ╭──────────────╮
|
# ╭──────────────╮
|
||||||
# │ Source files │
|
# │ Source files │
|
||||||
# ╰──────────────╯
|
# ╰──────────────╯
|
||||||
|
@ -17,6 +20,10 @@ $h_conf = ~/.config/hypr
|
||||||
#│ > $main <- this should contain the main monitor (e.g. DP-1 or HDMI-A-1..) │
|
#│ > $main <- this should contain the main monitor (e.g. DP-1 or HDMI-A-1..) │
|
||||||
#│ > $secondary <- This is just the second monitor │
|
#│ > $secondary <- This is just the second monitor │
|
||||||
#╰───────────────────────────────────────────────────────────────────────────╯
|
#╰───────────────────────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
# ─< source hotkeys file for hyprland >──────────────────────────────────────────────────────
|
||||||
|
source = $h_conf/hotkeys.conf
|
||||||
|
|
||||||
source = $HOME/.monitors.conf
|
source = $HOME/.monitors.conf
|
||||||
# variable for specialworkspace (has to be configured in .monitors.conf like -> 'workspace = name:x, on-created-empty:$terminal')
|
# variable for specialworkspace (has to be configured in .monitors.conf like -> 'workspace = name:x, on-created-empty:$terminal')
|
||||||
$terminal = foot
|
$terminal = foot
|
||||||
|
@ -38,9 +45,6 @@ workspace = 69, monitor:$main, persistent:true, allow-tearing:true, gapsin:0, ga
|
||||||
# ────────────────────────────────────────< specials >────────────────────────────────────────
|
# ────────────────────────────────────────< specials >────────────────────────────────────────
|
||||||
workspace = special:magic, monitor:$main, on-created-empty:$terminal, border:0
|
workspace = special:magic, monitor:$main, on-created-empty:$terminal, border:0
|
||||||
|
|
||||||
# ─< source hotkeys file for hyprland >──────────────────────────────────────────────────────
|
|
||||||
source = $h_conf/hotkeys.conf
|
|
||||||
|
|
||||||
# ─< initialisation script >─────────────────────────────────────────────────────────────────
|
# ─< initialisation script >─────────────────────────────────────────────────────────────────
|
||||||
exec-once = $h_conf/.scripts/init.sh
|
exec-once = $h_conf/.scripts/init.sh
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue