SOLVED: SetEnv Fvwm Variable $[w.class]-$[]

Hello all,

I was working on some code to move a deiconified window to the desktop it was launched on and it is working. I was thinking about adding some code to ShowDesktop and I ran into an issue. I was creating a variable called $[desknumber] and writing the value of the desktop number is was launched to to this variable and then using MoveToDesk to move it to the proper desk using MoveToDesk 0 $[desknumber]. This works. If I decide to create something to ShowDesktop, if multiple windows are iconified the variable $[desknumber] will be wrong. I am trying to create variable for each window when it is iconified so the desk number will write to them. I have the following code:

[code]+ I PipeRead 'echo SetEnv $[w.class]-$[] cat ~/.fvwm/windows/$[w.class]-$[]

  • I MoveToDesk 0 $[$[w.class]-$[]]
  • I GoToDesk 0 $[$[w.class]-$[]]
  • I UnsetEnv $[$[w.class]-$[]][/code]

The variable (Firefox-0x2000003=1] is getting created using the following when I display ‘env’ from a terminal:

+ I PipeRead 'echo SetEnv $[w.class]-$[] `cat ~/.fvwm/windows/$[w.class]-$[]`'

I am trying to MoveToDesk, GoToDesk and UnSetEnv using the variable and it is not working:

[code]+ I MoveToDesk 0 $[$[w.class]-$[]]

  • I GoToDesk 0 $[$[w.class]-$[]]
  • I UnsetEnv $[$[w.class]-$[]][/code]

Does anyone have any ideas on how to make this work?

Thank you,

Didn’t look at the details, but some suggestions.

First use InfoStore variables, not environment variables for this. They will be easier to work with and these do not need to be in the environment.

# Stores the desk number in a variable
InfoStoreAdd Desk-$[] 1

# Returns the desk number

# Deletes the variable
InfoStoreRemove Desk-$[]

In addition you may find States a nicer way to do this. If all you care about is a few desks you can assign each window a state based on the desk it was iconified on. Then use the State to determine what desk to move the window to when it is deiconified.

Thank you for the advice. I will checkout States afterwards but I am having an issue for InfoStore. It isn’t moving the window to the desk that started the app.

I am writing the initial desknumber to the variable $[w.class]-$[]
Example: firefox-0x200003 1

[code]DestroyFunc Thumbnail
AddToFunc Thumbnail

  • I Raise
  • I SetEnv Icon-$[] $[w.IconFile]
  • I InfoStoreAdd $[w.class]-$[] $[w.desk][/code]
DestroyFunc DeThumbnail
AddToFunc   DeThumbnail[/code]
+ I PipeRead "echo WindowStyle IconOverride, Icon \\$\\[Icon-$[]\\]"
+ I UnsetEnv Icon-$[]
+ I PipeRead "rm -f /dev/shm/icon.tmp.$[].png"
+ I MoveToDesk 0 $[infostore.$[w.class]-$[]]
+ I GoToDesk 0 $[infostore.$[w.class]-$[]]
+ I InfoStoreRemove $[w.class]-$[][/code]

Any ideas?


***Update 03/21/2017***
For some reason the system was having trouble with the following:
[code]+ I InfoStoreAdd $[w.class]-$[] $[w.desk]

I changed it to use only the $[] and things are working…


  • I InfoStoreAdd desk-$[] $[w.desk][/code]


Just a crazy idea:
Instead of the uncomfortable method of writing information to external files, you may also misuse a Complex Function that you create on-the-fly. For example, you can iconify a window using this function]AddToFunc ExtendedIconify

  • I WindowId $0 (!Iconic) Iconify True
  • I NoWindow AddToFunc F$0 I WindowId $0 (Iconic) Iconify False
  • I NoWindow AddToFunc F$0 I TestRc (Match) WindowId $0 MoveToDesk $1
  • I NoWindow AddToFunc F$0 I TestRc (Match) DestroyFunc F$0[/code]This is untested, sorry, but I have similar constructions in use. If you call this function, after some user action, by Function ExtendedIconify $[] $[w.desk] then you will have a window-specific function defined that you can call later to deiconify and move the window to the original desktop. It will look like this, but you won’t see it]AddToFunc F0xa0000d
  • I WindowId 0xa0000d (Iconic) Iconify False
  • I TestRc (Match) WindowId 0xa0000d MoveToDesk 3
  • I TestRc (Match) DestroyFunc F0xa0000d [/code]The function will destroy itself after deiconification. It contains all relevant information, so it even doesn’t need any parameters. Feel free to play with it.