I had been using:
Code: Select all
#!/bin/sh
#$1
NOTE=""
filename=$(basename "$@")
RESULTS=`Xdialog --fixed-font --wrap --left --stdout --title "$filename" --editbox "$@" 600x600`
EXIT_CODE=$?
EXISTS="FALSE"
ID=""
case $EXIT_CODE in
0) # All OK. The $RESULTS variable holds everything entered/choosed by the user.
NOTE="$RESULTS"
RESULTS2=`Xdialog --stdout --fselect "$@" 480x520`
EXIT_CODE2=$?
case $EXIT_CODE2 in
0)
echo "$NOTE" > "$RESULTS2"
esac
esac
exit 0
So I decided today to upgrade to GTKDialog and made the following.
Be forewarned it is still in the experimental stages, and I think higher minds such as many in this community could clean it up very quickly to prevent overwriting files and accidentily failing to save.
Code: Select all
#!/bin/sh
export currentfile="$@"
FILE1=$(cat "$@")
NOTE=""
filename=$(basename "$@")
FIL1=$(echo $FILE1)
confirm_function(){
Xdialog --title "Are you sure you want to save?" --backtitle "Yes or No?" --yesno "Yes to continue and No to cancel" 0 0
value=$?
echo "the result is: $value"
if [ "$value" = 0 ];
then
if [ "$INPUTFILE" = "" ];
then
echo "$EDITOR1" > "$currentfile"
else
echo "$EDITOR1" > "$INPUTFILE"
fi
else
echo "Save cancelled"
fi
}
export -f confirm_function
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window>
<vbox>
<hbox>
<edit wrap-mode="3" use-markup="true" accepts-tab="true">
<label>LEFT</label>
<variable>EDITOR1</variable>
<height>600</height>
<width>600</width>
<input file>'"$currentfile"'</input>
</edit>
</hbox>
<vbox>
<button use-stock="true" label="gtk-close"></button>
<button use-stock="true" label="gtk-save">
<action>confirm_function</action>
</button>
<hbox width-request="350">
<entry accept="file">
<variable>INPUTFILE</variable>
</entry>
<button tooltip-text="Select a file for saving">
<input file stock="gtk-open"></input>
<action type="fileselect">INPUTFILE</action>
<action>confirm_function</action>
</button>
</hbox>
</vbox>
</vbox>
</window>
'
export MAIN_DIALOG
$GTKDIALOG --program=MAIN_DIALOG
Hope it helps someone.
The first incarnation has done wonders for me when I just needed to have a running clipboard, thrash off some ideas, and even more frequently work on shell scripts.
And I am hoping this second will do so, too.
Ciao all! Thanks for being such a great community.
Also, to create new notes (from a second script), in the same fashion (/usr/local/bin)
you change the first
Code: Select all
export currentfile="$@"
Code: Select all
seed=$(date +%Y%m%d%H%M%S)
touch /tmp/"newnoteeditorGTK""$seed"
export currentfile=/tmp/"newnoteeditorGTK""$seed"