From 29796fd418fe772cd5513b6208f0a4d1df91ed32 Mon Sep 17 00:00:00 2001 From: hesam-init Date: Thu, 22 Feb 2024 23:37:29 +0330 Subject: [PATCH] chore: global env and swww tearing fixed --- hyprland/.config/environments/env.sh | 12 ++++++++++++ hyprland/.config/hypr/scripts/env.sh | 12 ------------ hyprland/.config/hypr/scripts/swww-random.sh | 10 +++++----- hyprland/.config/hypr/scripts/waybar-launch.sh | 8 ++++---- hyprland/.config/hypr/scripts/waybar-toggle.sh | 4 ++-- hyprland/.config/hypr/scripts/wlogout-toggle.sh | 7 ------- hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh | 11 ++++++----- 7 files changed, 29 insertions(+), 35 deletions(-) create mode 100755 hyprland/.config/environments/env.sh delete mode 100755 hyprland/.config/hypr/scripts/env.sh delete mode 100755 hyprland/.config/hypr/scripts/wlogout-toggle.sh diff --git a/hyprland/.config/environments/env.sh b/hyprland/.config/environments/env.sh new file mode 100755 index 0000000..fe7ead6 --- /dev/null +++ b/hyprland/.config/environments/env.sh @@ -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 diff --git a/hyprland/.config/hypr/scripts/env.sh b/hyprland/.config/hypr/scripts/env.sh deleted file mode 100755 index db1326d..0000000 --- a/hyprland/.config/hypr/scripts/env.sh +++ /dev/null @@ -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 diff --git a/hyprland/.config/hypr/scripts/swww-random.sh b/hyprland/.config/hypr/scripts/swww-random.sh index 573a436..d731a98 100755 --- a/hyprland/.config/hypr/scripts/swww-random.sh +++ b/hyprland/.config/hypr/scripts/swww-random.sh @@ -1,11 +1,11 @@ #!/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 - echo "No files found in the directory: ${wallpapers_dir}" + echo "No files found in the directory: ${WALLPAPERS_DIR}" exit 1 fi @@ -17,10 +17,10 @@ for file in "${files[@]}"; do done 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 fi 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 diff --git a/hyprland/.config/hypr/scripts/waybar-launch.sh b/hyprland/.config/hypr/scripts/waybar-launch.sh index 42a6cc2..68889bb 100755 --- a/hyprland/.config/hypr/scripts/waybar-launch.sh +++ b/hyprland/.config/hypr/scripts/waybar-launch.sh @@ -1,8 +1,8 @@ #!/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!" exit 1 fi @@ -12,11 +12,11 @@ sleep 1 while true; do logger -i "$0: Starting waybar in the background..." - exec $waybar_launcher & + exec $WAYBAR_LAUNCHER & waybar_pid=$! 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 echo "Error: inotifywait failed!" diff --git a/hyprland/.config/hypr/scripts/waybar-toggle.sh b/hyprland/.config/hypr/scripts/waybar-toggle.sh index a68beb6..d5582c7 100755 --- a/hyprland/.config/hypr/scripts/waybar-toggle.sh +++ b/hyprland/.config/hypr/scripts/waybar-toggle.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash -source $HOME/.config/hypr/scripts/env.sh +source $HOME/.config/environments/env.sh WAYBAR_PID=$(pgrep -x waybar) if [ -n "$WAYBAR_PID" ]; then pkill waybar else - exec $waybar_launcher + exec $WAYBAR_LAUNCHER fi diff --git a/hyprland/.config/hypr/scripts/wlogout-toggle.sh b/hyprland/.config/hypr/scripts/wlogout-toggle.sh deleted file mode 100755 index 6a53616..0000000 --- a/hyprland/.config/hypr/scripts/wlogout-toggle.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if pgrep -x "wlogout" >/dev/null; then - pkill wlogout -else - wlogout -fi diff --git a/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh b/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh index 69c76d4..315bb8e 100755 --- a/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh +++ b/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -wallpapers_dir="$HOME/Wallpapers/" +source $HOME/.config/environments/env.sh + dir="$HOME/.config/rofi/wallpaper/type-1" theme='style-8' @@ -9,16 +10,16 @@ rofi_cmd() { } show_image_preview() { - ls --escape "$wallpapers_dir" | - while read A; do echo -en "$A\x00icon\x1f$wallpapers_dir/$A\n"; done + ls --escape "$WALLPAPERS_DIR" | + while read A; do echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n"; done } choice=$( 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