Re: FVWM: Saving window-states (was: Module development in c++ ?)

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Sun, 12 Oct 2003 17:57:50 +0300

On 12 Oct 2003 16:23:53 +0200, Tomas wrote:
>
> On Sun, 12 Oct 2003, Mikhael Goikhman wrote:
> > On 12 Oct 2003 14:17:30 +0200, Tomas wrote:
> > >
> > > Hello. I was missing some functionality (specifically saving the position
> > > and size of windows) so I started to develop a module.
> > [..]
> >
> > If you describe exactly what do you need to do in your module, it is
> > possible there is a solution without additional modules.
>
> The thing is that I would like to select windows and choosing "Save
> position/size" or something from a menu (or whatever), to save theyre
> state in some kind of file. Next time the window opens, the window is
> resized/moved to the saved state. I use FvwmEvent for this right now (with
> inspiration from the FAQ), but I have to put all the window-names in the
> fvwm config-file, I would like to simplify this a bit.

It is not much longer to write a Perl module, but let's do it without it.

  DestroyFunc RestoreWindowGeometry
  AddToFunc RestoreWindowGeometry
  Read saved-window-geometries Quiet

  DestroyModuleConfig FvwmEvent-NewWindow: *
  *FvwmEvent-NewWindow: add_window RestoreWindowGeometry

  AddToFunc StartFunction
  + I Module FvwmEvent FvwmEvent-NewWindow

  DestroyFunc SaveWindowGeometry
  AddToFunc SaveWindowGeometry
  + I AddToFunc RestoreWindowGeometry
  + I + I ThisWindow ('$0') ResizeMove $1 $2 $3 $4
  + I Exec echo "+ I ThisWindow ('$0') ResizeMove $1 $2 $3 $4" >>$[FVWM_USERDIR]/saved-window-geometries

  Key F4 A CS Pick SaveWindowGeometry $[w.name] $[w.x] $[w.y] $[w.width] $[w.height]

Not tested, but it should work, I think. Press Ctrl-Shift-F4 to save the
current window geometry, it is restored automatically on the next launch.

To remove the old windows with the same name you may do something like:
Exec grep -v "ThisWindow ('$0')" file >file.new && mv file.new file; echo ..

This supposes window names do not include double quotes. To make it more
robust, write a module in Perl rather than relying on Exec+shell quotes
to work. If you ask me nicely I may write a Perl module for you doing
the same. But I don't really want to spoil your fun. :)

Regards,
Mikhael.
--
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 majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Sun Oct 12 2003 - 10:00:28 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:55 BST