Procházet zdrojové kódy

add support for OpenBSD

use gsed/gawk/grep on OpenBSD, also replace pidof with pgrep for
detecting existing process.
pull/744/head
Yifei Zhan před 2 roky
rodič
revize
5034a6afc2
2 změnil soubory, kde provedl 25 přidání a 1 odebrání
  1. +18
    -1
      bin/mailsync
  2. +7
    -0
      bin/mw

+ 18
- 1
bin/mailsync Zobrazit soubor

@@ -11,10 +11,16 @@
# issues. It also should at least be compatible with Linux (and maybe BSD) with
# Xorg and MacOS as well.

if [ "$(uname)" == 'OpenBSD' ]; then
alias grep=ggrep
alias sed=gsed
alias awk=gawk
fi

# 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
pidof mbsync >/dev/null && { echo "mbsync is already running."; exit ;}
pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;}

# First, we have to get the right variables for the mbsync file, the pass
# archive, notmuch and the GPG home. This is done by searching common profile
@@ -35,6 +41,17 @@ case "$(uname)" in
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
;;
OpenBSD)
displays="$(pgrep -lf X11R6 | grep -wo "[0-9]*:[0-9]\+" | sort -u)"
notify() { [ -n "$displays" ] && for x in ${displays:-0:}; do
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account."
done ;}
messageinfo() { [ -n "$displays" ] && for x in ${displays:-0:}; do
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "📧$from:" "$subject"
done ;}
;;
*)
case "$(readlink -f /sbin/init)" in
*systemd*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;;


+ 7
- 0
bin/mw Zobrazit soubor

@@ -13,6 +13,13 @@ mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config"
alias mbsync='mbsync -c "$mbsyncrc"'
acctseq="1 2 3 4 5 6 7 8 9"

if [ "$(uname)" == 'OpenBSD' ]; then
alias grep=ggrep
alias sed=gsed
alias awk=gawk
fi


for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"; do
[ -f "$x" ] && sslcert="$x" && break
done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;}


Načítá se…
Zrušit
Uložit