commit 964653fbcafa271246ae1e1142a0b46780ccb40d
parent 123e8c7a125ce4492af2e18f40abb89eafbdc633
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri, 6 May 2022 16:59:31 +0200
Added mblaze-extra (used to be a shell config file)
Diffstat:
2 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -18,6 +18,7 @@ SCRIPTS = addressgrep \
ffmpeg-facecam \
mail-checknow \
mail-compose \
+ mblaze-extras \
open-file \
open-stdin \
open-url \
diff --git a/mblaze-extras b/mblaze-extras
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# Useful extra commands for mblaze
+
+# Requires: mblaze, mpop
+
+# Usage: mblaze-extras command
+# List of commands:
+# get [filter]
+# mv [folder]
+# pick [field]
+# save
+# scan [folder]
+
+menu=${MENU:-dmenu}
+mdir=$HOME/mail
+mpopdir=$HOME/.config/mpop
+
+mbextra_scan() {
+ folder=${1:-inbox}
+ mlist -t $mdir/$1 | mthread | mseq -S
+ mscan
+}
+
+mbextra_get() {
+ mpop --filter=$mpopdir/filter-$1.sh
+ minc -q $mdir/inbox
+ mbextra_scan inbox
+}
+
+mbextra_pick() {
+ field=$1
+ shift
+ mpick -t "$field =~~ \"$@\""
+}
+
+mbextra_save() {
+ dir=$2
+ [ -z "$dir" ] && dir=$(dmenu-filepicker)
+ mkdir -p "$dir"
+
+ if [ ! -d "$dir" ]; then
+ echo "No directory selected, skipping."
+ else
+ cd "$dir"
+ mshow -x $1
+ fi
+}
+
+if [ -z "$1" ]; then
+ echo "Usage: mblaze-extras COMMAND"
+elif [ "$1" = "scan" ]; then
+ mbextra_scan $2
+elif [ "$1" = "mv" ]; then
+ folder=$2
+ if [ -n "$folder" ]; then
+ shift; shift
+ echo $@ $mdir/$folder | xargs mrefile
+ else
+ echo "No folder given, not moved"
+ fi
+elif [ "$1" = "get" ]; then
+ mbextra_get $2
+elif [ "$1" = "save" ]; then
+ shift
+ mbextra_save $@
+elif [ "$1" = "pick" ]; then
+ shift
+ mbextra_pick $@
+fi