Last active
March 31, 2020 20:11
-
-
Save PedroHLC/2bce4cb268e51c9e33f9701192246c19 to your computer and use it in GitHub Desktop.
Automatically downloads wallpapers from https://t.me/shingekinowall
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
#!/usr/bin/env sh | |
set -o errexit | |
_local="$HOME/.local/bin" | |
[ -n `echo $PATH | grep "${_local}"` ] || \ | |
export PATH="$PATH:${_local}" | |
which telegram-download 1>2 2>/dev/null || \ | |
pip install --user telegram-upload | |
_dest=`xdg-user-dir PICTURES` | |
[ -z "${_dest}" ] && _dest="$HOME/Pictures" | |
_dest="${_dest}/ShingekiNoWall" | |
mkdir -p "${_dest}" | |
pushd "${_dest}" | |
telegram-download --from 'shingekinowall' | |
popd | |
_service_dir="$HOME/.config/systemd/user" | |
_service="${_service_dir}/shingekinowall.service" | |
_timer="${_service_dir}/shingekinowall.timer" | |
install_service() { | |
[ -d "${_local}" ] || mkdir -p "${_local}" | |
cp "$0" "${_local}/shingekinowall" | |
mkdir -p "${_service_dir}" | |
tee "$_service" > /dev/null <<EOF | |
[Unit] | |
Description=Downloads shingekinowall images | |
[Service] | |
ExecStart="${_local}/shingekinowall" | |
[Install] | |
WantedBy=default.target | |
EOF | |
tee "$_timer" > /dev/null <<EOF | |
[Unit] | |
Description=Once per day automation | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target | |
EOF | |
systemctl --user start shingekinowall.timer | |
systemctl --user enable shingekinowall.timer | |
} | |
[ -f "${_service}" ] || install_service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment