Subject: FVWM: Different backgrounds

From: Fabio Stumbo <[email-masked]>
Date: Wed, 21 May 2003 11:33:36 +0200 (CEST)

Hi all,

I use fvwm2 since 1994 but only now I feel the need to use more than one 
desktop... ;-))

My problem is the following: in my current configuration (1 desktop) I
want a background which should be picked up randomly in a directory with
pictures. Moreover, it should change every hour. The only way I have been
able to obtain this is as follows:

my StartFunction contains the line

+ I Exec exec crontab /usr/local/etc/fvwm/cron.dir/hour

the hour file contains

------
SHELL=/bin/bash
DISPLAY=:0.0
PATH=/usr/local/etc/fvwm/bin

0 * * * * cgbg
-------------

cgbg is a script which simply calls

#!/bin/sh
/usr/X11R6/bin/xv -rb black -maxpect -rmode 5  
	-random /usr/local/etc/fvwm/bgs/* -quit

(I put it in a separate script so that it can also be called directly, 
somewhere else)

I don't know if this is the best way to have the job done but, so far, it 
worked, so I didn't feel the need for another solution (but for being 
forced to install manually xv, which is no longer included in any 
distribution... :-(

Now I use 2 desktops. I realized that my scripts have the effect to put 
the same image in the two desktop. What I want now is: on the first 
desktop (=0), same behavior as before. On the second desktop (=1), I 
would like to have a solid color background, which shouldn't change. I 
made some tries with FvwmBacker, but without success, so I am out of 
ideas: can anybody help me?

Thank you in advance 

Fabio

--
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: Cameron Simpson <[email-masked]>
Date: Wed, 21 May 2003 20:01:06 +1000

On 11:33 21 May 2003, Fabio Stumbo <[email-masked]> wrote:
| My problem is the following: in my current configuration (1 desktop) I
| want a background which should be picked up randomly in a directory with
| pictures. Moreover, it should change every hour. The only way I have been
| able to obtain this is as follows:
[... cron job that changes the backdrop ...]
| #!/bin/sh
| /usr/X11R6/bin/xv -rb black -maxpect -rmode 5  
| 	-random /usr/local/etc/fvwm/bgs/* -quit
| 
| (I put it in a separate script so that it can also be called directly, 
| somewhere else)
| 
| I don't know if this is the best way to have the job done but, so far, it 
| worked, so I didn't feel the need for another solution (but for being 
| forced to install manually xv, which is no longer included in any 
| distribution... :-(

It's shareware. RH can't distribute it.
But it is also my preferred viewer.
I sent some $$s to the author.

| Now I use 2 desktops. I realized that my scripts have the effect to put 
| the same image in the two desktop. What I want now is: on the first 
| desktop (=0), same behavior as before. On the second desktop (=1), I 
| would like to have a solid color background, which shouldn't change. I 
| made some tries with FvwmBacker, but without success, so I am out of 
| ideas: can anybody help me?

Have the script simply choose a backdrop but not set it with xv.
Use FvwmEvent to set the backdrop on entry to each desktop appropriately,
using xv.

I have FvwmEvent run a script called enterdesk when I switch desks:

	http://www.cskk.ezoshosting.com/cs/scripts/enterdesk

Pickim and rootbg et al are ludicrously overengineered scripts to do
something like what you want, but the enterdesk stuff may well be readily
modified to suit you.

Cheers,
-- 
Cameron Simpson, DoD#743        [email-masked]    http://www.zip.com.au/~cs/

If it ain't life-affirming, it ain't shit.
        - Rejected corporate motto, Touchstone Pictures.
--
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, 21 May 2003 13:02:06 +0000

> + I Exec exec crontab /usr/local/etc/fvwm/cron.dir/hour

Try the following instead in 2.5.x:

  AddToFunc ChangeRootHourly
  + I Exec exec cgbg
  + I Schedule 3600000 ChangeRootHourly

  AddToFunction StartFunction
  + I ChangeRootHourly

> forced to install manually xv, which is no longer included in any 

You don't need to use xv, there is "display" from ImageMagick that
understand all image formats, there is fvwm-root from 2.5.x that
understands XPM and PNG and there are some other root setters.

> ideas: can anybody help me?

You may run FvwmBacker that uses 2 Pixmap colorsets, one per desk.
Then the setup for 2.5.x may look like this (untested):

  DestroyFunc ChangeRootHourly
  AddToFunc   ChangeRootHourly
  + I PipeRead `dump-2-config-lines-for-colorset-51-and-52`
  + I Schedule 3600000 ChangeRootHourly

  AddToFunction StartFunction
  + I ChangeRootHourly
  + I FvwmBacker

  *FvwmBacker: Command (Desk 0) Colorset 51
  *FvwmBacker: Command (Desk 1) Colorset 52

The script should dump 2 lines, something like:

  Colorset 51 Pixmap bg7.png
  Colorset 52 Pixmap bg4.png

Regards,
Mikhael.

---

From: Fabio Stumbo <[email-masked]>
Date: Wed, 21 May 2003 16:41:56 +0200 (CEST)

> something like what you want, but the enterdesk stuff may well be readily

If I am not wrong, what you suggest is something which changes the 
background every time I switch the desktop, isn't it?
If so, it is not exactly what I mean.

I also ad a look at your scripts: they are very well done, but somewhat 
too involved and with too many interdependencies to be easily modified.

What I was simply looking for, was a (simple, if possible) way to tell 
fvwm:

for desktop 0 use this (function to select a) background
for desktop 1 use this  background

The solution suggested by Mikhael seems much closer to what I wanted: I 
will try it.

Thank you anyway

Fabio

---

From: Fabio Stumbo <[email-masked]>
Date: Thu, 22 May 2003 08:44:47 +0200 (CEST)

>   Colorset 52 Pixmap bg4.png

I tried: your suggestion works fine. Only two point:

1) am I forced to use png? I have lots of jpgs, so I should convert them.
Ok, it is simple and quick, but it is somewhat a waste of space to have
two copies of hundreds of pictures... 

2) Your suggestion has the effect that the background gets changed every
hour _since_ I fire up fvwm: what if I want the effect only exactly at the
hour (3:00, 4:00, 5:00, and so on...)?

Thank you 

Fabio

---

From: Cameron Simpson <[email-masked]>
Date: Thu, 22 May 2003 19:29:30 +1000

On 16:41 21 May 2003, Fabio Stumbo <[email-masked]> wrote:
| > | Now I use 2 desktops. I realized that my scripts have the effect to put 
| > | the same image in the two desktop. What I want now is: on the first 
| > | desktop (=0), same behavior as before. On the second desktop (=1), I 
| > | would like to have a solid color background, which shouldn't change. I 
| > | made some tries with FvwmBacker, but without success, so I am out of 
| > | ideas: can anybody help me?
| > 
| > Have the script simply choose a backdrop but not set it with xv.
| > Use FvwmEvent to set the backdrop on entry to each desktop appropriately,
| > using xv.
| > 
| > I have FvwmEvent run a script called enterdesk when I switch desks:
| > 
| > 	http://www.cskk.ezoshosting.com/cs/scripts/enterdesk
| > 
| > Pickim and rootbg et al are ludicrously overengineered scripts to do
| > something like what you want, but the enterdesk stuff may well be readily
| > modified to suit you.
| 
| If I am not wrong, what you suggest is something which changes the 
| background every time I switch the desktop, isn't it?

Well, only if it's different to what's displayed already.

| If so, it is not exactly what I mean.
| 
| I also ad a look at your scripts: they are very well done, but somewhat 
| too involved and with too many interdependencies to be easily modified.

Indeed, but enterdesk itself isn't.

| What I was simply looking for, was a (simple, if possible) way to tell 
| fvwm:
| 
| for desktop 0 use this (function to select a) background
| for desktop 1 use this  background
| 
| The solution suggested by Mikhael seems much closer to what I wanted: I 
| will try it.

BTW, you timing problem with Mikhael's suggestion is easily addressed.
As before, use your cron job to pick a fresh backdrop on the hour.
And copy the selected image to a generic name like ~/.current-backdrop.jpg,
and always have fvwm load that name.

fvwm-root is quite quick. If you take the effort you can size the source
image to fit your screen and convert to PNG on the way, and store the
converted image as your generic name. The update is very quick after that.

Cheers,

Faith in a holy cause is to a considerable extent a substitute for the
lost faith in ourselves.        - Eric Hoffer
--
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: Thu, 22 May 2003 10:37:33 +0000

> two copies of hundreds of pictures... 

I would also like FVWM to support JPG together with PNG, XPM and XBM,
but I am afraid this is not going to happen until at least 2.7.x.

> hour (3:00, 4:00, 5:00, and so on...)?

Well, then you should do some time mathematics.
Replace the "Schedule 3600000 ChangeRootHourly" line above with:

  PipeRead `perl -MTime::Local -e '@t = localtime; $t[0] = $t[1] = 0; $t[2]++; printf "Schedule %s ChangeRootHourly\\n", ((timelocal @t) - time) * 1000'`

Regards,
Mikhael.

---

From: Fabio Stumbo <[email-masked]>
Date: Thu, 22 May 2003 19:04:14 +0200 (CEST)

> but I am afraid this is not going to happen until at least 2.7.x.

Ok, we shall wait...

>   PipeRead `perl -MTime::Local -e '@t = localtime; $t[0] = $t[1] = 0;
> $t[2]++; printf "Schedule %s ChangeRootHourly\\n", ((timelocal @t) -
> time) * 1000'`

Well, I would have never been able to produce such a thing! And, what is 
worse, it works!!!

Thank you a lot.

BTW: just for understanding it better: all suggestions, both yours and 
Cameron's, work changing the background every time the desktop is 
changed, even if the desktop itself didn't change. I tried, for example,

Colorset 1 Pixmap $[HOME]/a.png
Colorset 2 Pixmap $[HOME]/b.png
*FvwmBacker: Command (Desk 0) Colorset 1
*FvwmBacker: Command (Desk 1) Colorset 2

without any other "esotheric" function. It seems to me that it should be
the more simple and correct way to have two different (but fixed!)  
backgrounds on different desktops. Yet when I switch desk, the bg get
redrawn every time, and it takes a little time. Not a lot, just half a
second or so, but anyway longer than I expected. 
If it is so, it seems to me that there is somewhat a waste of resources.
Or is it not?

Regards

Fabio

---

From: Perry Hutchison <[email-masked]>
Date: Thu, 22 May 2003 10:16:43 -0700 (PDT)

> It seems to me that it should be

Not really.  Most X servers have only one physical display page,
so you have to redraw (at least the exposed parts of) that page
to change the background.
--
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: Olivier Chapuis <[email-masked]>
Date: Thu, 22 May 2003 20:48:38 +0200

> but I am afraid this is not going to happen until at least 2.7.x.

Yes JPG will be good, but surely after 2.6. Also, one thing about
images and fvwm I would like to implement after 2.6 is a good image
resizing algo.

Regards, Olivier

---

From: Dan Espen <[email-masked]>
Date: Thu, 22 May 2003 14:55:12 -0400

> images and fvwm I would like to implement after 2.6 is a good image

Based on my experience, the one in xli is the fastest.

Its still a serious amount of computation, every pixel has to
be compared to all the surrounding pixels.

-- 
Dan Espen                           E-mail: [email-masked]

---

From: Marcus Lundblad <[email-masked]>
Date: Thu, 22 May 2003 22:50:40 +0200 (CEST)

> images and fvwm I would like to implement after 2.6 is a good image

Perhaps SVG would be nice support also.
I guees this has been up to discussion.

//Marcus

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 22 May 2003 21:57:16 +0000

On 22 May 2003 19:04:14 +0200, Fabio Stumbo wrote:
> 
> > > 2) Your suggestion has the effect that the background gets changed
> > > every hour _since_ I fire up fvwm: what if I want the effect only
> > > exactly at the hour (3:00, 4:00, 5:00, and so on...)?
> > 

Actually when I posted I knew it has a small problem, once a day it stops
to work (printing: Hour '24' out of range 0..23). I only wanted to give
you an idea, here is a quick hack if you may tolerate one case:

  $t[2]++; $s = $t[2] == 24? 3600000: ((timelocal @t) - time) * 1000; \
  print "Schedule $s ChangeRootHourly\\n";`

> changed, even if the desktop itself didn't change.

Hmm, I see you use the "desktop" word for 2 different meanings. Which?
I suppose you simply mean it takes some time to see a new image.

Yes, it takes some time to copy a picture to the root window.
I don't think colorsets in FvwmBacker work much slower than xv.
Try also solid colors or simple tiles as your background to speed it.

> If it is so, it seems to me that there is somewhat a waste of resources.

It is. But I don't know whether there is a good solution in X for this.

Regards,
Mikhael.