瀏覽代碼

cron fixes and simplifications

tags/v3.1
Luke Smith 4 年之前
父節點
當前提交
4cb726546f
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4C50B54A911F6252
共有 2 個檔案被更改,包括 10 行新增8 行删除
  1. +9
    -7
      bin/mailsync
  2. +1
    -1
      bin/mw

+ 9
- 7
bin/mailsync 查看文件

@@ -1,12 +1,6 @@
#!/usr/bin/env sh
#!/bin/sh
# Sync mail and give notification if there is new mail. # Sync mail and give notification if there is new mail.


export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export DBUS_SESSION_BUS_ADDRESS
export DISPLAY=:0.0
[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store"

# Run only if user logged in (prevent cron errors) # Run only if user logged in (prevent cron errors)
pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;}
# Run only if not already running in other instance # Run only if not already running in other instance
@@ -16,6 +10,14 @@ pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;}
ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; exit ;} ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; exit ;}
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script." command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."


# Required to display notifications if run as a cronjob:
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export DISPLAY=:0.0

# For individual configurations:
[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store"
pgrep i3blocks >/dev/null && STATUSBAR="i3blocks" || STATUSBAR="dwmblocks"

# Settings are different for MacOS (Darwin) systems. # Settings are different for MacOS (Darwin) systems.
if [ "$(uname)" = "Darwin" ]; then if [ "$(uname)" = "Darwin" ]; then
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}


+ 1
- 1
bin/mw 查看文件

@@ -290,7 +290,7 @@ choosecron() { ! pgrep cron >/dev/null && echo "No cron manager running. Install
read -r minnum read -r minnum
printf "\033[0m" printf "\033[0m"
done done
(crontab -l; echo "*/$minnum * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus; export DISPLAY=:0; . \$HOME/.profile; $(type mailsync | cut -d' ' -f3)") | crontab - &&
(crontab -l; echo "*/$minnum * * * * $(type mailsync | cut -d' ' -f3)") | crontab - &&
echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running." echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running."
fi ;} fi ;}




Loading…
取消
儲存