Subject: FVWM: Determine window's Icon

From: Tavis Ormandy <[email-masked]>
Date: Mon, 24 Nov 2003 12:35:28 +0000

Can anyone think of a way to restore a window's Icon after changing it,
or is there a way of getting that information from within an function?

I'm writing a simple Eye-Candy function, like this:

ExecUseShell /bin/ksh

DestroyFunc IconifyWithScreenshot
AddToFunc IconifyWithScreenshot
+ I Raise
+ I PipeRead "import -window $[w.id] -frame -silent -quality 0 $[HOME]/.fvwm/tmp.$[w.id].png \
	&& convert -resize 64 -frame 1x1 -bordercolor white -quality 0 \
		png:$[HOME]/.fvwm/tmp.$[w.id].png png:$[HOME]/.fvwm/icon.tmp.$[w.id].png \
	&& echo WindowStyle IconOverride, Icon $[HOME]/.fvwm/icon.tmp.$[w.id].png \
	|| echo Nop"
+ I Iconify
+ I Schedule 1000 Exec rm $[HOME]/.fvwm/?(icon|tmp)*.png

example:

before: 
http://dev.gentoo.org/~taviso/step1.png

after: 
http://dev.gentoo.org/~taviso/step2.png

After removing the icons, I'd like to restore it to it's original Icon,
so that if I Iconify the window without using this function, it doesnt
just dissapear. Maybe theres a better way?

-- 
-------------------------------------
[email-masked] | finger me for my gpg key.
-------------------------------------------------------
--
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: Mon, 24 Nov 2003 13:36:52 +0000

> just dissapear. Maybe theres a better way?

You can't push/pop Icon files for a window, only one icon is stored.
Hovewer you may do DestroyWindowStyle on deiconify if this helps.

You may also listen to destroy_window packet and then remove the icons,
not immediately after one second.

I would use "import -geometry 64 -resize 64 -silent" without additional
convert and use *IconTitle* and *IconBackground* style options instead.
Should be faster.

Regards,
Mikhael.

---

From: Tavis Ormandy <[email-masked]>
Date: Mon, 24 Nov 2003 14:10:45 +0000

> Hovewer you may do DestroyWindowStyle on deiconify if this helps.

Ahh! I should have tried that, thanks.

> not immediately after one second.

Yep, I was planning on doing that, just wanted to get it working nicely
first :)

> convert and use *IconTitle* and *IconBackground* style options instead.

Cool, I didnt realise you could do that...this looks much nicer now :)

DestroyFunc IconifyWithScreenshot
AddToFunc IconifyWithScreenshot
+ I Raise
+ I PipeRead "import -geometry 64 -resize 64 -silent -window $[w.id] $[HOME]/.fvwm/icon.tmp.$[w.id].png \
	&& echo WindowStyle IconOverride, Icon $[HOME]/.fvwm/icon.tmp.$[w.id].png \
	|| echo Nop"
+ I Iconify

DestroyFunc DeIconifyWithScreenshot
AddToFunc DeIconifyWithScreenshot
+ I WindowID $0 DestroyWindowStyle
+ I Exec rm -f $HOME/.fvwm/icon.tmp.$0.png

DestroyModuleConfig FvwmEvent-IconWatch: *
*FvwmEvent-IconWatch: Cmd
*FvwmEvent-IconWatch: PassID
*FvwmEvent-IconWatch: deiconify DeIconifyWithScreenshot

---

From: Mikhael Goikhman <[email-masked]>
Date: Mon, 24 Nov 2003 16:19:25 +0000

> Ahh! I should have tried that, thanks.

It would be really nice if we had an additional parameter to DestroyStyle
and DestroyWindowStyle to destroy only one specific style option, not all
style entry options. This would allow a lot of new dynamical functionality.
In your case you destroy all window-specific changes, not just Icon.

> *FvwmEvent-IconWatch: deiconify DeIconifyWithScreenshot

Please do not do it like this. The last 9 lines should be:

  DestroyFunc DeIconifyWithScreenshot
  AddToFunc DeIconifyWithScreenshot
  + I DestroyWindowStyle
  + I Exec rm -f $HOME/.fvwm/icon.tmp.$[w.id].png

Or to eliminate Exec call, even use: Test (f file) Exec exec rm file.

On another topic, reading the Gentoo forum, it seems that Gentoo package
of fvwm-themes is both old (0.6.2) and does not work with fvwm 2.5.x (how
is this possible?). This should be fixed by Gentoo people, I guess.

Regards,
Mikhael.

---

From: Tavis Ormandy <[email-masked]>
Date: Mon, 24 Nov 2003 16:30:35 +0000

> In your case you destroy all window-specific changes, not just Icon.

That would be very cool, as WindowStyle is a brand new feature I havnt
had a chance to do much else with it, so its working for me right now :)

> Or to eliminate Exec call, even use: Test (f file) Exec exec rm file.

Ahh, I've seen you mention this before to someone else, Thanks :)

> is this possible?). This should be fixed by Gentoo people, I guess.

Thanks for reminding me, I'll get that updated.

---

From: Andy Arbon <[email-masked]>
Date: Mon, 24 Nov 2003 18:48:33 +0000

Hello,

Excuse me for butting in, but I thought I'd give this idea a go. When I 
try and use the function I get the following output on the console:

import: Unable to read X window image (0x60000e).
import: Missing an image filename.

