File filter - include Clear icon
[geeqie.git] / scripts / template-desktop.sh
index c42a279..273cef8 100755 (executable)
@@ -1,14 +1,18 @@
-#! /bin/bash
+#!/bin/sh
 
-# Insert updated menu "Valid sections" list into the desktop template file.
-# This needs to be run only when the menus have changed.
 
-tmp_file=$(mktemp)
-path=$(dirname $(realpath $0))
-srcpath=$(dirname $path)"/src/layout_util.c"
-templatepath=$(dirname $path)"/plugins/template.desktop.in"
+## @file
+## @brief Insert updated menu "Valid sections" list into the desktop template file.
+##
+## This needs to be run only when the menus have changed.
+##
 
-awk -v src_path=$srcpath 'BEGIN {
+tmp_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
+path=$(dirname "$(realpath "$0")")
+srcpath=$(dirname "$path")/src/layout_util.c
+templatepath=$(dirname "$path")/plugins/template.desktop.in
+
+awk -v src_path="$srcpath" 'BEGIN {
 menu_flag = 0
 template_flag = 0
 i = 0
@@ -72,12 +76,14 @@ function get_menus()
 /Valid sections/ {template_flag = 1; print; get_menus()}
 /This is a filter/ {template_flag = 0; print ""}
 (template_flag == 0) {print}
-'  $templatepath > $tmp_file
+'  "$templatepath" > "$tmp_file"
+
+cat "$tmp_file"
+printf '%s\n' "$PWD"
 
-zenity --text-info < $tmp_file
-if [ $? == 0 ]
+if diff --unified=0 "./plugins/template.desktop.in" "$tmp_file" | zenity --title="Plugin template update" --text-info --width=700 --height=400
 then
-       mv $tmp_file  $templatepath
+       mv "$tmp_file" "$templatepath"
 else
-       rm $tmp_file
+       rm "$tmp_file"
 fi