Created
October 17, 2017 19:12
-
-
Save CalebWhiting/7016c58747e7a3d3ef4db5e9b2bbfc78 to your computer and use it in GitHub Desktop.
update-wallpapers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# (re)generates a .xml file pointing to a list of wallpapers found withing ~/.wallpapers, these pictures | |
# should then be visible within the 'Wallpapers' tab of the gnome wallpaper switcher. | |
# | |
# This needs to be ran as root. | |
# Optionally you can change the permissions of the directory '/usr/share/gnome-background-properties/' | |
# and it's contents to allow user r/w | |
# | |
WALLPAPERS="$HOME/.wallpapers" | |
if [ ! -d "$WALLPAPERS" ] && [ ! $(mkdir -m=777 "$WALLPAPERS") ] | |
then | |
echo "ERROR: Couldn't create wallpapers directory: $WALLPAPERS" | |
exit -1; | |
fi | |
{ | |
echo '<wallpapers>' | |
while read -rd $'\0' path | |
do | |
echo ' <wallpaper>' | |
echo " <name>${path#[.]*}</name>" | |
echo " <filename>${path}</filename>" | |
echo ' <pcolor>#000000</pcolor>' | |
echo ' <scolor>#000000</scolor>' | |
echo ' <options>zoom</options>' | |
echo ' <shade_type>solid</shade_type>' | |
echo ' </wallpaper>' | |
done < <(find "$WALLPAPERS" -type f -regextype posix-extended -regex '.*[.](jpg|jpeg|png|svg)' -print0) | |
echo '</wallpapers>' | |
} > '/usr/share/gnome-background-properties/wallpapers.xml' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment