summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorluukvbaal <31730729+luukvbaal@users.noreply.github.com>2019-05-30 16:54:38 +0200
committerGitHub <noreply@github.com>2019-05-30 16:54:38 +0200
commit70257daa83fee7a9ac0563d9a2d86991d0031dd8 (patch)
tree5bf22e7c9a9b3dedc68c98806fbdaa3cfac702ff /bin
parent5d72b5da981f8c71b7fe47997b7fd309e6e861cd (diff)
parent2157be7cec510dc6386f37cb7b8e6abc1dfe6ced (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mailsync2
-rwxr-xr-xbin/muttimage12
-rwxr-xr-xbin/mw20
-rwxr-xr-xbin/openfile5
4 files changed, 25 insertions, 14 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 387ce65..1ef2155 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -40,7 +40,7 @@ syncandnotify() {
fi
}
-# Run
+# Sync accounts passed as argument or all.
if [ "$#" -eq "0" ]; then
accounts="$(ls "$HOME/.local/share/mail")"
else
diff --git a/bin/muttimage b/bin/muttimage
index 03bd5f3..c798293 100755
--- a/bin/muttimage
+++ b/bin/muttimage
@@ -1,5 +1,11 @@
#!/bin/bash
-height=$(stty size | awk 'BEGIN {FS = " "} {print $1;}')
-width=$(stty size | awk 'BEGIN {FS = " "} {print $2;}')
+
+#get image resolution
+resolution=$(identify $1 | awk '{print $3}')
+IFS='x' # x is set as delimiter
+read -ra ADDR <<< "$resolution"
+width=${ADDR[0]}
+height=${ADDR[1]}
+
### Display Image / offset with mutt bar
-echo -e "2;3;\n0;1;210;20;$((width*7-250));$((height*14-100));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay &
+echo -e "2;3;\n0;1;0;42;$((width));$((height));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay &
diff --git a/bin/mw b/bin/mw
index 636a837..f8c4f24 100755
--- a/bin/mw
+++ b/bin/mw
@@ -1,13 +1,17 @@
#!/bin/sh
command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
-! "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 && printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n" && exit
+[ -r "$HOME/.password-store/.gpg-id" ] &&
+ "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 || {
+ printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n"
+ exit
+ }
! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
-if [[ "$OSTYPE" == "darwin"* ]]; then
- prefix="/usr/local"
-else
- prefix="/usr"
-fi
+case "$(uname)" in
+ Linux) prefix="/usr" ;;
+ *) prefix="/usr/local" ;;
+esac
+
muttdir="$HOME/.config/mutt" # Main mutt config location
accdir="$muttdir/accounts" # Directory for account settings
maildir="$HOME/.local/share/mail" # Location of mail storage
@@ -212,7 +216,7 @@ tryconnect() { mkdir -p "$maildir/$title"
fi ;}
finalize() { \
- boxes="$(find "$maildir/$title/" -mindepth 1 -maxdepth 1 | sed "s/^.*\//=/")"
+ boxes="$(find "$maildir/$title/" -mindepth 1 -maxdepth 1 | sed "s/\ /\\\ /g;s/^.*\//=/")"
[ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && return
printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n"
spoolfile=$(echo "$boxes" | grep -i -m 1 inbox | sed 's/=/+/g')
@@ -309,6 +313,8 @@ synchronize_flags=true
gpg_path=$GPG"
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;}
+trap 'echo -e "\033[0m\n"' INT
+
case "$1" in
ls) list ;;
add) asktype && askinfo && tryconnect && finalize || delete ;;
diff --git a/bin/openfile b/bin/openfile
index a3163f3..e530b3e 100755
--- a/bin/openfile
+++ b/bin/openfile
@@ -1,9 +1,8 @@
#!/bin/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"
-base=$(basename "$1")
-ext="${base##*.}"
-file=$(mktemp -u --suffix=".$ext")
+mkdir -p "/tmp/$USER-mutt-tmp"
+file="/tmp/$USER-mutt-tmp/$(basename "$1")"
rm -f "$file"
cp "$1" "$file"
$opener "$file" >/dev/null 2>&1 &