I thought some of you might be interested in this – especially if you use icons for iconic applications.
More often than not, I have icons focused on the root window and I’d rather use the keyboard to switch between them, and then press enter to deiconify them. Here’s what I came up with:
Key Up I A Direction North (CurrentPage, Iconic) Focus
… as a first example. Essentially it says that in the direction of north, for the next window that’s on the current page and is iconic, to focus it. Then it is bound to the up arrow key, to iconic windows. I’ll let you guess the other bindings:
Key Down I A Direction South (CurrentPage, Iconic) Focus
Key Right I A Direction East (CurrentPage, Iconic) Focus
Key Left I A Direction West (CurrentPage, Iconic) Focus
Try it – it works rather well. You might also (depending on the icons you want included) wish to add:
as a condition to the commands. The enter key binding to deiconify the app is this:
Key Return I A Current (Iconic) Iconify off
I’m sure someone will have a use for this.
– Thomas Adam
I’m not sure if this should be its own topic or part of this topic, so feel free to move as necessary. The above is similar to what I want, except that I really just want a keybinding (i.e. Ctrl-Alt-2) that will deiconify an app in the IconBox (in this case, the 2nd item). I don’t want to be navigating icons, I just want to have a direct keybinding to deiconify a specific app.
I’m really not sure how to specify this. Any advice would be appreciated.
It seems like the best way to implement this will be to write window IDs to a file. The file will act like a heap, so that the last app to be iconified will be added to the bottom, and IDs will be removed as they are deiconified. This should only work if PlaceAgain Icon is in effect, which is indeed what I want.
(Note, the below is all pseudo-code )
For example, when an app is iconified:
PipeRead echo $[w.id] > file
and when the app is deiconified, something like:
PipeRead sed -e “/$[w.id]/d”
To actually implement the keybinding (i.e. ctrl-alt-2), I’ll have to read the file line by line until i reach line N, and then deiconify the app with this window ID.
Thomas Adam’s link will be very helpful in doing some of this. I’ll give it a shot tomorrow
Okay, it’s finally working! A huge thanks goes to Thomas Adam for helping me with it. This is honestly one of the most useful things I’ve ever done for fvwm, it makes navigating with a keyboard so much easier.
How to use keybindings to deiconify apps (i.e. ctrl-alt-N to deiconify the Nth app in your IconBox).
(Please note that this assumes you’re using the PlaceAgain Icon for removing gaps in the IconBox. Otherwise it’s more difficult to keep track of window IDs, although possible.)
- On iconifying your app, append the Window ID to a file. For example, in your Thumbnail function:
+ I PipeRead "echo $[w.id] >> $[FVWM_USERDIR]/.icons"
- On deiconifying your app, remove the Window ID from the file. For example, in your DeThumbnail function:
+ I PipeRead "sed -ie '/$[w.id]/d' $[FVWM_USERDIR]/.icons"
- Set up a function that is exactly the same as DeiconifyAndRearrange, but use “+ I” instead of “+ C”, like:
[code]# This will remove gaps when de-iconifying an application from the keybinding
- I Iconify off
- I All (CurrentPage, Iconic) PlaceAgain Icon[/code]
- Set up your keybindings, like:
[code]# The following allows us to associate keybindings with deiconifying
iconified apps that appear in the IconBox. As coded here, this will only work
if PlaceAgain Icon is used in the config (as per the default).
Key 1 A MC DeiconifyAppNum 1
Key 2 A MC DeiconifyAppNum 2
Key 3 A MC DeiconifyAppNum 3
Key 4 A MC DeiconifyAppNum 4
Key 5 A MC DeiconifyAppNum 5
Key 6 A MC DeiconifyAppNum 6
- I PipeRead
echo WindowId $$(sed -ne '$$0p' $[FVWM_USERDIR]/.icons) DeiconifyAndRearrange2[/code]
- Be sure that you remove the file in case there are residual Window IDs from a previous instance of fvwm. For example, in your StartFunction:
+ I Test (Init) Exec exec rm -f $[FVWM_USERDIR]/.icons
That’s it! Hope you enjoy this as much as I do, it really makes keyboard navigation so much better and faster.
Just a quick caveat…
The “-i” flag to GNU Sed is recent (as of version 4.x) and is by no means backwards compatible. Hence if you run into problems you will need to use a construct such as:
+ I PipeRead "sed -e '/$[w.id]/d' < $[FVWM_USERDIR]/.icons > /tmp/tmpfile.sed && mv /tmp/tmpfile.sed $[FVWM_USERDIR]/.icons"
… since this is effectively how the “-i” flag to sed works, anyway.
– Thomas Adam