Subject: FVWM: setting up special windows on startup automatically

From: Cyprian Laskowski <[email-masked]>
Date: Thu, 09 Aug 2001 12:22:27 -0700

Hi,

Yesterday, it occurred to me: wait a minute: why have I not upgraded
my fvwm (my system came with 2.2.4)?  I was astounded, as I could not
come up with a reasonable answer.  Needless to say, I immediately
upgraded to 2.4.0 and am very pleased with the changes.  Thanks a lot!
You guys rule!

Playing around with it also brought up an old issue, which I still
don't know how to solve:

On startup (in InitFunction), I like to start up one xterm and one
emacs, and have them treated specially for the duration of the
session: I want the xterm to be sticky, and I want special keybindings
that will immediately take me to both of these windows.  But the
following doesn't work, and my other similar variants don't either.

AddToFunc InitFunction 
+	'I'	Exec exec xmodmap $HOME/.xmodmaprc
+       'I'     Exec exec xbiff -geometry 50x50+1080+5
+	'I'	Exec exec xterm -font 7x13 -geometry 55x8+765+5 -T BANG
+       'I'     Wait xterm
+       'I'     Next FlipFocus
+       'I'     Stick
+       'I'     Key Return A 3 WindowId $w FlipFocus
+	'I'	Exec exec emacs -f eshell
+       'I'     Wait emacs
+       'I'     Next (emacs) FlipFocus
+       'I'     Key Return A 3C WindowId $w FlipFocus

The problem begins with Stick, but I suspect that my Key commands
aren't set up right either (although I know that Mod3 is set up right,
as it works in other, more standard situations).  Could you show me
how to make this work?

BTW, the problem with Stick is also a problem I sometimes have with
FvwmCommand.  Say I try (I know this is a silly example):

% FvwmCommand 'Stick'

Fvwm seems to wait for me to select a window, but I want it to just
use the current one.  There are other commands with which I have the
same problem.  But I'm probably just using the wrong approach, right?

Thanks in advance for any help,

cyp
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 10 Aug 2001 07:30:39 +0200

> as it works in other, more standard situations).  Could you show me

When you run a command that needs a window to work on, the window
is usually chosen from the context the function was invoked from.
Usually, the context window is simply the window you clicked on,
but it can be something else or even unset under some
circumstances.  This is why you need "Next FlipFocus" to focus the
window, not just "FlipFocus".  It is important to know that the
context window does not change during function execution.  Thus,
the "Stick" line refers to the original context window again, not
to the one just focused.  "Next Stick" should work.  The "Key"
lines do not work for the same reason.  In addition, the "$w" is
replaced by a more or less random window, even if you use
"Next Key ..." since it is replaced at the time the "Next Key ..."
line is executed - and at that time the window was not yet
selected by the "Next".

I recommend doing this stuff in a separate function:

  Style BANG Sticky

  AddToFunc WaitAndFocusAndKeybind
  + I Wait $0
  + I Next ($0) FlipFocus
  + I Key $1 $2 $3 WindowId $w FlipFocus

  AddToFunc InitFunction
  + I Exec exec xmodmap $HOME/.xmodmaprc
  + I Exec exec xbiff -geometry 50x50+1080+5
  + I Exec exec xterm -font 7x13 -geometry 55x8+765+5 -T BANG
  + I WaitAndFocusAndKeybind BANG Return A 3
  + I Exec exec emacs -f eshell
  + I WaitAndFocusAndKeybind emacs Return A 3

(untested)

You get the idea.

> same problem.  But I'm probably just using the wrong approach, right?

Try 

  % FvwmCommand "Next Stick"

or

  % FvwmCommand "Current Stick"

instead.  When commands are executed from a module, there may not
be a context window to operate on, so fvwm asks for user
interaction.  To select a window automatically you have to use one
of the conditional commands.  If you would like a module command
to fail quietly if there is no window to operate on you can use
the "Silent" command prefix:

  % FvwmCommand "Silent Current (xterm) kill"

This would kill the current window if it is an xterm and do
nothing otherwise.

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Cyprian Laskowski <[email-masked]>
Date: Fri, 10 Aug 2001 05:36:47 -0700

Dominik Vogt <[email-masked]> writes:
> window, not just "FlipFocus".

Ah, yes!  I knew it was something fundamental that I did not
understand.  Thank you for the thorough explanation.

>   + I WaitAndFocusAndKeybind emacs Return A 3
Nice.  I will try that when I get home.

Thanks very much,

cyp

---

From: Cyprian Laskowski <[email-masked]>
Date: Sat, 11 Aug 2001 16:59:23 -0700

>> that will immediately take me to both of these windows.

>   + I WaitAndFocusAndKeybind emacs Return A 3
Ok, the sticky business worked fine.  But the Key commands did not
work as expected.  They seemed to do nothing (although they are bound,
since the application doesn't see these keys).  I tried replacing the
FlipFocus above with Beep to see if it did anything, and it did in
fact beep.  So it appears that the FlipFocus isn't working as I
expect.  Now I'm thinking that the problem is that $w is being
replaced when the command is executed and not when the command is run
(which corresponds to what you're saying above in the "Next Key"
discussion, right?).  Which makes sense to me, but I did not consider
it before.  In that case, the FlipFocus would always just give focus
to the window that already has the focus, which has no visible effect.
Is this what happens?  If so, is there any way for me to make this
work still the way I want?
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 13 Aug 2001 11:11:01 +0200

On Sat, Aug 11, 2001 at 04:59:23PM -0700, Cyprian Laskowski wrote:
> discussion, right?).

Exactly.

> Which makes sense to me, but I did not consider
> Is this what happens?

I honestly do not know :)

> If so, is there any way for me to make this work still the way I want?  

You have to quote the '$' to protect it from being evaluated too
early.  There is a logic behind it, but even I can exactly tell
how many '$'s are necessary except by trying.  One of these lines
should work:

  + I Key $1 $2 $3 WindowId $$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$$$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$$$$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$$$$$w FlipFocus
  + I Key $1 $2 $3 WindowId $$$$$$$$w FlipFocus

;-)

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: [email-masked]
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].