]> Softwares of Agnibho - imagecap.git/blobdiff - imagecap
Use zenity to edit text
[imagecap.git] / imagecap
index f423723431ac0c263f69b633804b2bcab7405cc2..eec547e6f81eae4e185b68308471cde6b21642fb 100755 (executable)
--- a/imagecap
+++ b/imagecap
@@ -1,36 +1,50 @@
 #! /bin/bash
 
-#=========================================================
-# Wrapper script for feh image viewer with comment support
-#=========================================================
+# Copyright (c) 2017 Agnibho Mondal
+# All rights reserved
+#
+# This file is part of ImageCap.
+#
+# ImageCap is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# ImageCap is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# ImageCap.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Agnibho Mondal
+# contact@agnibho.com
+# www.agnibho.com
 
 SELF="$(realpath "$0")";
-EDIT="gvim -f";
 ARG="$(echo $1 | sed "s/^file:\/\///g")";
 DIR="$(dirname "$ARG")";
 if [ -n "$ARG" ];then
-       #IMG="$(feh -U "$DIR"|grep "$ARG$")";
        IMG="$DIR/$(basename "$ARG")";
 fi
 
 function update(){
-       TEMP=$(mktemp);
-       exiftool -S -s -b -comment "$1">$TEMP;
-       ls -l $TEMP;
-       $EDIT $TEMP;
-       exiftool -overwrite_original_in_place "-comment<=$TEMP" "$1";
-       rm $TEMP;
+       DATA=$(exiftool -S -s -b -comment "$1");
+       DATA=$(echo -n "$DATA"|zenity --text-info --editable --title="Edit Caption" --ok-label="Update");
+       if [ "$?" = "0" ];then
+               exiftool -overwrite_original_in_place -comment="$DATA" "$1";
+       fi
 }
 
 function view(){
        if [ -n "$IMG" ];then
-               feh -q --action1 ";$SELF e '%f'" --info "exiftool -S -s -b -comment '%f'" --scale-down --draw-tinted --start-at "$IMG" "$DIR";
+               feh -q --action1 ";$SELF -e '%f'" --info "exiftool -S -s -b -comment '%f'" --scale-down --draw-tinted --start-at "$IMG" "$DIR";
        else
-               feh -q --action1 ";$SELF e '%f'" --info "exiftool -S -s -b -comment '%f'" --scale-down --draw-tinted "$DIR";
+               feh -q --action1 ";$SELF -e '%f'" --info "exiftool -S -s -b -comment '%f'" --scale-down --draw-tinted "$DIR";
        fi
 }
 
-if [ "$1" == "e" ];then
+if [ "$1" == "-e" ];then
        update "$2";
 else
        view "$1";