hyprland-dotfiles/hypr/scripts/wallpaper.sh

86 lines
2.6 KiB
Bash
Raw Normal View History

2023-08-17 14:59:28 +00:00
#!/bin/bash
2023-11-10 21:12:15 +00:00
# _ _
# __ ____ _| | |_ __ __ _ _ __ ___ _ __
# \ \ /\ / / _` | | | '_ \ / _` | '_ \ / _ \ '__|
# \ V V / (_| | | | |_) | (_| | |_) | __/ |
# \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_|
# |_| |_|
2023-08-17 15:44:09 +00:00
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
2023-08-17 14:59:28 +00:00
2023-11-10 21:12:15 +00:00
case $1 in
# Load wallpaper from .cache of last session
"init")
if [ -f ~/.cache/current_wallpaper.jpg ]; then
2023-12-10 12:40:53 +00:00
wal -q -c -i ~/.cache/current_wallpaper.jpg
2023-11-10 21:12:15 +00:00
else
wal -q -i ~/wallpaper/
fi
;;
# Select wallpaper with rofi
"select")
2023-12-20 10:05:15 +00:00
selected=$( find "$HOME/wallpaper" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort | while read rfile
do
echo -en "$rfile\x00icon\x1f$HOME/wallpaper/${rfile}\n"
done | rofi -dmenu -replace -l 6 -config ~/dotfiles/rofi/config-wallpaper.rasi)
2023-11-10 21:12:15 +00:00
if [ ! "$selected" ]; then
echo "No wallpaper selected"
exit
fi
wal -q -i ~/wallpaper/$selected
;;
# Randomly select wallpaper
*)
wal -q -i ~/wallpaper/
;;
esac
2023-08-17 15:44:09 +00:00
# -----------------------------------------------------
# Load current pywal color scheme
# -----------------------------------------------------
2023-08-17 14:59:28 +00:00
source "$HOME/.cache/wal/colors.sh"
2023-11-10 21:12:15 +00:00
echo "Wallpaper: $wallpaper"
2023-08-17 14:59:28 +00:00
2023-08-20 09:46:46 +00:00
# -----------------------------------------------------
# Copy selected wallpaper into .cache folder
2023-08-20 09:46:46 +00:00
# -----------------------------------------------------
2023-08-30 12:45:03 +00:00
cp $wallpaper ~/.cache/current_wallpaper.jpg
2023-08-20 09:46:46 +00:00
2023-08-17 15:44:09 +00:00
# -----------------------------------------------------
2023-12-10 12:37:48 +00:00
# get wallpaper image name
2023-08-17 15:44:09 +00:00
# -----------------------------------------------------
newwall=$(echo $wallpaper | sed "s|$HOME/wallpaper/||g")
2023-08-17 14:59:28 +00:00
2023-08-17 15:44:09 +00:00
# -----------------------------------------------------
2023-11-10 21:12:15 +00:00
# Reload waybar with new colors
# -----------------------------------------------------
~/dotfiles/waybar/launch.sh
2023-08-17 15:44:09 +00:00
# -----------------------------------------------------
2023-11-10 21:12:15 +00:00
# Set the new wallpaper
# -----------------------------------------------------
transition_type="wipe"
# transition_type="outer"
# transition_type="random"
2023-10-01 09:21:02 +00:00
swww img $wallpaper \
--transition-bezier .43,1.19,1,.4 \
--transition-fps=60 \
2023-11-10 21:12:15 +00:00
--transition-type=$transition_type \
2023-10-01 09:21:02 +00:00
--transition-duration=0.7 \
--transition-pos "$( hyprctl cursorpos )"
2023-08-20 09:46:46 +00:00
# -----------------------------------------------------
# Send notification
# -----------------------------------------------------
2023-11-10 21:12:15 +00:00
sleep 1
2023-09-20 11:56:57 +00:00
notify-send "Colors and Wallpaper updated" "with image $newwall"
2023-08-17 14:59:28 +00:00
2023-08-20 09:46:46 +00:00
echo "DONE!"