Dynamic icon.

I have an FvwmButtons setup where one of the “entries” look like this:

*mpdStatus: (1x2, Frame 0, ActionOnPress, Swallow "CoverArt" `FvwmScript $[fvwm_home]/script/CoverArt`, Action(Mouse 1) `exec exec gmpc`, Action(Mouse 3) `exec exec aterm -e ncmpc`)

This works fine. The script it swallows is supposed to output an icon:

[code]WindowTitle {CoverArt}
WindowSize 64 64
WindowPosition 0 0
Colorset 10

Set $current_art = (GetOutput {Exec echo sh $[fvwm_home]/script/currentart.sh} 1 -1)
ChangeIcon 1 $current_art

If (RemainderOfDiv (GetTime) 20)==0 Then

Set $current_art = (GetOutput {Exec echo `sh /home/christian/.fvwm/script/currentart.sh`} 1 -1)
ChangeIcon 1 $current_art


Widget 1
Type ItemDraw
Size 64 64
Position 0 0
Flags NoFocus NoReliefString
I had some troubles having this run my shellscript, but now it does(I know for sure, it outputs to a file as well). It simply outputs “/path/to/icon.png”
My problem is… it never get to see any icon! :frowning:
Any obvious mistakes? I’m pretty new to FvwmScripts and dynamic icons, but I know it can be done, seeing as Pem does it :wink: I’ve looked quite a lot at his stuff while trying to achieve this, but I just can’t seem to get it working. Any help would be greatly appreciated! :slight_smile:

It should not. It seems quite good to me. Just one thing, the sh call before your script sould not be necessary if the appropriate measure are taken for your shell script to get executed: execution rights turn on, “#!/bin/bash” set at the beginning of your file.

To debug this script, could you please post the currentart.sh? (some kind of icon showing the current album being played as I see)

Two things for debugging script. Check your shell script on the command line and check your FvwmScript with the FvwmConsole. It helps a lot. :wink:

I know #!/bin/bash should be enough, but I had some problems getting the FvwmScript to actually run my script. A dirty workaround, I just fiddled around until it worked(I’ll clean things up later). This should however be irrelevant, seeing as the script gets run. I’ll post more when I get home, but FvwmScript executes it fine, and creates a proper widget, just without the icon. The script gets run. The script works fine from the commandline, and outputs “/path/to/icon.png”. OKOK, gottarun, I’ll post more when I get home.


mpc --format %artist%-%album% | sed 1q | sed -e i"/home/christian/.fvwm/albumgfx/ -e a.png" | tr -d “\012” > /home/christian/.fvwm/currentart

mpc --format %artist%-%album% | sed 1q | sed -e i"/home/christian/.fvwm/albumgfx/ -e a.png" | tr -d “\012”[/code]

FvwmConsole creates the widget it’s supposed to create(64x64), but without any icon. The file “currentart” gets updated every 20 seconds(like specified), so the script gets run.
I appreciate your help :slight_smile:

Humm … I’ve just checked your FvwmScript by setting $current_art to an icon with different size: 48x48, 64x64, 80x80. Everything worked fine (so far). Thus, I was wondering what’s the content of your debug file /home/christian/.fvwm/currentart.

$ mpc The Dillinger Escape Plan - Sugar Coated Sour [playing] #12/186 1:45 (73%) volume:100% repeat: on random: on

And so…:

cat .fvwm/currentart "/home/christian/.fvwm/albumgfx/The Dillinger Escape Plan-Calculating Infinity.png"

Hmm. While writing this post I fiddled around a bit more with the CoverArt-script. I tried setting a static icon, and so I discovered that it wouldn’t show the icon unless I skipped “”… annoying. Filenames with blanks in them obviously won’t work.
sed’ing it should solve this?

Edit: Fvwm does not seem to enjoy escaping \blanks …? Any way of doing this? If not, I’ll probably just remove the blanks from the filenames and save myself some trouble.

Yes, actually, it seems not a problem of the FvwmScript but rather a problem of the ‘echo’ you’re using under the FvwmScript. I was betting on a blank space issue or double quote parsing. To counter this issue you have to double quote the double quote with some backslashes. It starts to be tricky. From my perspective and I think you’re about to do it, I would not bother with that and I would remove the blank space :blush:

I’ve modified the currentart.sh-script to output a filename without blanks, and edited a few of the actual filenames to match this. Still, it does not actually “fetch” the icon - it’s just a blank square. Setting a static icon works fine. Bah :confused:

EDIT: Yessir, now it works. I removed the Exec in front of echo…(GetOutput), and it works fine :slight_smile:
Now, all I need is to download more cover art :smiley:
Thanks for your help :slight_smile:

By the way, I don’t think the echo was the reason why quotes was not allowed.
When setting a static icon,
Set $blahblah /path/to/icon.png
worked, while
Set $blahblah “/path/to/icon.png” did not.
Ok, gotta run.