From f2014408b984c7e5814d1021cab55624cbed7ae6 Mon Sep 17 00:00:00 2001 From: Kr1ss Date: Tue, 31 May 2022 18:19:40 +0200 Subject: fix notifications when the Xorg process is just X To close #845 : I added the `-x` flag to prevent the regex from matching on _every_ pro- cess name containing an `X`. Because I'm not entirely sure about portability (does every `pgrep` va- riant support that flag), I didn't push this directly. So what do you think @LukeSmithxyz ? --- bin/mailsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index 97cd224..2f32c14 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -42,7 +42,7 @@ case "$(uname)" in *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; esac # remember if a display server is running since `ps` doesn't always contain a display - pgrepoutput="$(pgrep -a X\(org\|wayland\))" + pgrepoutput="$(pgrep -ax X\(\|org\|wayland\))" displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)" notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do export DISPLAY=$x -- cgit v1.2.3 From 3a2f4a55fa966a6c095639193cb9ab1f3a3d8229 Mon Sep 17 00:00:00 2001 From: f380cedric Date: Fri, 10 Jun 2022 18:16:29 +0200 Subject: Fix: find & case-insensitive filesystem On case-insensitive filesystem, `inbox` and `Inbox` are the same path. Running `find Inbox inbox [expr]` will print twice the same information. Use shell glob instead: `find` will descend into path `inbox`, ignoring letter cases, only once. Fix #828. --- bin/mailsync | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index 2f32c14..0d2983f 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -56,12 +56,8 @@ syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi new=$(find\ - "$HOME/.local/share/mail/$acc/INBOX/new/"\ - "$HOME/.local/share/mail/$acc/Inbox/new/"\ - "$HOME/.local/share/mail/$acc/inbox/new/"\ - "$HOME/.local/share/mail/$acc/INBOX/cur/"\ - "$HOME/.local/share/mail/$acc/Inbox/cur/"\ - "$HOME/.local/share/mail/$acc/inbox/cur/"\ + "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/new/\ + "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/cur/\ -type f -newer "$lastrun" 2> /dev/null) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) case 1 in -- cgit v1.2.3 From 367c10ec3f16c3c11e1a5de980bc95dd4fa6bf79 Mon Sep 17 00:00:00 2001 From: jw Date: Fri, 1 Jul 2022 00:12:04 +0200 Subject: Silence mailsync, so cron doesn't spam e-mails on every update --- bin/mailsync | 7 +++---- bin/mw | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index 2f32c14..6aba835 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -70,14 +70,13 @@ syncandnotify() { } # Sync accounts passed as argument or all. -if [ "$#" -eq "0" ]; then - accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" -else +if [ "$#" -gt "0" ]; then for arg in "$@"; do [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 done accounts=$* fi +[[ ! $accounts ]] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" # Parallelize multiple accounts for account in $accounts; do @@ -86,7 +85,7 @@ done wait -notmuch new 2>/dev/null +notmuch new --quiet #Create a touch file that indicates the time of the last run of mailsync touch "$lastrun" diff --git a/bin/mw b/bin/mw index d8d4d73..8a89a17 100755 --- a/bin/mw +++ b/bin/mw @@ -262,7 +262,7 @@ togglecron() { cron="$(mktemp)" sed -ibu /mailsync/d "$cron"; rm -f "$cron"bu else echo "Adding automatic mailsync every ${cronmin:-10} minutes..." - echo "*/${cronmin-10} * * * * $prefix/bin/mailsync" >> "$cron" + echo "*/${cronmin:-10} * * * * $prefix/bin/mailsync -q" >> "$cron" fi && crontab "$cron"; rm -f "$cron" ;} -- cgit v1.2.3 From caf2681891eb3fbe04bd10ba30369ffe8e8616d4 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jul 2022 10:00:34 -0400 Subject: remove bashism --- bin/mailsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index 6aba835..f100cd0 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -76,7 +76,7 @@ if [ "$#" -gt "0" ]; then done accounts=$* fi -[[ ! $accounts ]] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" +[ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" # Parallelize multiple accounts for account in $accounts; do -- cgit v1.2.3 From 30c1c0d2ae1ea4439986b1868557bbd2cc9e297a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jul 2022 17:35:52 -0400 Subject: fix #785 since cron now silent --- bin/mailsync | 2 -- 1 file changed, 2 deletions(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index f100cd0..c924de5 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -11,8 +11,6 @@ # issues. It also should at least be compatible with Linux (and maybe BSD) with # Xorg and MacOS as well. -# 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 ;} # Run only if not already running in other instance pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} -- cgit v1.2.3 From f723938a73d3096b6e174437c61924f21978630b Mon Sep 17 00:00:00 2001 From: Parin Jasoliya Date: Thu, 29 Sep 2022 22:32:43 +0530 Subject: Add Support for POP3 Notification --- bin/mailsync | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'bin/mailsync') diff --git a/bin/mailsync b/bin/mailsync index 854e1d1..1dc3d47 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -19,7 +19,7 @@ pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} # files for variable assignments. This is ugly, but there are few options that # will work on the maximum number of machines. eval "$(grep -h -- \ - "^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \ + "^\s*\(export \)\?\(MBSYNCRC\|MPOPRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \ "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \ "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ "$HOME/.pam_environment" 2>/dev/null)" @@ -27,6 +27,7 @@ eval "$(grep -h -- \ export GPG_TTY="$(tty)" [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" +[ -n "$MPOPRC" ] || MPOPRC="$HOME/.config/mpop/config" lastrun="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" @@ -52,7 +53,13 @@ esac # Check account for new mail. Notify if there is new content. syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" - if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + if [ "$1" = "pop" ]; then + # Handle POP + mpop "$acc" + else + # Handle IMAP + if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + fi new=$(find\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/new/\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/cur/\ @@ -70,11 +77,17 @@ if [ "$#" -gt "0" ]; then done accounts=$* fi +# TODO handle account passed from argument [ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" +[ -z "$pop_accounts" ] && pop_accounts="$(awk '/^account/ {print $2}' "$MPOPRC")" # Parallelize multiple accounts for account in $accounts; do - syncandnotify & + syncandnotify "imap" & +done + +for account in $pop_accounts; do + syncandnotify "pop" & done wait -- cgit v1.2.3