wallpaper image file support

This commit is contained in:
Stephan Raabe
2023-12-21 11:05:20 +01:00
parent 9033dbf59b
commit 88a73b7039
18 changed files with 88 additions and 28 deletions
+23 -4
View File
@@ -9,12 +9,30 @@
# by Stephan Raabe (2023)
# -----------------------------------------------------
# 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")
case $1 in
# Load wallpaper from .cache of last session
"init")
if [ -f ~/.cache/current_wallpaper.jpg ]; then
wal -q -c -i ~/.cache/current_wallpaper.jpg
if [ -f $cache_file ]; then
wal -q -i $current_wallpaper
else
wal -q -i ~/wallpaper/
fi
@@ -48,9 +66,10 @@ source "$HOME/.cache/wal/colors.sh"
echo "Wallpaper: $wallpaper"
# -----------------------------------------------------
# Copy selected wallpaper into .cache folder
# Write selected wallpaper into .cache files
# -----------------------------------------------------
cp $wallpaper ~/.cache/current_wallpaper.jpg
echo "$wallpaper" > "$cache_file"
echo "* { current-image: url(\"$wallpaper\", height); }" > "$rasi_file"
# -----------------------------------------------------
# get wallpaper image name
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash
_getHeader "$name" "$author"
echo "$homepage ($email)"
echo "ML4W dotfiles Version 2.7"
echo "Settings Version" $(_getVersion)
echo ""
echo $description
@@ -2,6 +2,9 @@
_getHeader "$name" "$author"
if gum confirm "Do you want to update the SDDM background with the current wallpaper?" ;then
cache_file="$HOME/.cache/current_wallpaper"
if [ ! -d /etc/sddm.conf.d/ ]; then
sudo mkdir /etc/sddm.conf.d
echo "Folder /etc/sddm.conf.d created."
@@ -10,11 +13,15 @@ if gum confirm "Do you want to update the SDDM background with the current wallp
sudo cp ~/dotfiles/sddm/sddm.conf /etc/sddm.conf.d/
echo "File /etc/sddm.conf.d/sddm.conf updated."
sudo cp ~/.cache/current_wallpaper.jpg /usr/share/sddm/themes/sugar-candy/Backgrounds/
echo "Current wallpaper copied into /usr/share/sddm/themes/sugar-candy/Backgrounds/"
current_wallpaper=$(cat "$cache_file")
extension="${current_wallpaper##*.}"
sudo cp $current_wallpaper /usr/share/sddm/themes/sugar-candy/Backgrounds/current_wallpaper.$extension
echo "Current wallpaper copied into /usr/share/sddm/themes/sugar-candy/Backgrounds/"
new_wall=$(echo $current_wallpaper | sed "s|$HOME/wallpaper/||g")
sudo cp ~/dotfiles/sddm/theme.conf /usr/share/sddm/themes/sugar-candy/
echo "File theme.conf updated in /usr/share/sddm/themes/sugar-candy/"
sudo sed -i 's/CURRENTWALLPAPER/'"current_wallpaper.$extension"'/' /usr/share/sddm/themes/sugar-candy/theme.conf
echo ""
echo "SDDM background successfully updated!"