From fe875b3321e3e46c89be908ad51c3062c2ba9c6a Mon Sep 17 00:00:00 2001 From: pika Date: Sat, 3 May 2025 09:11:59 +0200 Subject: [PATCH] some changes (also have pretty fast hyprland animations now!) --- .scripts/random_swww.sh | 138 +++++++++++++++++++++++++--------------- hyprland.conf | 12 ++-- 2 files changed, 96 insertions(+), 54 deletions(-) diff --git a/.scripts/random_swww.sh b/.scripts/random_swww.sh index 8daa276..36f2651 100755 --- a/.scripts/random_swww.sh +++ b/.scripts/random_swww.sh @@ -1,4 +1,4 @@ -#!/bin/bash --norc +#!/usr/bin/env bash # ╭───────────────╮ # │ SWWW-settings │ # ╰───────────────╯ @@ -17,70 +17,108 @@ export SWWW_TRANSITION=center _swww() { if [ -z "$1" ]; then # ─< random wallpaper selection >───────────────────────────────────────────────────────── - local wall_dir="$HOME/.wallpapers" + local wall_dir="$HOME/.wallpaper" # ─< Create an array of directories to exclude >────────────────────────────────────────── IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS" - # ─< 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/*\"" - - for dir in "${EXCLUDED_DIRS[@]}"; do - find_cmd+=" -not -path \"$wall_dir/$dir/*\"" + # # ─< Build the find command with exclusions >───────────────────────────────────────────── + # local find_cmd="find \"$wall_dir\" -type f \( -iname \"*.png\" -o -iname \"*.jpg\" -o -iname \"*.jpeg\" -o -iname \"*.gif\" \)" + # + # # Add directory exclusions + # 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 - # ─< Select a random picture >──────────────────────────────────────────────────────────── - local pic=$(eval $find_cmd | shuf -n 1) + local pic=$(printf "%s\n" "${pics[@]}" | 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 >────────────────────────────────────────────────────────────────── - 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 + if ! command -v swww >/dev/null 2>&1; then 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 else - 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 + if ! command -v swww >/dev/null 2>&1; then + 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-daemon" >/dev/null; then + notify-send "ERROR" "seems like swww didn't start as expected" + return 1 fi - # ─< executing swww with the random $pic >──────────────────────────────────────────────── - swww img "$1" - # --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION" - notify-send "󰸉 " "Changed wallpaper to $1" + notify-send "SWWW" "started successfully" + fi + + # 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 - notify-send "ERROR" "$1 not found" + notify-send "ERROR" "Failed to set wallpaper: $1" + return 1 fi fi - } _swww "$@" diff --git a/hyprland.conf b/hyprland.conf index e7cf9aa..da5879d 100644 --- a/hyprland.conf +++ b/hyprland.conf @@ -4,7 +4,10 @@ # │ and setup my hyprland environment │ # ╰───────────────────────────────────────────────────╯ - +# ╭──────────╮ +# │ security │ +# ╰──────────╯ +# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow # ╭──────────────╮ # │ 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..) │ #│ > $secondary <- This is just the second monitor │ #╰───────────────────────────────────────────────────────────────────────────╯ + +# ─< source hotkeys file for hyprland >────────────────────────────────────────────────────── +source = $h_conf/hotkeys.conf + source = $HOME/.monitors.conf # variable for specialworkspace (has to be configured in .monitors.conf like -> 'workspace = name:x, on-created-empty:$terminal') $terminal = foot @@ -38,9 +45,6 @@ workspace = 69, monitor:$main, persistent:true, allow-tearing:true, gapsin:0, ga # ────────────────────────────────────────< specials >──────────────────────────────────────── workspace = special:magic, monitor:$main, on-created-empty:$terminal, border:0 -# ─< source hotkeys file for hyprland >────────────────────────────────────────────────────── -source = $h_conf/hotkeys.conf - # ─< initialisation script >───────────────────────────────────────────────────────────────── exec-once = $h_conf/.scripts/init.sh