diff options
Diffstat (limited to 'mailsync')
-rwxr-xr-x | mailsync | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -28,9 +28,10 @@ eval "$(grep -h -- \ "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ "$HOME/.pam_environment" 2>/dev/null)" -export GPG_TTY="$(tty)" +GPG_TTY="$(tty)" +export GPG_TTY -[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.config/isync/mbsyncrc" +[ -n "$MBSYNCRC" ] && alias mbsync='mbsync -c $MBSYNCRC' || MBSYNCRC="$HOME/.config/isync/mbsyncrc" # Settings are different for MacOS (Darwin) systems. case "$(uname)" in @@ -39,13 +40,16 @@ case "$(uname)" in ;; *) case "$(readlink -f /sbin/init)" in - *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; + *systemd*|*openrc*) + DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus + export DBUS_SESSION_BUS_ADDRESS + ;; esac # remember if a display server is running since `ps` doesn't always contain a display pgrepoutput="$(pgrep -a 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 + export DISPLAY="$x" notify-send --app-name="mutt-wizard" "New mail!" "📬 $2 new mail(s) in \`$1\` account." done ;} ;; @@ -64,7 +68,8 @@ syncandnotify() { "$HOME/.local/share/mail/$acc/inbox/cur/"\ -type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" 2> /dev/null) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) - case 1 in + one="1" + case "$one" in $((newcount > 0)) ) notify "$acc" "$newcount" ;; esac } @@ -74,7 +79,7 @@ if [ "$#" -eq "0" ]; then accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" else for arg in "$@"; do - [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 + [ "${arg%"${arg#?}"}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 done accounts=$* fi |