Discussion:
FVWM: best way to update a button or menu item
Lucio Chiappetti
2015-01-21 11:27:49 UTC
Permalink
First of all my apologies if I'm asking in the wrong place, I was a
member of the mailing list <***@fvwm.org>, but some times after my last
posting (a few years ago) I received nothing. I assumed recently that the
list was replaced by the forum, but since registration to the forum is
barred by a totally ununderstandable question (!), I checked the archives
and I realized the list is still mildly active ... but has changed
address, so I re-subscribed.

I am in the process of revamping all my fvwm configuration, I re-read all
the man pages (incidentally the web based ones are excellent as ease of
access) and decided to try some of the modules I so far skipped (and
FvwmConsole is a great way to test things.

What I want to do so far is the following (for one I have a working
solution but there may be better ones, for the other I have just ideas)

1) I want to keep (e.g. in the lower left corner of my screen) a text
label with the desktop number or name

After some experiments, I think the best is to use FvwmButtons

I define a transparent color set
Colorset 10 Transparent,Fore White

then for each desktop I define a FvwmButtons like this (only I
call them 0,1,2 ...)

Style MyDesk0 StartsOnDesk 0, SkipMapping,NoTitle,WindowListSkip,
!Borders,!Handles,ParentalRelativity,StickyAcrossPages,
!StickyAcrossDesks,StaysOnBottom
DestroyModuleConfig MyDesk0*
*MyDesk0: (Title "desk 0", Action Nop)
*MyDesk0: Colorset 10

Module FvwmButtons -g -0-0 MyDesk0

Each one has hardcoded the desk number (or potentially name).
I hoped I could use $[desk.n] as a dynamic content. but I found with
some disappointment that it is the current desk at the moment the
button or menu or whatever is created.

Is there any smarter solution (with a single fvwmbutton or other
widget for all desks, which displays the current desk number as soon
as one moves to it ?)

2) I want to keep the current date on the screen (and time as well, but
time is no problem)

In my old configuration I do this already, I stick in a corner of the
screen, one above the other, two applications.

- one is a xdaliclock with the (hh:mm:ss) time (no title, etc.)
- the other one is a rclock with a geometry of 150x1-0+12, so the
display of the analog clock is suppressed, and the date is shown
in the window title bar

what I wanted to do now was to collect the two clocks, together with
other things like the FvwmPager and some other stuff, into a
FvwmButtons.

The xdaliclock is swallowed nicely (so time is no problem), but
rclock is not usable, because the window title does not exist for
swallowed windows.

So far I replaced the rclock button (in the FvwmButtons MyBox) with a
Piperead from a shell script which does a silly
echo *MyBox: \(1x1, Back rgb:99/00/00, Fore White,
Title \"`date "+%a %b %d"`\", Action Nop\)

This is very economic (no additional X applications) but of course
works but loads the date of the moment FvwmButtons is invoked
(currently from FvwmConsole and later at fvwm startup)

Since I usually leave the machine logged in for several days, of
course this date will no longer be valid on the next day

Is there a smart way to have a button periodically refresh its
content ?

I thought of some at command or better crontab, which could use
FvwmCommand to tell fvwm to KillModule FvwmButtons Mybox and
invoke it again (may be with a dedicated function) ...
... or I could just use the fvwm restart I already have

Any smarter solution ?
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Lucio Chiappetti
2015-01-21 13:23:21 UTC
Permalink
DestroyModuleConfig FE-UpdateDeskNum
*FE-UpdateDeskNum: new_desk NewFunc
AddToFunc StartFunction I Module FvwmEvent FE-UpdateDeskNum
DestroyFunc NewFunc
AddToFunc NewFunc
+ I SendToModule MyDesk0 ChangeButton desklabel Title $0
Thanks for the hints towards FvwmEvent (I thought something like that but
first of all did not know the names of the applicable event !)

anyhow, I did that (testing in FvwmConsole), I just replaced the last
statement with

+ I SendToModule MyDesk0 ChangeButton desklabel Title "desk $0"

If I call NewFunc "x" the button label is updated fine

However as soon as invoke Module FvwmEvent FE-UpdateDeskNum I get in the
error console twice this message

FE-UpdateDeskNum: incomplete event definition *FE-UpdateDeskNumnew_desk
FE-UpdateDeskNum: incomplete event definition *FE-UpdateDeskNumnew_desk

in fact I do not understand ho FvmwEvent passes argument $0 to the
function !!

(BTW I am using fvwm 2.5.26)

Thanks in advance for any further hint
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Lucio Chiappetti
2015-01-21 15:35:31 UTC
Permalink
DestroyModuleConfig FE-UpdateDeskNum
*FE-UpdateDeskNum: new_desk NewFunc
DestroyFunc NewFunc
AddToFunc NewFunc
+ I SendToModule MyDesk0 ChangeButton desklabel Title $0
in fact I do not understand ho FvmwEvent passes argument $0 to the function
!!
As for your other problem, see: $[desk.n] and: $[desk.name$[desk.n]]
You should really pass those to 'NewFunc'.
not really "pass", more "hardcode" so they are automatically expanded !

With the code above, doing "NewFunc anything" was correctly changing the
label to argument anything.

I tried "calling NewFunc from FvwmEvent with desktop as argument"
mod DestroyModuleConfig FE-UpdateDeskNum
mod *FE-UpdateDeskNum: new_desk NewFunc $[desk.n]
but that is WRONG
the correct way is instead
mod AddToFunc NewFunc
mod + I SendToModule MyDesk0 ChangeButton desklabel Title "desk
$[desk.n]"

I was aware of the $-variables, only I noted that inserting them in menus
or buttons, the value at the moment of the menu or button defintion was
used. Instead for the function, the value at the moment of function call
is used !

So it works, even with desktop names (the only provision is that the
button title shall be created at beginning with a string long enough to
cater for the longest value it would receive in the future)
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Lucio Chiappetti
2015-01-21 15:38:28 UTC
Permalink
Post by Lucio Chiappetti
2) I want to keep the current date on the screen (and time as well, but
time is no problem)
Is there a smart way to have a button periodically refresh its
content ?
thanks to the previous hint to SendToModule ... ChangeButton my solution
is to run via crontab at midnight the following two line shell script

