From c80a54e42b52ce297f0f2f71af23c562832025c7 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:35:27 +0900 Subject: init --- ar/.local/bin/cron/crontog | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 ar/.local/bin/cron/crontog (limited to 'ar/.local/bin/cron/crontog') diff --git a/ar/.local/bin/cron/crontog b/ar/.local/bin/cron/crontog new file mode 100755 index 0000000..9ebab9c --- /dev/null +++ b/ar/.local/bin/cron/crontog @@ -0,0 +1,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}" -- cgit v1.2.3