Hyprland-dotfiles/hypr/scripts/wallpaper.sh

82 lines
2.4 KiB
Bash
Raw Normal View History

2023-08-17 10:59:28 -04:00
#!/bin/bash
2023-11-10 16:12:15 -05:00
# _ _
# __ ____ _| | |_ __ __ _ _ __ ___ _ __
# \ \ /\ / / _` | | | '_ \ / _` | '_ \ / _ \ '__|
# \ V V / (_| | | | |_) | (_| | |_) | __/ |
# \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_|
# |_| |_|
2023-08-17 11:44:09 -04:00
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
2023-08-17 10:59:28 -04:00
2023-11-10 16:12:15 -05:00
case $1 in
# Load wallpaper from .cache of last session
"init")
if [ -f ~/.cache/current_wallpaper.jpg ]; then
2023-12-10 07:40:53 -05:00
wal -q -c -i ~/.cache/current_wallpaper.jpg
2023-11-10 16:12:15 -05:00
else
wal -q -i ~/wallpaper/
fi
;;
# Select wallpaper with rofi
"select")
2023-11-13 07:37:27 -05:00
selected=$(ls -1 ~/wallpaper | grep "jpg" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-wallpaper.rasi)
2023-11-10 16:12:15 -05: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 11:44:09 -04:00
# -----------------------------------------------------
# Load current pywal color scheme
# -----------------------------------------------------
2023-08-17 10:59:28 -04:00
source "$HOME/.cache/wal/colors.sh"
2023-11-10 16:12:15 -05:00
echo "Wallpaper: $wallpaper"
2023-08-17 10:59:28 -04:00
2023-08-20 05:46:46 -04:00
# -----------------------------------------------------
# Copy selected wallpaper into .cache folder
2023-08-20 05:46:46 -04:00
# -----------------------------------------------------
2023-08-30 08:45:03 -04:00
cp $wallpaper ~/.cache/current_wallpaper.jpg
2023-08-20 05:46:46 -04:00
2023-08-17 11:44:09 -04:00
# -----------------------------------------------------
2023-12-10 07:37:48 -05:00
# get wallpaper image name
2023-08-17 11:44:09 -04:00
# -----------------------------------------------------
newwall=$(echo $wallpaper | sed "s|$HOME/wallpaper/||g")
2023-08-17 10:59:28 -04:00
2023-08-17 11:44:09 -04:00
# -----------------------------------------------------
2023-11-10 16:12:15 -05:00
# Reload waybar with new colors
# -----------------------------------------------------
~/dotfiles/waybar/launch.sh
2023-08-17 11:44:09 -04:00
# -----------------------------------------------------
2023-11-10 16:12:15 -05:00
# Set the new wallpaper
# -----------------------------------------------------
transition_type="wipe"
# transition_type="outer"
# transition_type="random"
2023-10-01 05:21:02 -04:00
swww img $wallpaper \
--transition-bezier .43,1.19,1,.4 \
--transition-fps=60 \
2023-11-10 16:12:15 -05:00
--transition-type=$transition_type \
2023-10-01 05:21:02 -04:00
--transition-duration=0.7 \
--transition-pos "$( hyprctl cursorpos )"
2023-08-20 05:46:46 -04:00
# -----------------------------------------------------
# Send notification
# -----------------------------------------------------
2023-11-10 16:12:15 -05:00
sleep 1
2023-09-20 07:56:57 -04:00
notify-send "Colors and Wallpaper updated" "with image $newwall"
2023-08-17 10:59:28 -04:00
2023-08-20 05:46:46 -04:00
echo "DONE!"