This commit is contained in:
Stephan Raabe
2024-05-23 15:42:03 +02:00
parent 004702f450
commit 150616996f
12 changed files with 65 additions and 35 deletions

View File

@@ -10,6 +10,10 @@
# -----------------------------------------------------
# Cache file for holding the current wallpaper
wallpaper_folder="$HOME/wallpaper"
if [ -f ~/dotfiles/.settings/wallpaper-folder.sh ] ;then
source ~/dotfiles/.settings/wallpaper-folder.sh
fi
cache_file="$HOME/.cache/current_wallpaper"
blurred="$HOME/.cache/blurred_wallpaper.png"
rasi_file="$HOME/.cache/current_wallpaper.rasi"
@@ -17,13 +21,13 @@ 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"
echo "$wallpaper_folder/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"
echo "* { current-image: url(\"$wallpaper_folder/default.jpg\", height); }" > "$rasi_file"
fi
current_wallpaper=$(cat "$cache_file")
@@ -35,26 +39,26 @@ case $1 in
if [ -f $cache_file ]; then
wal -q -i $current_wallpaper
else
wal -q -i ~/wallpaper/
wal -q -i $wallpaper_folder
fi
;;
# Select wallpaper with rofi
"select")
selected=$( find "$HOME/wallpaper" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort -R | while read rfile
selected=$( find "$wallpaper_folder" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort -R | while read rfile
do
echo -en "$rfile\x00icon\x1f$HOME/wallpaper/${rfile}\n"
echo -en "$rfile\x00icon\x1f$wallpaper_folder/${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
wal -q -i $wallpaper_folder/$selected
;;
# Randomly select wallpaper
*)
wal -q -i ~/wallpaper/
wal -q -i $wallpaper_folder/
;;
esac