blob: 70e7cf1e730a958c2e67ae44d5e3daab76da7436 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/crons until restored.
cron_file="${XDG_CONFIG_HOME:-$HOME/.config}/crons"
# Check if there are any active cronjobs
if crontab -l 2>/dev/null | grep -q '^[^#[:space:]]'; then
# If active cronjobs are found, save and disable them
ln -sf "${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/$(whereami)/.config/crons" "${XDG_CONFIG_HOME:-${HOME}/.config}/crons"
crontab -r
notify-send "⏰ Cronjobs saved and disabled."
else
# If no active cronjobs are found, try re-enabling from saved file
if [ -f "$cron_file" ]; then
crontab - <"$cron_file"
rm "$cron_file"
notify-send "🕓 Cronjobs re-enabled."
else
notify-send "🕰️ No saved cronjobs to re-enable."
fi
fi
# Notify status bar to update
pkill -RTMIN+3 "${STATUSBAR:-dwmblocks}"
|