set a = `date "+%a %b %d"`
/usr/bin/FvwmCommand "SendToModule MyBox ChangeButton myDate Title '$a[1]
$a[2] $a[3]'"
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Chris Siebenmann
2015-01-21 15:39:44 UTC
Permalink
Post by Lucio Chiappetti
2) I want to keep the current date on the screen (and time as well, but
time is no problem)
In my old configuration I do this already, I stick in a corner of the
screen, one above the other, two applications.
- one is a xdaliclock with the (hh:mm:ss) time (no title, etc.)
- the other one is a rclock with a geometry of 150x1-0+12, so the
display of the analog clock is suppressed, and the date is shown
in the window title bar
You want the old standby 'xclock', specifically 'xclock -digital'
(possibly with '-strftime' as well, which will let you specify the exact
format of the clock).

- cks
Lucio Chiappetti
2015-01-21 16:58:08 UTC
Permalink
Post by Chris Siebenmann
Post by Lucio Chiappetti
2) I want to keep the current date on the screen
You want the old standby 'xclock', specifically 'xclock -digital'
(possibly with '-strftime' as well
Don't know why I junked it with a "don't like" back in 2006. As a clock I
rather liked Jamie Zawinksi's xdaliclock (although at the time I did not
realize he was the author). For date I liked rclock (which is also an
appointment manager ... just use it to tell me when to take a pill and
when to go home, or occasional to the dentist :-))

Anyhow now I have a solution which works with a crontab, so it is a waste
to keep there a process for something which occurs once a day.
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Lucio Chiappetti
2015-01-21 15:54:31 UTC
Permalink
So far (in the last 10 years or so !!) I've been using the following
mental model when dealing with fvwm desktops and pages

A page is a screen where I keep the terminals, editors, analysis tools
I need for a particular sub-activity (say analysing the spectra of a
particular source, or writing a particular program, or writing documents
for a particular project

Desktops were a family grouping of pages

So, so far I had normally (on my physical desktop computer) 2 fvwm
desktops of 2x2 pages each.

One desktop was intended for "real work"
The other one for "connectivity" (and I had one page for e-mail, one page
for web, one page for VNC or Xnest or VirtualBox, and a spare)

(on the laptop I used - seldom - for presentations I kept 3-5 desktops of
1 page each ... that was mainly because of the reduced space on the
screen)

Now I decided to change the mental model.

I would like to have one desktop per project/activity (i.e. what I
previously called pages).

If I do each desktop of 1 page that's easy.

However since I discovered the wonderful command to do mouse scrolling

Mouse 1 A CM Scroll reverse

I would appreciate having each desktop "somehow bigger" than the physical
screen. Sometimes I need rather wide terminal screens. Probably 2x2 is too
big ...

I tried DeskTopSize 1.5x1.5 ...
... apparently it is accepted but does not work as expected

I assume I cannot have "fractional" increases.

Would it be possible to use the FvwmPager to show only the first page of
each 2x2 or 1x2 desktop (and consider the rest as hidden reserved space
which can be reached scrolling) ?

Otherwise what about having normally DeskTopSize 1x1 and at need
increasing it on the fly to 2x1 or 2x2 (I tested the increase works)

Opinions ?
--
------------------------------------------------------------------------
Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy)
For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
------------------------------------------------------------------------
Do not like Firefox >=29 ? Get Pale Moon ! http://www.palemoon.org
Loading...