Wallpaper script supports color, no longer sources conf file

This commit is contained in:
Sasha Koshka 2024-01-31 13:23:26 -05:00
parent 720ddd3d99
commit 03290f61e7

View File

@ -1,9 +1,51 @@
#!/bin/sh #!/bin/sh
if type "$XMD_USERDIR/wallpaper" > /dev/null; then name=`basename "$0"`
. "$XMD_USERDIR/wallpaper" configFilePath="$XMD_USERDIR/wallpaper"
if type xwallpaper > /dev/null; then isInstalled() {
xwallpaper "--${mode}" "$file" type "$1" > /dev/null
}
shouldHaveInstalled() {
if ! isInstalled "$1"; then
echo "$name: $1 is not installed" >&2
return 1
fi fi
}
usage() {
echo "Usage: $name" >&2
exit 2
}
[ "$#" -gt 0 ] && usage
if type "$configFilePath" > /dev/null; then
color="black"
while read -r line; do
IFS="=" read key value << EOF
$line
EOF
case "$key" in
"mode") mode="$value";;
"file") file="$value";;
"color") color="$color";;
*) echo "$name: bad key $key in $configFilePath" >&2;;
esac
done < "$configFilePath"
case "$mode" in
"" | center | focus | maximize | stretch | tile | zoom) ;;
*)
echo "$name: bad mode $mode" >&2
exit 1
;;
esac
[ -n color ] && shouldHaveInstalled xsetroot && \
xsetroot -solid "$color"
[ -n mode ] && shouldHaveInstalled xwallpaper && \
xwallpaper "--${mode}" "$file"
fi fi