2023-03-09 08:25:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# ____ _ _____ _
|
|
|
|
# / ___| |__ __ _ _ __ __ _ ___ |_ _| |__ ___ _ __ ___ ___
|
|
|
|
# | | | '_ \ / _` | '_ \ / _` |/ _ \ | | | '_ \ / _ \ '_ ` _ \ / _ \
|
|
|
|
# | |___| | | | (_| | | | | (_| | __/ | | | | | | __/ | | | | | __/
|
|
|
|
# \____|_| |_|\__,_|_| |_|\__, |\___| |_| |_| |_|\___|_| |_| |_|\___|
|
|
|
|
# |___/
|
|
|
|
#
|
|
|
|
# by Stephan Raabe (2023)
|
|
|
|
# -----------------------------------------------------
|
2023-02-09 09:27:03 +00:00
|
|
|
|
2023-12-21 10:05:20 +00:00
|
|
|
# Cache file for holding the current wallpaper
|
|
|
|
cache_file="$HOME/.cache/current_wallpaper"
|
|
|
|
rasi_file="$HOME/.cache/current_wallpaper.rasi"
|
|
|
|
|
|
|
|
# Create cache file if not exists
|
|
|
|
if [ ! -f $cache_file ] ;then
|
|
|
|
touch $cache_file
|
|
|
|
echo "$HOME/wallpaper/default.jpg" > "$cache_file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create rasi file if not exists
|
|
|
|
if [ ! -f $rasi_file ] ;then
|
|
|
|
touch $rasi_file
|
|
|
|
echo "* { current-image: url(\"$HOME/wallpaper/default.jpg\", height); }" > "$rasi_file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
current_wallpaper=$(cat "$cache_file")
|
|
|
|
|
2023-11-10 21:12:15 +00:00
|
|
|
case $1 in
|
|
|
|
|
|
|
|
# Load wallpaper from .cache of last session
|
|
|
|
"init")
|
2023-12-21 10:05:20 +00:00
|
|
|
if [ -f $cache_file ]; then
|
|
|
|
wal -q -i $current_wallpaper
|
2023-11-10 21:12:15 +00:00
|
|
|
else
|
|
|
|
wal -q -i ~/wallpaper/
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
# Select wallpaper with rofi
|
|
|
|
"select")
|
2023-12-21 12:14:11 +00:00
|
|
|
selected=$( find "$HOME/wallpaper" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort -R | while read rfile
|
2023-12-20 10:05:15 +00:00
|
|
|
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-02-09 09:27:03 +00:00
|
|
|
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-02-09 09:27:03 +00:00
|
|
|
# Reload qtile to color bar
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-02-09 09:27:03 +00:00
|
|
|
qtile cmd-obj -o cmd -f reload_config
|
|
|
|
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-04-08 14:26:43 +00:00
|
|
|
# Get new theme
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-04-08 14:26:43 +00:00
|
|
|
source "$HOME/.cache/wal/colors.sh"
|
2023-11-10 21:12:15 +00:00
|
|
|
echo "Wallpaper: $wallpaper"
|
2023-04-11 08:27:01 +00:00
|
|
|
newwall=$(echo $wallpaper | sed "s|$HOME/wallpaper/||g")
|
2023-10-02 08:51:16 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------------
|
2023-12-21 10:05:20 +00:00
|
|
|
# Write selected wallpaper into .cache files
|
2023-10-02 08:51:16 +00:00
|
|
|
# -----------------------------------------------------
|
2023-12-21 10:05:20 +00:00
|
|
|
echo "$wallpaper" > "$cache_file"
|
|
|
|
echo "* { current-image: url(\"$wallpaper\", height); }" > "$rasi_file"
|
2023-10-02 08:51:16 +00:00
|
|
|
|
2023-09-18 20:13:15 +00:00
|
|
|
sleep 1
|
2023-04-10 15:04:46 +00:00
|
|
|
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-04-08 14:26:43 +00:00
|
|
|
# Send notification
|
2023-08-20 09:46:46 +00:00
|
|
|
# -----------------------------------------------------
|
2023-09-20 11:56:57 +00:00
|
|
|
notify-send "Colors and Wallpaper updated" "with image $newwall"
|
2023-03-06 16:55:42 +00:00
|
|
|
echo "Done."
|