Subject: FVWM: pager manipulation

From: Victor Eijkhout <[email-masked]>
Date: Wed, 20 Mar 2002 15:49:43 -0500

I'm trying to add/delete desktops dynamically.

This is a form for adding a desktop:
DestroyModuleConfig AddDesk: *
*AddDesk: WarpPointer
*AddDesk: Line left
*AddDesk: Text "Add new desktop:"
*AddDesk: Line expand
*AddDesk: Input deskname 20 ""
*AddDesk: Button quit "OK" ^M
*AddDesk: Command Exec cd $HOME/.fvwm ; \
     echo *FvwmPager: Label $d \"$(deskname)\" >> page_labels ; \
     sort_labels ; count_desks
*AddDesk: Command restart_pager
*AddDesk: Button quit "Cancel"

It calls two shell scripts to keep the labels sorted, and to update 
the number of desks in the Module FvwmPager command, which is also in 
a separate file.

Restarting the pager goes like this:

DestroyFunc restart_pager
AddToFunc restart_pager
+ "I" KillModule FvwmPager
+ "I" DestroyModuleConfig FvwmPager
+ "I" Read $[HOME]/.fvwm/pager_start
+ "I" Read $[HOME]/.fvwm/pager_style
+ "I" Read $[HOME]/.fvwm/page_labels

The problem is that the pager gets killed and restarted, but it 
doesn't have its proper size. It shows up without the extra desk, 
even though the configuration files that are supposed to get read do 
show the right number.

The weird thing is that if I again issue the restart_pager command

DestroyMenu desktops
AddToMenu desktops "Desktop" Title
+ "Add new desk" AddNewDesk
+ "Name this desk" NameThisDesk
+ "Remove this desk" RemoveThisDesk
+ "Restart pager" restart_pager

the new size does become effective. I've tried all sorts of things 
and I don't understand what's happening here.

-- 
Victor Eijkhout <[email-masked]>
tel: 865 974 9308 (W), 865 673 6998 (H), 865 974 8296 (F)
http://www.cs.utk.edu/~eijkhout/
--
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: Mikhael Goikhman <[email-masked]>
Date: Wed, 20 Mar 2002 21:19:03 +0000

> and I don't understand what's happening here.

You did not provide your pager_start and pager_style files plus
sort_labels and count_desks scripts, so I may only guess what they do.

Try a more correct Read order (yes, path to files is not needed here):

  DestroyFunc restart_pager
  AddToFunc   restart_pager
  + I KillModule FvwmPager
  + I DestroyModuleConfig FvwmPager
  + I Read pager_style
  + I Read page_labels
  + I Read pager_start

Regards,
Mikhael.

---

From: Victor Eijkhout <[email-masked]>
Date: Wed, 20 Mar 2002 22:13:49 -0500

>>  Restarting the pager goes like this:

Changed to

where

% cat pager_style
# options for the pager window
Style "FvwmPager" Sticky,StaysOnTop,NoTitle
# : yellow frame
Style "FvwmPager" Color white/yellow
*FvwmPager: Geometry -0+35
# options for the contents of the pager
*FvmwPagerWindowColors yellow gray blue black
# desktop organisation
DeskTopSize 2x1

% cat page_labels
*FvwmPager: Label 0 "stuff"
*FvwmPager: Label 1 "docs"
*FvwmPager: Label 2 "a"
*FvwmPager: Label 3 "NSDL"
*FvwmPager: Label 4 "Atlas"

% cat pager_start
Module FvwmPager 0 4
*FvwmPager: Rows 5
*FvwmPager: Columns 1

So
-- the current desk was #1 "docs", out of "stuff, docs, NSDL, Atlas"
-- I added desk "a"
-- kill the pager and its config
-- read the style, labels, and start files

and what is displayed is a pager with 4 desks: "stuff, a, NSDL, 
Atlas", which does not correspond to the input files.

>You did not provide your pager_start and pager_style files plus

Above.

>sort_labels and count_desks scripts, so I may only guess what they do.

Those are shell scripts that keep the labels sorted and keep the 
numbers on the "Module FvwmPager" line in sync with the number of 
labels:

e% cat sort_labels
#!/bin/sh
mv page_labels page_labels.tmp
sort -k 3,3 -s page_labels.tmp \
   | awk 'BEGIN {v=-1} $3==v {v=v+1; $3=v; print} $3>v {print ; v=$3}' \
   > page_labels

% cat count_desks
#!/bin/sh
mv pager_start pager_start.tmp
cat pager_start.tmp \
  | awk -v n=`wc -l page_labels | awk '{print $1}'` \
    '/Module/ {$4=n-1} /Rows/ {$3=n} {print}' \
  > pager_start

>   + I DestroyModuleConfig FvwmPager

Did that and it makes no difference.