diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mailsync | 9 | ||||
-rwxr-xr-x | bin/muttimage | 4 | ||||
-rwxr-xr-x | bin/mw | 23 | ||||
-rwxr-xr-x | bin/openfile | 2 |
4 files changed, 27 insertions, 11 deletions
diff --git a/bin/mailsync b/bin/mailsync index d79507d..f7c3211 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -2,12 +2,13 @@ # 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 -export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus +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) -pgrep -u "$USER" >/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 pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} @@ -47,7 +48,7 @@ else fi echo " 🔃" > /tmp/imapsyncicon_"$USER" -pkill -RTMIN+12 i3blocks >/dev/null 2>&1 +pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1 # Parallelize multiple accounts for account in $accounts @@ -57,7 +58,7 @@ done wait rm -f /tmp/imapsyncicon_"$USER" -pkill -RTMIN+12 i3blocks >/dev/null 2>&1 +pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1 notmuch new 2>/dev/null diff --git a/bin/muttimage b/bin/muttimage index c798293..a846bea 100755 --- a/bin/muttimage +++ b/bin/muttimage @@ -1,9 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash #get image resolution resolution=$(identify $1 | awk '{print $3}') IFS='x' # x is set as delimiter -read -ra ADDR <<< "$resolution" +read -ra ADDR <<< "$resolution" width=${ADDR[0]} height=${ADDR[1]} @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && @@ -69,6 +69,7 @@ Patterns * !\"[Gmail]/All Mail\" Create Both SyncState * MaxMessages $maxmes +ExpireUnread no # End profile " @@ -130,8 +131,22 @@ askinfo() { \ printf "\033[0m" done domain="$(echo "$fulladdr" | sed "s/.*@//")" + search_query=$domain + case "$domain" in + protonmail.com|protonmail.ch|pm.me) + search_query='protonmail.com' && break;; + *) + while : ; do + printf "\nIs your email hosted with Protonmail? [yes/no] " + read -r is_protonmail + case $is_protonmail in + [Yy][Ee][Ss]) search_query='protonmail.com' && break;; + [Nn][Oo]) break;; + *) printf 'Please answer Yes or No' + esac; done; + esac printf "\\nSearching for \033[32m%s\033[0m in \033[34m\`domains.csv\`\033[0m..." "$domain" - serverinfo="$(grep "^$domain" "$muttshare/domains.csv" 2>/dev/null)" + serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" if [ -z "$serverinfo" ]; then printf "Your email domain is not in mutt-wizard's database yet.\\nmutt-wizard will still autoconfigure everything, but you will have to manually type in your service's IMAP and SMTP server information.\\nYou can usually quickly find this by internet searching for it.\\n" printf "Insert the IMAP server for your email provider (excluding the port number)\\n\033[36m\t" @@ -190,7 +205,7 @@ EOF } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" - fingerprint="$(msmtp --serverinfo --host=127.0.0.1 --port=1025 --tls --tls-certcheck=off)" || return 1 + fingerprint="$(msmtp --serverinfo --host=127.0.0.1 --port=1025 --tls --tls-certcheck=off | grep SHA256: | sed 's/^.*: //')" sed -ibu "s/account $title/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu } @@ -224,7 +239,7 @@ finalize() { \ trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g') sed -ibu "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc" - echo "mailboxes =$title ===================== $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc" + echo "mailboxes $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc" printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" sed -ibu "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox diff --git a/bin/openfile b/bin/openfile index e530b3e..b16483b 100755 --- a/bin/openfile +++ b/bin/openfile @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Helps open a file with xdg-open from mutt in a external program without weird side effects. [ $(uname) = "Darwin" ] && opener="open" || opener="setsid xdg-open" mkdir -p "/tmp/$USER-mutt-tmp" |