summaryrefslogtreecommitdiff
path: root/debian/.local/bin/cron
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
commit28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch)
tree85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/cron
parent8470ff001befcfd0f626dea69a9e76d43aee0511 (diff)
updates
Diffstat (limited to 'debian/.local/bin/cron')
-rw-r--r--debian/.local/bin/cron/README.md11
-rwxr-xr-xdebian/.local/bin/cron/crontog26
-rwxr-xr-xdebian/.local/bin/cron/mediaup34
-rwxr-xr-xdebian/.local/bin/cron/newsup15
4 files changed, 86 insertions, 0 deletions
diff --git a/debian/.local/bin/cron/README.md b/debian/.local/bin/cron/README.md
new file mode 100644
index 0000000..fa0c354
--- /dev/null
+++ b/debian/.local/bin/cron/README.md
@@ -0,0 +1,11 @@
+# Important Note
+
+These cronjobs have components that require information about your current display to display notifications correctly.
+
+When you add them as cronjobs, I recommend you precede the command with commands as those below:
+
+```
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here
+```
+
+This ensures that notifications will display, xdotool commands will function and environmental variables will work as well.
diff --git a/debian/.local/bin/cron/crontog b/debian/.local/bin/cron/crontog
new file mode 100755
index 0000000..70e7cf1
--- /dev/null
+++ b/debian/.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}"
diff --git a/debian/.local/bin/cron/mediaup b/debian/.local/bin/cron/mediaup
new file mode 100755
index 0000000..85935a2
--- /dev/null
+++ b/debian/.local/bin/cron/mediaup
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+timestamp_file="${HOME}/.cache/ytdlpupdate"
+current_time=$(date +%s)
+
+# Create cache directory if it doesn't exist
+mkdir -p "${HOME}/.cache"
+
+# Check if the timestamp file exists and is less than 24 hours old
+if [ -f "$timestamp_file" ] && [ "$(cat "$timestamp_file")" -gt "$((current_time - 86400))" ]; then
+ exit 0
+fi
+
+# Check if pipx is available, install if not
+if ! command -v pipx >/dev/null 2>&1; then
+ python3 -m pip install --user pipx || exit 1
+ python3 -m pipx ensurepath || exit 1
+ if [ -f "${ZDOTDIR:-${HOME}/.config/zsh}/.zshrc" ]; then
+ # shellcheck source=${ZDOTDIR:-${HOME}/.config/zsh}/.zshrc
+ . "${ZDOTDIR:-${HOME}/.config/zsh}/.zshrc"
+ elif [ -f "${HOME}/.zshrc" ]; then
+ # shellcheck source=${HOME}/.zshrc
+ . "${HOME}/.zshrc"
+ fi
+fi
+
+# Check if yt-dlp is installed via pipx, install or upgrade it
+if ! pipx list | grep -q yt-dlp; then
+ pipx install yt-dlp || exit 1
+else
+ pipx upgrade yt-dlp || exit 1
+fi
+
+echo "$current_time" >"$timestamp_file"
diff --git a/debian/.local/bin/cron/newsup b/debian/.local/bin/cron/newsup
new file mode 100755
index 0000000..346ec75
--- /dev/null
+++ b/debian/.local/bin/cron/newsup
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Set as a cron job to check for new RSS entries for newsboat.
+# If newsboat is open, sends it an "R" key to refresh.
+
+/usr/bin/notify-send "📰 Updating RSS feeds..."
+
+pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit
+
+echo 🔃 >/tmp/newsupdate
+pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}"
+/usr/bin/newsboat -x reload
+rm -f /tmp/newsupdate
+pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}"
+/usr/bin/notify-send "📰 RSS feed update complete."