chore: global env and swww tearing fixed

This commit is contained in:
hesam-init 2024-02-22 23:37:29 +03:30
parent a264abe2a3
commit 29796fd418
7 changed files with 29 additions and 35 deletions

View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# waybar env :
export WAYBAR_THEME="river"
export WAYBAR_DIR="$HOME/.config/waybar/$WAYBAR_THEME"
export WAYBAR_LAUNCHER="waybar -c $WAYBAR_DIR/config.jsonc -s $WAYBAR_DIR/style.css"
export WAYBAR_INOTIFY_EVENTS="-e close_write,move,create"
# swww env :
export WALLPAPERS_DIR="$HOME/Wallpapers"
export SWWW_FPS=144
export SWWW_DURATION=2

View file

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# waybar env :
export waybar_theme="river"
export waybar_dir="$HOME/.config/waybar/$waybar_theme"
export waybar_launcher="waybar -c $waybar_dir/config.jsonc -s $waybar_dir/style.css"
export inotify_events="-e close_write,move,create"
# swww env :
export wallpapers_dir="$HOME/Wallpapers"
export swww_fps=120
export swww_duration=2

View file

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source $HOME/.config/hypr/scripts/env.sh source $HOME/.config/environments/env.sh
files=($(find "${wallpapers_dir}" -type f)) files=($(find "${WALLPAPERS_DIR}" -type f))
if [ ${#files[@]} -eq 0 ]; then if [ ${#files[@]} -eq 0 ]; then
echo "No files found in the directory: ${wallpapers_dir}" echo "No files found in the directory: ${WALLPAPERS_DIR}"
exit 1 exit 1
fi fi
@ -17,10 +17,10 @@ for file in "${files[@]}"; do
done done
if [ ${#image_files[@]} -eq 0 ]; then if [ ${#image_files[@]} -eq 0 ]; then
echo "No image files found in the directory: ${wallpapers_dir}" echo "No image files found in the directory: ${WALLPAPERS_DIR}"
exit 1 exit 1
fi fi
random_pic=${image_files[$RANDOM % ${#image_files[@]}]} random_pic=${image_files[$RANDOM % ${#image_files[@]}]}
swww img "$random_pic" --transition-fps $swww_fps --transition-type any --transition-duration $swww_duration swww img "$random_pic" --transition-fps $SWWW_FPS --transition-type any --transition-duration $SWWW_DURATION

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source $HOME/.config/hypr/scripts/env.sh source $HOME/.config/environments/env.sh
if [[ ! -d "$waybar_dir" ]]; then if [[ ! -d "$WAYBAR_DIR" ]]; then
echo "Error: Configuration directory or files missing!" echo "Error: Configuration directory or files missing!"
exit 1 exit 1
fi fi
@ -12,11 +12,11 @@ sleep 1
while true; do while true; do
logger -i "$0: Starting waybar in the background..." logger -i "$0: Starting waybar in the background..."
exec $waybar_launcher & exec $WAYBAR_LAUNCHER &
waybar_pid=$! waybar_pid=$!
logger -i "$0: Started waybar PID=$waybar_pid. Waiting for modifications..." logger -i "$0: Started waybar PID=$waybar_pid. Waiting for modifications..."
inotifywait $inotify_events "$waybar_dir" 2>&1 | logger -i inotifywait $WAYBAR_INOTIFY_EVENTS "$WAYBAR_DIR" 2>&1 | logger -i
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Error: inotifywait failed!" echo "Error: inotifywait failed!"

View file

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source $HOME/.config/hypr/scripts/env.sh source $HOME/.config/environments/env.sh
WAYBAR_PID=$(pgrep -x waybar) WAYBAR_PID=$(pgrep -x waybar)
if [ -n "$WAYBAR_PID" ]; then if [ -n "$WAYBAR_PID" ]; then
pkill waybar pkill waybar
else else
exec $waybar_launcher exec $WAYBAR_LAUNCHER
fi fi

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
if pgrep -x "wlogout" >/dev/null; then
pkill wlogout
else
wlogout
fi

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
wallpapers_dir="$HOME/Wallpapers/" source $HOME/.config/environments/env.sh
dir="$HOME/.config/rofi/wallpaper/type-1" dir="$HOME/.config/rofi/wallpaper/type-1"
theme='style-8' theme='style-8'
@ -9,16 +10,16 @@ rofi_cmd() {
} }
show_image_preview() { show_image_preview() {
ls --escape "$wallpapers_dir" | ls --escape "$WALLPAPERS_DIR" |
while read A; do echo -en "$A\x00icon\x1f$wallpapers_dir/$A\n"; done while read A; do echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n"; done
} }
choice=$( choice=$(
show_image_preview | rofi_cmd show_image_preview | rofi_cmd
) )
wallpaper="$wallpapers_dir/$choice" wallpaper="$WALLPAPERS_DIR/$choice"
swww img -t any --transition-bezier 0.0,0.0,1.0,1.0 --transition-duration 1 --transition-step 255 --transition-fps 120 "$wallpaper" swww img "$wallpaper" --transition-fps $SWWW_FPS --transition-type any --transition-duration $SWWW_DURATION
exit 1 exit 1