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

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]-$[w.id] cat ~/.fvwm/windows/$[w.class]-$[w.id]

  • I MoveToDesk 0 $[$[w.class]-$[w.id]]
  • I GoToDesk 0 $[$[w.class]-$[w.id]]
  • I UnsetEnv $[$[w.class]-$[w.id]][/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]-$[w.id] `cat ~/.fvwm/windows/$[w.class]-$[w.id]`'

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

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

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

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

Thank you,
Tony

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-$[w.id] 1

# Returns the desk number
$[infostore.Desk-$[w.id]]

# Deletes the variable
InfoStoreRemove Desk-$[w.id]

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]-$[w.id]
Example: firefox-0x200003 1

[code]DestroyFunc Thumbnail
AddToFunc Thumbnail

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

Any ideas?

Thanks,
Tony

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

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

[code]

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

Thanks,
Tony

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.id] $[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.