Hyprland-dotfiles/qtile/scripts/wallpaper.sh
Stephan Raabe 51e9d67781 Updates
2023-12-20 11:05:15 +01:00

67 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# ____ _ _____ _
# / ___| |__ __ _ _ __ __ _ ___ |_ _| |__ ___ _ __ ___ ___
# | | | '_ \ / _` | '_ \ / _` |/ _ \ | | | '_ \ / _ \ '_ ` _ \ / _ \
# | |___| | | | (_| | | | | (_| | __/ | | | | | | __/ | | | | | __/
# \____|_| |_|\__,_|_| |_|\__, |\___| |_| |_| |_|\___|_| |_| |_|\___|
# |___/
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
case $1 in
# Load wallpaper from .cache of last session
"init")
if [ -f ~/.cache/current_wallpaper.jpg ]; then
wal -q -i ~/.cache/current_wallpaper.jpg
else
wal -q -i ~/wallpaper/
fi
;;
# Select wallpaper with rofi
"select")
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)
if [ ! "$selected" ]; then
echo "No wallpaper selected"
exit
fi
wal -q -i ~/wallpaper/$selected
;;
# Randomly select wallpaper
*)
wal -q -i ~/wallpaper/
;;
esac
# -----------------------------------------------------
# Reload qtile to color bar
# -----------------------------------------------------
qtile cmd-obj -o cmd -f reload_config
# -----------------------------------------------------
# Get new theme
# -----------------------------------------------------
source "$HOME/.cache/wal/colors.sh"
echo "Wallpaper: $wallpaper"
newwall=$(echo $wallpaper | sed "s|$HOME/wallpaper/||g")
# -----------------------------------------------------
# Copy selected wallpaper into .cache folder
# -----------------------------------------------------
cp $wallpaper ~/.cache/current_wallpaper.jpg
sleep 1
# -----------------------------------------------------
# Send notification
# -----------------------------------------------------
notify-send "Colors and Wallpaper updated" "with image $newwall"
echo "Done."