2021-08-21 01:56:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# WPDL
|
2021-08-24 02:01:36 +00:00
|
|
|
VERSION="0.1-rev83"
|
2021-08-21 01:56:26 +00:00
|
|
|
CONF="/home/$USER/.config/wpdl.conf"
|
|
|
|
source $CONF
|
|
|
|
|
|
|
|
# updater
|
|
|
|
if [ "$1" = "-u" ]; then
|
2021-08-24 02:01:36 +00:00
|
|
|
# contact tildegit to see if there's a new release
|
|
|
|
WPSET_REL=$(mktemp /tmp/wpset-releases-XXXXX.json)
|
|
|
|
curl -s https://tildegit.org/api/v1/repos/BrendanTCC/brendotools-wallman/releases -o $WPSET_REL
|
|
|
|
DOWNLOAD_VERSION=$(cat $WPSET_REL | jq .[0].tag_name | sed s/\"//g)
|
|
|
|
DOWNLOAD_URL=$(cat $WPSET_REL | jq .[0].assets[0].browser_download_url | sed s/\"//g)
|
|
|
|
DOWNLOAD_FNAME=$(cat $WPSET_REL | jq .[0].assets[0].name | sed s/\"//g)
|
|
|
|
rm $WPSET_REL
|
|
|
|
|
|
|
|
# compare versions
|
|
|
|
WPSET_REMOTEVER=$(echo "$DOWNLOAD_VERSION")
|
|
|
|
WPSET_LOCALVER=$(wpset -v)
|
|
|
|
|
|
|
|
if [ "$WPSET_REMOTEVER" == "$WPSET_LOCALVER" ]; then
|
|
|
|
|
|
|
|
# tell user that there's nothing to do
|
|
|
|
echo "you are already running the latest available version of wallman."
|
2021-08-21 01:56:26 +00:00
|
|
|
exit
|
2021-08-24 02:01:36 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
# download the update
|
|
|
|
cd /home/$USER/
|
|
|
|
wget $DOWNLOAD_URL -o $DOWNLOAD_FNAME
|
|
|
|
unzip $DOWNLOAD_FNAME
|
|
|
|
cd brendotools-wallman
|
2021-08-24 03:09:18 +00:00
|
|
|
|
|
|
|
# install the update
|
2021-08-24 02:01:36 +00:00
|
|
|
mv wpset /bin/wpset
|
|
|
|
chmod +x /bin/wpset
|
|
|
|
cd /home/$USER/
|
|
|
|
rm -rf brendotools-wallman/
|
|
|
|
echo "done."
|
2021-08-21 01:56:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# version
|
|
|
|
if [ "$1" = "-v" ]; then
|
2021-08-22 07:09:36 +00:00
|
|
|
echo "$VERSION"
|
2021-08-21 01:56:26 +00:00
|
|
|
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..."
|
2021-08-21 02:05:08 +00:00
|
|
|
ssh $SSH_USER@$SSH_HOST "bash /home/$SSH_USER/bin/wplist" &> /dev/null
|
2021-08-21 01:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2021-08-21 02:05:08 +00:00
|
|
|
curl -s sftp://$SSH_HOST/home/$SSH_USER/bin/wpdl -u $SSH_USER: -o wpdl
|
2021-08-21 01:56:26 +00:00
|
|
|
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
|