(With a different window number for different windows, obviously)

Insertion of an extra echo shows that the line that is failing is:
  PipeRead "import -geometry 64 -frame -resize 64 -silent -window 
0x60000e /home/ara/.fvwm/icon.tmp.0x60000e.png + I echo WindowStyle 
IconOverride, Icon /home/ara/.fvwm/icon.tmp.0x60000e.png || echo Nop"

Any ideas? This is with 2.5.8.

Also, I had to comment out the bottom + I Iconify, otherwise I get a 
kind of 'bouncing' effect, where the window iconises and then 
immediately deiconises. This could be because the former command is 
failing though AFAIK.
Cheers,

Andy

---

From: KXCG Maas <[email-masked]>
Date: Tue, 25 Nov 2003 00:33:10 +0100

Hi everybody, I was wondering if fvwm is customizable enough to create
some sort of thing described below, or maybe some sort of thing already
exists. I am looking to create some sort of console/terminal that
automaticly pops up over any existing windows when some important
messages popup. And dissapears automaticly after X seconds.

I would like to redirect multiple logfiles to that console and specify
when the console should popup, maybe by flagging a logfile or/and specify
patterns to recognize in the actual log when it should popup..

Any help would be appreciated ..

Thx 
-Boy

---

From: Mikhael Goikhman <[email-masked]>
Date: Tue, 25 Nov 2003 00:08:13 +0000

> 0x60000e /home/ara/.fvwm/icon.tmp.0x60000e.png + I echo WindowStyle 
                                                 ^^^
> Any ideas? This is with 2.5.8.

You probably didn't copy it correctly. The "+ I" should be "&&".

> immediately deiconises. This could be because the former command is 

It should not bounce, even if PipeRead failed.

Post the whole related config you use, i.e. FvwmEvent lines, the
mentioned function lines and so on.

Regards,
Mikhael.

---

From: Mikhael Goikhman <[email-masked]>
Date: Tue, 25 Nov 2003 00:18:36 +0000

> patterns to recognize in the actual log when it should popup..

I see several solutions. Passive periodical checking (may be done using
Schedule, it is even good that Schedule does not work when you are away
from your X in this case). Or active checking, you run FvwmCommandS
module from StartFunction. And run a filter program that executes
shell command "FvwmCommand 'ActivateLogWindow'" when needed. This
ActivateLogWindow function may execute "Schedule X000 DeactivateLogWindow".

Chack out FAQ (the search keyword "Toggle") and the man pages with all
mentioned keywords.

Regards,
Mikhael.

---

From: KXCG Maas <[email-masked]>
Date: Tue, 25 Nov 2003 11:56:07 +0100

Thx for the suggestions, so there are no existing implementations of
this functionality. I think I will go for the active solution.

Thx for the help ...

-Boy

---

From: Andy Arbon <[email-masked]>
Date: Thu, 27 Nov 2003 23:11:39 +0000

> It should not bounce, even if PipeRead failed.

Hello, and as usual thanks for replying Mikhael ;)

Apologies about the incorrect line. It was correct to start with, but
probably got mucked up at some point when I was trying to work out the
problem. I have corrected it, but still get the original problem,
complete with the above error message and 'bouncing'.

Is it possible that I have an incorrect version of import? I have:
ara@zoidberg ara $ import -version
Version: ImageMagick 5.5.6 04/01/03 Q16 http://www.imagemagick.org

Here are the relevant config lines: (winname_event included just so you
can see how it fits in in the FvwmEvent config)
(.fvwm/Functions)

#ExecUseShell /bin/ksh
DestroyFunc IconifyWithScreenshot
AddToFunc IconifyWithScreenshot
+ I echo "Iconnify running"
+ I Raise
+ I PipeRead "import -geometry 64 -frame -resize 64 -silent -window
$[w.id] $[HOME]/.fvwm/icon.tmp.$[w.id].png \
&& echo WindowStyle IconOverride, Icon $[HOME]/.fvwm/icon.tmp.$[w.id].png \
|| echo Nop"
+ I Iconify

DestroyFunc DeIconifyWithScreenshot
AddToFunc DeIconifyWithScreenshot
+ I echo "deIconnify running"
+ I DestroyWindowStyle
#+ I Test (f file) Exec exec rm -f $HOME/.fvwm/icon.tmp.$[w.id].png

DestroyFunc winame_event
AddToFunc winame_event
   + I ThisWindow ("*ara*") Style "*ara*" Colorset 1
   + I ThisWindow ("*root*") Style "*root*" Colorset 2

(.fvwm/Modules)

*FvwmEvent: StartDelay 3
#*FvwmEvent: Delay 1
#*FvwmEvent: startup          "/usr/local/share/sounds/fvwm/gong.au"
*FvwmEvent: window_name winame_event
*FvwmEvent: deiconify DeIconifyWithScreenshot
*FvwmEvent: iconify IconifyWithScreenshot
Module FvwmEvent

I get the "(de)iconify running" messages at the console, so the event
part of the config is working. I did wonder if the inability to read the
Xwindow image might be a permissions problem, in the same way that some
of the nodes in /dev can cause problems with OpenGL, but running:

# import -geometry 64 -frame -resize 64 -silent -window 0x2400019
~~/test.png && echo WindowStyle IconOverride, Icon ~/test.png

At the console as both root and my normal user works fine.

Thanks,

Andy