Mikhael Goikhman writes:
>On 15 Dec 2001 23:28:32 +0100, Riswick, J.G.A. van wrote:
>>
>> I'd like to implement a 'goto desktop' menu which
>> shows a few desktop numbers (as menu items), and a '*' in
>> front of the current desktop number. Upon choosing a number,
>> the current desktop is changed to that number.
>>
>> The question is, how to get the asterisk (*) in front
>> of the current desktop number. Is it possible to retreive
>> this using FvwmCommand?
>
>Use this piece of code (4 lines) that builds and shows requested menu.
>
> AddToFunc ShowMyDeskMenu
> + I DestroyMenu MyDeskMenu
> + I PipeRead `for i in 0 1 2 3; do echo -n 'AddToMenu MyDeskMenu "';
>[ $$d = ${i} ] && echo -n "**"; echo \\ ${i}'" GotoDesk '${i}; done
> ^
> |__ real TAB for better alignment
> + I Menu MyDeskMenu
>
>Double dollar is to expand desk at run time, not at func definition time.
>Double star is to escape star in AddToMenu.
>Double slash is to escape TAB (one for FVWM, another for /bin/sh), so TAB
>is passed to echo.
>${i} ensures FVWM does not expands var, but /bin/sh does.
You can also use the DynamicPopupAction feature. Here is how I have it set up:
AddToMenu RootMenu "Root Menu" Title
+ "MyPrograms" Popup MyPrograms
+ "Desk Tops" Popup DeskTops
<etc>
AddToMenu DeskTops "Desk Tops" Title
+ DynamicPopupAction Function MyDeskTops
AddToFunc MyDeskTops
+ I DestroyMenu recreate DeskTops
+ I PipeRead `/home/glenlee/.fvwm/desk.prl $$d $$[page.nx] $$[page.ny]`
#!/usr/bin/perl
# desk.prl
%desk = ("0","F1","1","F2","2","F3","3","F4","4","F5","5","F6","6","F7","7","F8","8","F9","9","F10","10","F11","11","F12","12","1","13","2","14","3","15","4","16","5","17","6","18","7","19","8","20","9","21","0","22","Home","23","End");
for ($i=0;$i<24;$i++) {
print qq(AddToMenu DeskTops );
if (($ARGV[0] == $i) && (($ARGV[1] == 0) && ($ARGV[2] == 0))) {
print qq("=> Go to Desk $desk{$i}" GotoDeskAndPage $i 0 0\n);
print qq(+ " Page 0 1" GotoDeskAndPage $i 1 0\n);
print qq(+ " Page 1 1" GotoDeskAndPage $i 1 1\n);
print qq(+ " Page 1 0" GotoDeskAndPage $i 0 1\n);
} elsif (($ARGV[0] == $i) && (($ARGV[1] == 1) && ($ARGV[2] == 0))) {
print qq(" Go to Desk $desk{$i}" GotoDeskAndPage $i 0 0\n);
print qq(+ "=> Page 0 1" GotoDeskAndPage $i 1 0\n);
print qq(+ " Page 1 1" GotoDeskAndPage $i 1 1\n);
print qq(+ " Page 1 0" GotoDeskAndPage $i 0 1\n);
} elsif (($ARGV[0] == $i) && (($ARGV[1] == 1) && ($ARGV[2] == 1))) {
print qq(" Go to Desk $desk{$i}" GotoDeskAndPage $i 0 0\n);
print qq(+ " Page 0 1" GotoDeskAndPage $i 1 0\n);
print qq(+ "=> Page 1 1" GotoDeskAndPage $i 1 1\n);
print qq(+ " Page 1 0" GotoDeskAndPage $i 0 1\n);
} elsif (($ARGV[0] == $i) && (($ARGV[1] == 0) && ($ARGV[2] == 1))) {
print qq(" Go to Desk $desk{$i}" GotoDeskAndPage $i 0 0\n);
print qq(+ " Page 0 1" GotoDeskAndPage $i 1 0\n);
print qq(+ " Page 1 1" GotoDeskAndPage $i 1 1\n);
print qq(+ "=> Page 1 0" GotoDeskAndPage $i 0 1\n);
} else {
print qq(" Go to Desk $desk{$i}" GotoDeskAndPage $i 0 0\n);
print qq(+ " Page 0 1" GotoDeskAndPage $i 1 0\n);
print qq(+ " Page 1 1" GotoDeskAndPage $i 1 1\n);
print qq(+ " Page 1 0" GotoDeskAndPage $i 0 1\n);
}
}
Glen
--
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 Sun Dec 16 2001 - 13:43:40 GMT