mirror of
https://github.com/xsghetti/HyprCrux.git
synced 2025-07-01 21:10:38 -04:00
wallpaper scripts
This commit is contained in:
parent
d3ade36241
commit
c5a477ab96
3 changed files with 170 additions and 0 deletions
40
.config/hypr/scripts/swww.sh
Normal file
40
.config/hypr/scripts/swww.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
|
||||
# Pywal Colors for current wallpaper
|
||||
|
||||
# Define the path to the swww cache directory
|
||||
cache_dir="$HOME/.cache/swww/"
|
||||
|
||||
# Get a list of monitor outputs
|
||||
monitor_outputs=($(ls "$cache_dir"))
|
||||
|
||||
# Initialize a flag to determine if the ln command was executed
|
||||
ln_success=false
|
||||
|
||||
# Loop through monitor outputs
|
||||
for output in "${monitor_outputs[@]}"; do
|
||||
# Construct the full path to the cache file
|
||||
cache_file="$cache_dir$output"
|
||||
|
||||
# Check if the cache file exists for the current monitor output
|
||||
if [ -f "$cache_file" ]; then
|
||||
# Get the wallpaper path from the cache file
|
||||
wallpaper_path=$(cat "$cache_file")
|
||||
|
||||
# Copy the wallpaper to the location Rofi can access
|
||||
if ln -sf "$wallpaper_path" "$HOME/.config/rofi/.current_wallpaper"; then
|
||||
ln_success=true # Set the flag to true upon successful execution
|
||||
fi
|
||||
|
||||
break # Exit the loop after processing the first found monitor output
|
||||
fi
|
||||
done
|
||||
|
||||
# Check the flag before executing further commands
|
||||
if [ "$ln_success" = true ]; then
|
||||
# execute pywal
|
||||
# wal -i "$wallpaper_path"
|
||||
|
||||
# execute pywal skipping tty and terminal changes
|
||||
wal -i "$wallpaper_path" -s -t &
|
||||
fi
|
31
.config/hypr/scripts/wallpaper.sh
Normal file
31
.config/hypr/scripts/wallpaper.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
DIR=~/.config/wallpapers
|
||||
PICS=($(ls ${DIR}))
|
||||
|
||||
RANDOMPICS=${PICS[ $RANDOM % ${#PICS[@]} ]}
|
||||
|
||||
if [[ $(pidof swww) ]]; then
|
||||
pkill swww
|
||||
fi
|
||||
|
||||
swww query || swww init
|
||||
|
||||
#change-wallpaper using swww
|
||||
swww img ${DIR}/${RANDOMPICS} --transition-fps 60 --transition-type any --transition-duration 2
|
||||
|
||||
wal -i ~/.config/rofi/.current_wallpaper
|
||||
|
||||
~/.config/.scripts/swww.sh
|
||||
|
||||
_ps=(waybar)
|
||||
for _prs in "${_ps[@]}"; do
|
||||
if pidof "${_prs}" >/dev/null; then
|
||||
pkill "${_prs}"
|
||||
fi
|
||||
done
|
||||
|
||||
sleep 1
|
||||
# Relaunch waybar
|
||||
waybar &
|
||||
|
99
.config/hypr/scripts/wallpaperselect.sh
Normal file
99
.config/hypr/scripts/wallpaperselect.sh
Normal file
|
@ -0,0 +1,99 @@
|
|||
|
||||
#!/bin/bash
|
||||
## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
|
||||
# This script for selecting wallpapers (SUPER W)
|
||||
|
||||
scriptsDir="$HOME/.config/hypr/scripts"
|
||||
|
||||
# WALLPAPERS PATH
|
||||
wallDIR="/home/crux/.config/wallpapers"
|
||||
|
||||
# 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."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if rofi is already running
|
||||
if pidof rofi > /dev/null; then
|
||||
pkill rofi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
main
|
||||
|
||||
wal -i ~/.config/rofi/.current_wallpaper
|
||||
|
||||
~/.config/.scripts/swww.sh
|
||||
|
||||
_ps=(waybar)
|
||||
for _prs in "${_ps[@]}"; do
|
||||
if pidof "${_prs}" >/dev/null; then
|
||||
pkill "${_prs}"
|
||||
fi
|
||||
done
|
||||
|
||||
sleep 1
|
||||
# Relaunch waybar
|
||||
waybar &
|
Loading…
Add table
Add a link
Reference in a new issue