mirror of
https://github.com/xsghetti/HyprCrux.git
synced 2025-07-03 05:40:38 -04:00
updates
This commit is contained in:
parent
cb5f26f4dc
commit
f41688887f
18 changed files with 441 additions and 206 deletions
|
@ -1,101 +1,85 @@
|
|||
|
||||
#!/bin/bash
|
||||
|
||||
scriptsDir="$HOME/.config/hypr/scripts"
|
||||
# Directory containing wallpapers
|
||||
#!/bin/bash
|
||||
|
||||
# WALLPAPERS PATH
|
||||
wallDIR="$HOME/.config/wallpapers"
|
||||
WALLPAPER_DIR="$HOME/.config/wallpapers"
|
||||
HYPERPAPER_CONFIG="$HOME/.config/hypr/hyprpaper.conf"
|
||||
|
||||
# Transition config
|
||||
FPS=60
|
||||
TYPE="wipe"
|
||||
DURATION=2
|
||||
BEZIER=".43,1.19,1,.4"
|
||||
SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION"
|
||||
|
||||
# Check if swaybg is running
|
||||
if pidof swaybg > /dev/null; then
|
||||
pkill swaybg
|
||||
fi
|
||||
|
||||
# Retrieve image files
|
||||
PICS=($(ls "${wallDIR}" | grep -E ".jpg$|.jpeg$|.png$|.gif$"))
|
||||
RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}"
|
||||
RANDOM_PIC_NAME="${#PICS[@]}. random"
|
||||
|
||||
# Rofi command
|
||||
rofi_command="rofi -show -dmenu -theme $HOME/.config/rofi/themes/wallpaper-select.rasi"
|
||||
|
||||
menu() {
|
||||
for i in "${!PICS[@]}"; do
|
||||
# Displaying .gif to indicate animated images
|
||||
if [[ -z $(echo "${PICS[$i]}" | grep .gif$) ]]; then
|
||||
printf "$(echo "${PICS[$i]}" | cut -d. -f1)\x00icon\x1f${wallDIR}/${PICS[$i]}\n"
|
||||
else
|
||||
printf "${PICS[$i]}\n"
|
||||
fi
|
||||
done
|
||||
|
||||
printf "$RANDOM_PIC_NAME\n"
|
||||
}
|
||||
|
||||
swww query || swww init
|
||||
|
||||
main() {
|
||||
choice=$(menu | ${rofi_command})
|
||||
|
||||
# No choice case
|
||||
if [[ -z $choice ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Random choice case
|
||||
if [ "$choice" = "$RANDOM_PIC_NAME" ]; then
|
||||
swww img "${wallDIR}/${RANDOM_PIC}" $SWWW_PARAMS
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find the index of the selected file
|
||||
pic_index=-1
|
||||
for i in "${!PICS[@]}"; do
|
||||
filename=$(basename "${PICS[$i]}")
|
||||
if [[ "$filename" == "$choice"* ]]; then
|
||||
pic_index=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $pic_index -ne -1 ]]; then
|
||||
swww img "${wallDIR}/${PICS[$pic_index]}" $SWWW_PARAMS
|
||||
else
|
||||
echo "Image not found."
|
||||
# Check if the directory exists
|
||||
if [ ! -d "$WALLPAPER_DIR" ]; then
|
||||
echo "Wallpaper directory not found!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if rofi is already running
|
||||
if pidof rofi > /dev/null; then
|
||||
pkill rofi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
main
|
||||
# Ensure Hyprpaper is running
|
||||
if ! pgrep -x "hyprpaper" > /dev/null; then
|
||||
hyprpaper &
|
||||
sleep 0.5 # Give it some time to start
|
||||
fi
|
||||
|
||||
wal -i ~/.config/rofi/.current_wallpaper
|
||||
# Function to format wallpapers for Rofi with previews
|
||||
menu() {
|
||||
find "$WALLPAPER_DIR" -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" \) | while read -r img; do
|
||||
printf "$(basename "$img")\x00icon\x1f$img\n"
|
||||
done
|
||||
}
|
||||
|
||||
~/.config/hypr/scripts/swww.sh
|
||||
# Show Rofi menu with image previews
|
||||
WALLPAPER=$(menu | rofi -dmenu -theme $HOME/.config/rofi/wallselect.rasi)
|
||||
|
||||
_ps=(waybar)
|
||||
for _prs in "${_ps[@]}"; do
|
||||
if pidof "${_prs}" >/dev/null; then
|
||||
pkill "${_prs}"
|
||||
# Check if the user pressed Escape (Rofi returns 1 when Escape is pressed)
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "No wallpaper selected, exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If user selected a wallpaper, preload and set it using Hyprpaper
|
||||
if [ -n "$WALLPAPER" ]; then
|
||||
FULL_PATH="$WALLPAPER_DIR/$WALLPAPER"
|
||||
|
||||
# Check if the wallpaper file exists before applying it
|
||||
if [ -f "$FULL_PATH" ]; then
|
||||
# Preload the wallpaper
|
||||
hyprctl hyprpaper preload "$FULL_PATH"
|
||||
sleep 0.2 # Short delay to ensure it's loaded
|
||||
|
||||
# Set the wallpaper using hyprpaper
|
||||
hyprctl hyprpaper wallpaper ", $FULL_PATH"
|
||||
|
||||
# Update Hyprpaper config file to persist wallpaper after reboot
|
||||
echo "preload = $FULL_PATH" > "$HYPERPAPER_CONFIG"
|
||||
echo "wallpaper = , $FULL_PATH" >> "$HYPERPAPER_CONFIG"
|
||||
|
||||
# Restart Hyprpaper to apply changes
|
||||
pkill hyprpaper
|
||||
hyprpaper &
|
||||
|
||||
# Create symlink to the selected wallpaper for Rofi access
|
||||
ln -sf "$FULL_PATH" "$HOME/.config/rofi/.current_wallpaper"
|
||||
|
||||
# Wait a moment to ensure the wallpaper is fully loaded before applying pywal
|
||||
sleep 1
|
||||
|
||||
# Use pywal to generate color scheme from the current wallpaper
|
||||
wal -i "$FULL_PATH" --cols16
|
||||
sleep 1 # Wait a moment for pywal to finish executing
|
||||
|
||||
# Run pywal-discord to update Discord (if applicable)
|
||||
pywal-discord
|
||||
else
|
||||
echo "Selected wallpaper file not found."
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "No wallpaper selected."
|
||||
fi
|
||||
|
||||
# Kill any running Waybar process
|
||||
pkill waybar
|
||||
|
||||
# Call a script to refresh Hyprpaper settings (if applicable)
|
||||
~/.config/hypr/scripts/refresh.sh
|
||||
|
||||
sleep 1
|
||||
# Relaunch waybar
|
||||
waybar &
|
||||
|
||||
~/.config/hypr/scripts/refresh.sh
|
||||
|
||||
pywal-discord
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue