Xmd/session/src/xmd-load-wallpaper

56 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
name=`basename "$0"`
configFilePath="$XMD_USERDIR/wallpaper"
isInstalled() {
type "$1" > /dev/null
}
shouldHaveInstalled() {
if ! isInstalled "$1"; then
echo "$name: $1 is not installed" >&2
return 1
fi
}
usage() {
echo "Usage: $name" >&2
exit 2
}
[ "$#" -gt 0 ] && usage
echo $configFilePath
if type "$configFilePath" > /dev/null; then
color="black"
while read -r line; do
line=`echo $line | sed s/\#.\*$//g`
[ -z "$line" ] && continue
IFS="=" read key value << EOF
$line
EOF
case "$key" in
"mode") mode="$value";;
"file") file="$value";;
"color") color="$value";;
*) 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