Add autocategorize service
This commit is contained in:
parent
0c5d0a80b5
commit
c4c00a8701
40
base/.config/systemd/user/autocategorize
Executable file
40
base/.config/systemd/user/autocategorize
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Pull in user-dirs.dirs if it exists
|
||||||
|
userdirs="${XDG_CONFIG_DIR:-$HOME/.config}"/user-dirs.dirs
|
||||||
|
[ -f "$userdirs" ] && . "$userdirs"
|
||||||
|
# Obtain download directory from there, otherwise use default
|
||||||
|
downloaddir="${XDG_DOWNLOAD_DIR:-$HOME/Downloads}"
|
||||||
|
documentsdir="${XDG_DOCUMENTS_DIR:-$HOME/Documents}"
|
||||||
|
picturesdir="${XDG_PICTURES_DIR:-$HOME/Pictures}"
|
||||||
|
|
||||||
|
# Sort out downloads
|
||||||
|
[ -e "$downloaddir" ] && {
|
||||||
|
# Sort out epubs
|
||||||
|
if [ -d ~/Books ]; then
|
||||||
|
echo "Sorting out books..."
|
||||||
|
find "$downloaddir" \
|
||||||
|
-type f \
|
||||||
|
-iname "*.epub" -or \
|
||||||
|
-iname "*.mobi" \
|
||||||
|
-print \
|
||||||
|
-exec mv {} ~/Books \;
|
||||||
|
fi
|
||||||
|
# Remove anything that's wicked old
|
||||||
|
echo "Removing ancient downloads..."
|
||||||
|
find "$downloaddir" \
|
||||||
|
-mtime +180 \
|
||||||
|
-print -delete
|
||||||
|
# Remove anything kinda old but really big
|
||||||
|
echo "Removing large downloads..."
|
||||||
|
find "$downloaddir" \
|
||||||
|
-mtime +30 -size 10M \
|
||||||
|
-print -delete
|
||||||
|
# Remove zips, but at a lower tolerance
|
||||||
|
echo "Removing old zips..."
|
||||||
|
find "$downloaddir" \
|
||||||
|
-mtime +30 -type f -iname "*.zip" \
|
||||||
|
-print -delete
|
||||||
|
}
|
9
base/.config/systemd/user/autocategorize.service
Normal file
9
base/.config/systemd/user/autocategorize.service
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# vim:ft=systemd:
|
||||||
|
[Unit]
|
||||||
|
Description=Autocategorize service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=%h/.config/systemd/user/autocategorize
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
11
base/.config/systemd/user/autocategorize.timer
Normal file
11
base/.config/systemd/user/autocategorize.timer
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# vim:ft=systemd:
|
||||||
|
[Unit]
|
||||||
|
Description=Autocategorize timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
Persistent=true
|
||||||
|
OnBootSec=15min
|
||||||
|
OnCalendar=*-*-* 22:00:00
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
Loading…
Reference in New Issue
Block a user