diff options
| author | Ja.KooLit <85185940+JaKooLit@users.noreply.github.com> | 2024-08-14 00:48:44 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-14 00:48:44 +0900 |
| commit | ac062ecf708b28d10cc3275fcf9e18c736d568f4 (patch) | |
| tree | d80f5d1f469304bd625b4a8fd2c49085e24f3285 /config/hypr/UserScripts | |
| parent | f9ff441fe41e4af112411b4bef55bca98c2f7474 (diff) | |
| parent | 69a7793deddb102d9643d5ee047bde81ba25bcbd (diff) | |
Merge pull request #402 from JaKooLit/main
Main to AGS-Dev
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/QuickEdit.sh | 2 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperEffects.sh | 105 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 45 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 4 |
4 files changed, 83 insertions, 73 deletions
diff --git a/config/hypr/UserScripts/QuickEdit.sh b/config/hypr/UserScripts/QuickEdit.sh index cd604619..8864a30c 100755 --- a/config/hypr/UserScripts/QuickEdit.sh +++ b/config/hypr/UserScripts/QuickEdit.sh @@ -2,7 +2,7 @@ # Rofi menu for Quick Edit / View of Settings (SUPER E) # define your preferred text editor and terminal to use -editor=nano +editor=${EDITOR:-nano} tty=kitty configs="$HOME/.config/hypr/configs" diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index 84f8fd7b..cc6a5781 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -1,9 +1,9 @@ #!/bin/bash # /* ---- đĢ https://github.com/JaKooLit đĢ ---- */ # -# Wallpaper Effects using imagemagick +# Wallpaper Effects using ImageMagick # Inspiration from ML4W - Stephan Raabe https://gitlab.com/stephan-raabe/dotfiles -# variables +# Variables current_wallpaper="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" wallpaper_output="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" SCRIPTSDIR="$HOME/.config/hypr/scripts" @@ -20,27 +20,26 @@ BEZIER=".43,1.19,1,.4" SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION" # Define ImageMagick effects -# https://imagemagick.org/script/magick.php - declare -A effects=( -["Black & White"]="magick $current_wallpaper -colorspace gray -sigmoidal-contrast 10,40% $wallpaper_output" -["Blurred"]="magick $current_wallpaper -blur 0x5 $wallpaper_output" -["Solarize"]="magick $current_wallpaper -solarize 80% $wallpaper_output" -["Sepia Tone"]="magick $current_wallpaper -sepia-tone 65% $wallpaper_output" -["Negate"]="magick $current_wallpaper -negate $wallpaper_output" -["Charcoal"]="magick $current_wallpaper -charcoal 0x5 $wallpaper_output" -["Edge Detect"]="magick $current_wallpaper -edge 1 $wallpaper_output" -["Emboss"]="magick $current_wallpaper -emboss 0x5 $wallpaper_output" -["Sharpen"]="magick $current_wallpaper -sharpen 0x5 $wallpaper_output" -["Oil Paint"]="magick $current_wallpaper -paint 4 $wallpaper_output" -["Vignette"]="magick $current_wallpaper -vignette 0x5 $wallpaper_output" -["Posterize"]="magick $current_wallpaper -posterize 4 $wallpaper_output" -["Polaroid"]="magick $current_wallpaper -polaroid 0 $wallpaper_output" -["No Effects"]="no-effects" + ["No Effects"]="no-effects" + ["Black & White"]="magick $current_wallpaper -colorspace gray -sigmoidal-contrast 10,40% $wallpaper_output" + ["Blurred"]="magick $current_wallpaper -blur 0x10 $wallpaper_output" + ["Charcoal"]="magick $current_wallpaper -charcoal 0x5 $wallpaper_output" + ["Edge Detect"]="magick $current_wallpaper -edge 1 $wallpaper_output" + ["Emboss"]="magick $current_wallpaper -emboss 0x5 $wallpaper_output" + ["Negate"]="magick $current_wallpaper -negate $wallpaper_output" + ["Oil Paint"]="magick $current_wallpaper -paint 4 $wallpaper_output" + ["Posterize"]="magick $current_wallpaper -posterize 4 $wallpaper_output" + ["Polaroid"]="magick $current_wallpaper -polaroid 0 $wallpaper_output" + ["Sepia Tone"]="magick $current_wallpaper -sepia-tone 65% $wallpaper_output" + ["Solarize"]="magick $current_wallpaper -solarize 80% $wallpaper_output" + ["Sharpen"]="magick $current_wallpaper -sharpen 0x5 $wallpaper_output" + ["Vignette"]="magick $current_wallpaper -vignette 0x5 $wallpaper_output" + ["Zoomed"]="magick $current_wallpaper -gravity Center -extent 1:1 $wallpaper_output" ) # Function to apply no effects -no_effects() { +no-effects() { swww img -o "$focused_monitor" "$current_wallpaper" $SWWW_PARAMS & # Wait for swww command to complete wait $! @@ -51,56 +50,52 @@ no_effects() { # Refresh rofi, waybar, wallust palettes "${SCRIPTSDIR}/Refresh.sh" notify-send -u low -i "$iDIR/bell.png" "No wallpaper effects" - - # copying wallpaper for rofi menu - cp $current_wallpaper $wallpaper_output + # copying wallpaper for rofi menu + cp "$current_wallpaper" "$wallpaper_output" } # Function to run rofi menu main() { # Populate rofi menu options - options="No Effects" + options=("No Effects") for effect in "${!effects[@]}"; do - if [ "$effect" != "No Effects" ]; then - options+="\n$effect" - fi + [[ "$effect" != "No Effects" ]] && options+=("$effect") done - # rofi - choice=$(echo -e "$options" | rofi -i -dmenu -config ~/.config/rofi/config-wallpaper-effect.rasi) - if [ ! -z "$choice" ]; then - # Check if the choice exists in the array - if [[ "${effects[$choice]+exists}" ]]; then - if [ "$choice" == "No Effects" ]; then - no_effects - else - # Apply selected effect - notify-send -u normal -i "$iDIR/bell.png" "Applying $choice effects" - eval "${effects[$choice]}" - # Wait for effects to be applied - sleep 1 - # Execute swww command after image conversion - swww img -o "$focused_monitor" "$wallpaper_output" $SWWW_PARAMS & - # Wait for swww command to complete - wait $! - # Run other commands after swww - wallust run "$wallpaper_output" -s & - # Wait for other commands to finish - wait $! - # Refresh rofi, waybar, wallust palettes - "${SCRIPTSDIR}/Refresh.sh" - notify-send -u low -i "$iDIR/bell.png" "$choice effects applied" - fi + # Show rofi menu and handle user choice + choice=$(printf "%s\n" "${options[@]}" | LC_COLLATE=C sort | rofi -dmenu -p "Choose effect" -i -config ~/.config/rofi/config-wallpaper-effect.rasi) + + # Process user choice + if [[ -n "$choice" ]]; then + if [[ "$choice" == "No Effects" ]]; then + no-effects + elif [[ "${effects[$choice]+exists}" ]]; then + # Apply selected effect + notify-send -u normal -i "$iDIR/bell.png" "Applying $choice effects" + eval "${effects[$choice]}" + # Wait for effects to be applied + sleep 1 + # Execute swww command after image conversion + swww img -o "$focused_monitor" "$wallpaper_output" $SWWW_PARAMS & + # Wait for swww command to complete + wait $! + # Wait for other commands to finish + wallust run "$wallpaper_output" -s & + # Wait for other commands to finish + wait $! + # Refresh rofi, waybar, wallust palettes + "${SCRIPTSDIR}/Refresh.sh" + notify-send -u low -i "$iDIR/bell.png" "$choice effects applied" else - echo "Effects not recognized." + echo "Effect '$choice' not recognized." fi fi } -# Check if rofi is already running +# Check if rofi is already running and kill it if pidof rofi > /dev/null; then - pkill rofi - exit 0 + pkill rofi + exit 0 fi main diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index d2ca7c28..25ef30e9 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -4,11 +4,10 @@ # WALLPAPERS PATH wallDIR="$HOME/Pictures/wallpapers" +SCRIPTSDIR="$HOME/.config/hypr/scripts" # variables -SCRIPTSDIR="$HOME/.config/hypr/scripts" focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') - # swww transition config FPS=60 TYPE="any" @@ -21,24 +20,28 @@ if pidof swaybg > /dev/null; then pkill swaybg fi -# Retrieve image files -PICS=($(find "${wallDIR}" -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png -o -iname \*.gif \))) +# Retrieve image files using null delimiter to handle spaces in filenames +mapfile -d '' PICS < <(find "${wallDIR}" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" \) -print0) + RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}" RANDOM_PIC_NAME=". random" # Rofi command rofi_command="rofi -i -show -dmenu -config ~/.config/rofi/config-wallpaper.rasi" - # Sorting Wallpapers menu() { - sorted_options=($(printf '%s\n' "${PICS[@]}" | sort)) + # Sort the PICS array + IFS=$'\n' sorted_options=($(sort <<<"${PICS[*]}")) + # Place ". random" at the beginning with the random picture as an icon printf "%s\x00icon\x1f%s\n" "$RANDOM_PIC_NAME" "$RANDOM_PIC" + for pic_path in "${sorted_options[@]}"; do pic_name=$(basename "$pic_path") + # Displaying .gif to indicate animated images - if [[ -z $(echo "$pic_name" | grep -i "\.gif$") ]]; then + if [[ ! "$pic_name" =~ \.gif$ ]]; then printf "%s\x00icon\x1f%s\n" "$(echo "$pic_name" | cut -d. -f1)" "$pic_path" else printf "%s\n" "$pic_name" @@ -51,15 +54,25 @@ swww query || swww-daemon --format xrgb # Choice of wallpapers main() { - choice=$(menu | ${rofi_command}) + choice=$(menu | $rofi_command) + + # Trim any potential whitespace or hidden characters + choice=$(echo "$choice" | xargs) + RANDOM_PIC_NAME=$(echo "$RANDOM_PIC_NAME" | xargs) + # No choice case - if [[ -z $choice ]]; then + if [[ -z "$choice" ]]; then + echo "No choice selected. Exiting." exit 0 fi # Random choice case - if [ "$choice" = "$RANDOM_PIC_NAME" ]; then - swww img -o $focused_monitor "${RANDOM_PIC}" $SWWW_PARAMS + if [[ "$choice" == "$RANDOM_PIC_NAME" ]]; then + swww img -o "$focused_monitor" "$RANDOM_PIC" $SWWW_PARAMS; + sleep 0.5 + "$SCRIPTSDIR/WallustSwww.sh" + sleep 0.2 + "$SCRIPTSDIR/Refresh.sh" exit 0 fi @@ -74,7 +87,7 @@ main() { done if [[ $pic_index -ne -1 ]]; then - swww img -o $focused_monitor "${PICS[$pic_index]}" $SWWW_PARAMS + swww img -o "$focused_monitor" "${PICS[$pic_index]}" $SWWW_PARAMS else echo "Image not found." exit 1 @@ -84,12 +97,14 @@ main() { # Check if rofi is already running if pidof rofi > /dev/null; then pkill rofi - exit 0 + sleep 1 # Allow some time for rofi to close fi main sleep 0.5 -${SCRIPTSDIR}/WallustSwww.sh +"$SCRIPTSDIR/WallustSwww.sh" + sleep 0.2 -${SCRIPTSDIR}/Refresh.sh +"$SCRIPTSDIR/Refresh.sh" + diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index 1d2ea30b..c0a40fd7 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -63,12 +63,12 @@ temp_feel_text = f"Feels like {temp_feel}c" # min-max temperature temp_min = ( html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']") - .eq(0) + .eq(1) .text() ) temp_max = ( html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']") - .eq(1) + .eq(0) .text() ) temp_min_max = f"ī {temp_min}\t\tī {temp_max}" |
