Re: FVWM: conditional functios

From: <ybamnolk_at_cisco.com>
Date: Sun, 17 Aug 1997 09:47:58 -0700

Paolo,

> Date: Sun, 17 Aug 1997 11:18:05 +0200
> From: Linux-Debian Team <cube_at_wigner.cstc.org>
> To: fvwm_at_hpc.uh.edu
> Subject: FVWM: conditional functios
> Reply-To: pumilia_at_mbox.est.it
>
> I am used to open a note pad from time to time, anywhere in my
> workplace. My note pad is a plain text file edited through vi in
> xterm and i can pop it up either by key composition or selecting
> a menu item in fvwm2 root context.
> Often it happens i try to open my notes file twice simultaneously,
> having forgotten a vi session is already active on another desktop
> of my workplace.
> Here my question follows: is there a viable solution in order to
> avoid opening twice the sape file?
>
> A further question comes to my mind:
> May it be possible to apply a condition to the execution of a command
> in fvwm2 ? In affirmative case, the window manager could be asked
> to execute a script file; then, depending on the result, to start
> one function or another. In the present case, the script would
> check whether the requested (my notes) file is already open.
>

The fast and simple way I can think about is to write a script that will
maintain the lock and start the script from the menu instead of starting vi
with your input file directly.

I'm including (an untested) csh script that should do the job.

(To get the script error messages you should start this script inside
 a diffrent xterm)
 
 
---- cut here, save as file notepad.csh and chmod u+x notepad.csh
#! /bin/csh -f

set LOCK = /tmp/note-pad-$USER.lock
set NOTE_FILE = a/path/to/the/note/pad/file.txt

if ( -f $LOCK) then
    echo "Note pad is open. Close it first."
    exit -1
endif

# now put the lock.
touch $LOCK

# Edit the file.
xterm -e vi $NOTE_FILE

# Reset the lock.

/bin/rm -f $LOCK

exit 0
--- cut here ---

Good luck,
Yehuda.






> thank you
>
> Paolo Pumilia
>
>
> --
> 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.
>
--
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 Sun Aug 17 1997 - 11:50:27 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:38:00 BST