brendotools-wallman/wpset

80 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# WPDL
VERSION="0.1-rev81"
CONF="/home/$USER/.config/wpdl.conf"
source $CONF
# updater
if [ "$1" = "-u" ]; then
curl sftp://$HOST_DISP/home/$SSH_USER/bin/wpset-update -u $SSH_USER: | bash
exit
fi
# version
if [ "$1" = "-v" ]; then
echo "v$VERSION"
exit
fi
# set last wp
if [ "$1" = "last" ]; then
feh --bg-max $WALL_LOC/$LAST
exit
fi
function wplist() {
curl -u $SSH_USER: sftp://$SSH_HOST/home/$SSH_USER/wp.list
}
function listupdate() {
echo "updating wallpaper list..."
ssh $SSH_USER@$SSH_HOST "bash /home/$SSH_USER/bin/wplist" &> /dev/null
}
listupdate
if [ -z "$1" ]; then
echo "usage: wpset <wallpaper name>"
echo "to list available wallpapers: wpset -l"
echo "[for startup script] to set last wp: wpset last"
exit
fi
# wallpaper list
if [ "$1" = "-l" ]; then
wplist
exit
fi
if [ "$1" = "list" ]; then
wplist
exit
fi
# check for locally installed walls and set em if it's there
WPCHECK=$(ls $WALL_LOC | grep $1)
if [ "$WPCHECK" = "$1" ]; then
feh --bg-max $WALL_LOC/$1
echo "$1" > $WALL_LOC/.lastwp
exit
else
# wallpaper lookup
WPLIST=$(wplist | grep $1)
if [ "$WPLIST" = "$1" ]; then
# download the actual script
curl -s sftp://$SSH_HOST/home/$SSH_USER/bin/wpdl -u $SSH_USER: -o wpdl
chmod +x wpdl
clear
$PWD/wpdl $*
rm wpdl
[ -e wp.list ] && rm $PWD/wp.list
else
clear
echo "could not find the wallpaper you requested, here's a list of what's available:"
wplist
fi
fi