Firt of all, I've got 4 desktops with 4x1 pages each.
I wanted to be able to switch between them using well
known keys (Alt+F1..F12 and Alt+Arrows).
Alt+Fx is simple:
Key F1 A M GotoDeskAndPage 0 0 0
Key F2 A M GotoDeskAndPage 0 1 0
Key F3 A M GotoDeskAndPage 0 2 0
Key F4 A M GotoDeskAndPage 0 3 0
Key F5 A M GotoDeskAndPage 1 0 0
Key F6 A M GotoDeskAndPage 1 1 0
Key F7 A M GotoDeskAndPage 1 2 0
Key F8 A M GotoDeskAndPage 1 3 0
Key F9 A M GotoDeskAndPage 2 0 0
Key F10 A M GotoDeskAndPage 2 1 0
Key F11 A M GotoDeskAndPage 2 2 0
Key F12 A M GotoDeskAndPage 2 3 0
F1..F4 block navigates through Desk 0, F5..F8 through Desk 1 and so on...
But then Alt+arrows... Natural solution seems:
Key Left A M GotoPage -1p 0p
Key Right A M GotoPage +1p 0p
...but it only allows navigating on one Desk. So I came up with
following:
Key Left A M GotoLeft
Key Right A M GotoRight
DestroyFunc GotoLeft
AddToFunc GotoLeft
+ I PipeRead '\
maxdesk=2;\
maxpage=$(($[desk.pagesx]-1));\
if [ $[desk.n] -gt 0 ]; then\
prevdesk=$(($[desk.n]-1));\
else\
prevdesk=$maxdesk;\
fi;\
if [ $[page.nx] -eq 0 ]; then\
echo GotoDeskAndPage $prevdesk $maxpage 0;\
else\
echo GotoPage -1p 0p;\
fi'
DestroyFunc GotoRight
AddToFunc GotoRight
+ I PipeRead '\
maxdesk=2;\
maxpage=$(($[desk.pagesx]-1));\
if [ $[desk.n] -lt $maxdesk ]; then\
nextdesk=$(($[desk.n]+1));\
else\
nextdesk=0;\
fi;\
if [ $[page.nx] -eq $maxpage ]; then\
echo GotoDeskAndPage $nextdesk 0 0;\
else\
echo GotoPage +1p 0p;\
fi'
Which does the right thing. I wonder if it can be done easier? Maybe
without calling shell? I used shell because of two things:
- I wasn't able to check on which page I was. I know $[page.nx] has
this information, but I was unable to find something which would
enable me to write: + I TestSth($[page.nx] == 0) GotoDesk ...
- And I don't think it is possible to do some calculations from
within fvwm (like substracting one from current desk number).
My question is more generic -- how should such things be done efficiently?
I feel kind of unhappy knowing that whenever I press Alt+arrow a shell
is being launched just to echo some text. One little quirk of mine. ;-)
Hmm... perl? Just tell me what other options are... :-)
Regards,
Dawid
--
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 majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Wed Sep 03 2003 - 16:08:21 BST