hi,
i want to ask what is the proper way to use Fvwm variables within
a shell script for FvwmCommand.
Especifically, what about $w ?
In the shell script i am attaching, in the second if clause,
i am attempting to use $w, to write a window id to a file.
I tested the 'Prev' command by itself in FvwmTalk, and it succeeds in writing
the window id to a file.
But it does not work from my shell script. File does not get written.
(i tried using '$$' and quoting... -- no luck)
BTW, the rest of the script works just fine. I can toggle back and
forth between 2 windows in different pages, from the xterms' command line.
[There must be simpler ways of doing window toggling,
but I just wanted to play...]
- thanks, josin
_________________________________________________________________________
In Heaven there will be no DOS, no Intel, and above all, no Bill.
#!/bin/bash
###############################################################################
# FvwmCommand to toggle between windows.
#
# 980901 j.alvistur
##############################################################################
# NO UNDEFINED VARS ALLOWED...
set -u
# FOR DEBUGGING
# set -x
. FvwmCommand.sh
PN=`basename $0`
USAGE="\a\
To: toggle between windows.
Usage: $PN -gG window_name
$PN -r
-r return to previous window.
-g go to 'window_name' Arg can be any string found in actual
window name. Beware of mismatches.
Sorry no regexps.
-G go to 'window_name' Same as '-g' above. But this is for when
it is invoked from FvwmTalk. "
#bash does not have built-in 'which'... so this should return the path echo...
eco=`which echo`
return_to=/tmp/window_return_to
went_to=/tmp/window_went_to
#=============================================================================
# unloading args...
#=============================================================================
RETURN="FALSE"
INVOKING_FROM="NOTHING"
window_name="NOTHING_AT_ALL"
# echo "\$#: $#"
while getopts rg:G: opt
do
case $opt in
r )
RETURN="TRUE"
;;
g )
INVOKING_FROM="SHELL"
window_name="$OPTARG"
;;
G )
INVOKING_FROM="FvwmTalk"
window_name="$OPTARG"
;;
\?)
echo "$PN: bad option passed"
$eco "$USAGE"
exit 2
;;
esac
done
shift `expr $OPTIND - 1`
test $# -ne 0 && {
echo "$PN: too many args";
$eco "$USAGE";
exit 1; }
#=============================================================================
# doing the work...
#=============================================================================
if [ "$INVOKING_FROM" = "SHELL" ] ; then
# win_name -first_match -id -m $WINNAME > $return_to || { exit 1; }
# OR
# Current [ * ] Exec echo $w > $return_to
# using environ variable here...
echo $WINDOWID > $return_to || {
echo "$PN: cannot write to file $return_to"
exit 1; }
win_name -first_match -id -m $window_name > $went_to || {
echo "$PN: cannot write to file $went_to"
exit 1; }
Next [ *${window_name}* ] FocusAndWarp
exit 0
elif [ "$INVOKING_FROM" = "FvwmTalk" ] ; then
# IF INVOKING FROM FVWMTALK....
echo "from fvwmtalks " >> /tmp/zlog
Prev [ * ] Exec echo $w > $return_to
Next [ *${window_name}* ] Exec echo $w > $went_to
Next [ *${window_name}* ] FocusAndWarp
exit 0
elif [ "$RETURN" = "TRUE" ] ; then
WID=`cat $return_to` || { exit 1; }
swap_files $return_to $went_to || { exit 1; }
WindowId $WID WarpToWindow 10 10
exit 0
else
echo "$PN: in default case. Fell thru."
$eco "$USAGE"
exit 1
fi
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Thu Sep 10 1998 - 13:17:17 BST