]> git.rmz.io Git - dotfiles.git/commitdiff
bin: add maif, a wrapper around maim with auto filename
authorSamir Benmendil <me@rmz.io>
Sat, 6 Feb 2021 14:09:44 +0000 (14:09 +0000)
committerSamir Benmendil <me@rmz.io>
Sat, 6 Feb 2021 14:09:44 +0000 (14:09 +0000)
bin/maif [new file with mode: 0755]

diff --git a/bin/maif b/bin/maif
new file mode 100755 (executable)
index 0000000..e4e1d2a
--- /dev/null
+++ b/bin/maif
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+set -e
+
+version="0.1"
+
+function usage ()
+{
+    echo "Usage :  $0 [options] [FILE]
+
+    MAke Image File
+
+    Takes a screenshot using maim and saves it to FILE. If FILE is
+    not given it defaults to current timestamp, and geometry of
+    selection.
+
+    Options:
+    -h,--help       Display this message"
+}
+
+# Parse arguments
+declare -a args
+while [[ $# -gt 0 ]]; do
+    opt="$1"
+
+    case $opt in
+        -h|--help)     usage; exit 0 ;;
+        -* )
+            echo -e "\n  Option does not exist : $opt\n"
+            usage; exit 1 ;;
+
+        *) args+=("$opt"); shift ;;
+    esac
+done
+
+geometry="$(slop)"
+file="$(date "+%FT%T_${geometry%%+*}_maif.png")"
+maim --geometry="${geometry}" $file