Debian Codegraph @

bin/fvwm-menu-desktop-config.fpl

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # Uage: Module FvwmPerl -l fvwm-menu-desktop-config.fpl
2
3 # This script generates an FvwmForm similar to the FvwmForm-Desktop by
4 # Dan Espen but inserts the found xdg menus dynamically into the Form
5 # before processed.
6 # Author: Thomas Funk <[email protected]>
7 # Version: 1.4
8
9 package MenuConfig;
10 use File::Basename;
11 use strict;
12 use warnings;
13
14 my $modname = 'FvwmForm-XDGMenu-Config';
15 my $configtmp = "$ENV{'FVWM_USERDIR'}/.XDGMenu-Config.fvwm2rc";
16
17 open(MSG ,">$configtmp") || die "Error $!";
18
19 my $all = `fvwm-menu-desktop --get-menus all`;
20 my $selected = `fvwm-menu-desktop --get-menus desktop`;
21
22 my @all_filelist = split(/ /,$all);
23 my @selected_filelist = split(/ /,$selected);
24
25 my %all_menus = ();
26 my %selected__menus = ();
27 my $max_length = 0;
28 foreach my $path (@selected_filelist) {
29 my ($filename, $directories, $suffix) = fileparse($path, qr/\.[^.]*/);
30 push (@{$selected__menus{$directories}}, $filename);
31 }
32
33 my $i = 1;
34 foreach my $path (@all_filelist) {
35 # qr matched against the end of the $filename.
36 # The matching portion is removed and becomes the $suffix.
37 my ($filename, $directories, $suffix) = fileparse($path, qr/\.[^.]*/);
38 my $name = "MEN" . $filename;
39 push (@{$all_menus{$directories}{$i}}, ($filename, $name, "off"));
40 next if !defined $selected__menus{$directories};
41 foreach my $hit (@{$selected__menus{$directories}}) {
42 if ($filename eq $hit) {
43 pop (@{$all_menus{$directories}{$i}});
44 push (@{$all_menus{$directories}{$i}}, "on");
45 }
46 }
47 $max_length = length($filename) if ($max_length < length($filename));
48 $i++;
49 }
50
51 my $fvwmform_commands = "
52 DestroyModuleConfig ${modname}: *
53 *${modname}: Title \"\$[gt.Fvwm XDGMenu Config]\"
54 *${modname}: WarpPointer
55 #*${modname}: Line center
56 #*${modname}: Text \"\$[gt.Fvwm XDGMenu Config]\"
57 #*${modname}: Line
58 *${modname}: Separator
59 *${modname}: Line center
60 *${modname}: Text \"\$[gt.Available Menus]\"
61 *${modname}: Line
62 ";
63
64 if (scalar keys %all_menus != 0) {
65 foreach my $key (sort( keys %all_menus)) {
66 $fvwmform_commands .= "
67 *${modname}: Line left
68 *${modname}: Text \"\$[gt.Menus in]\"
69 *${modname}: Text \" $key\"
70 *${modname}: Line left
71 *${modname}: Selection meth multiple
72 ";
73 my $m_count = 0;
74 foreach my $count (sort(keys %{$all_menus{$key}})) {
75 my $menu = $all_menus{$key}{$count};
76 my $newstring = $menu->[0] . ' ' x eval($max_length-length($menu->[0]));
77 $fvwmform_commands .= "*${modname}: Choice $menu->[1] $menu->[1] $menu->[2] \"$newstring\"\n";
78 $m_count++;
79 if ($m_count == 4) {
80 $fvwmform_commands .= "
81 *${modname}: Line left
82 *${modname}: Selection meth multiple
83 ";
84 $m_count = 0;
85 }
86 }
87 $fvwmform_commands .= "
88 *${modname}: Line left
89 *${modname}: Text \" \"
90 ";
91 }
92 }
93 else {
94 $fvwmform_commands .= "
95 *${modname}: Line center
96 *${modname}: Text \"\$[gt.No menus found! Check why from within a terminal with]\"
97 *${modname}: Line center
98 *${modname}: Text \"'fvwm-menu-desktop -v'\"
99 *${modname}: Line left
100 *${modname}: Text \" \"
101 ";
102 }
103
104 $fvwmform_commands .= "
105 *${modname}: Separator
106 *${modname}: Line center
107 *${modname}: Text \"\$[gt.Options]\"
108 *${modname}: Button continue \"\$[gt.Help]\"
109 *${modname}: Command Module FvwmForm FvwmForm-XDGOptionsHelp
110 *${modname}: Line
111
112 *${modname}: Line Left
113 *${modname}: Text \"\$[gt.Include in Menu? ]\"
114 *${modname}: Selection SelItype single
115 *${modname}: Choice IncludeConfig IncludeConfig off \"\$[gt.Config ]\"
116 *${modname}: Choice IncludeRegen IncludeRegen off \"\$[gt.Regenerate ]\"
117 *${modname}: Choice IncludeBoth IncludeBoth on \"\$[gt.Both ]\"
118 *${modname}: Choice IncludeNone IncludeNone off \"\$[gt.None ]\"
119
120 *${modname}: Line Left
121 *${modname}: Text \"\$[gt.Use Icons? ]\"
122 *${modname}: Selection SelItype single
123 *${modname}: Choice IconsOn IconsOn off \"\$[gt.Yes ]\"
124 *${modname}: Choice IconsOff IconsOff on \"\$[gt.No ]\"
125
126 *${modname}: Text \"\$[gt. ]\"
127 *${modname}: Text \"\$[gt.Icon size: ]\"
128 *${modname}: Input Size 2 \"\"
129 *${modname}: Text \"\$[gt. (Default is 24)]\"
130
131 *${modname}: Line Left
132 *${modname}: Text \"\$[gt.Use Titles? ]\"
133 *${modname}: Selection SelItype single
134 *${modname}: Choice TitlesOn TitlesOn on \"\$[gt.Yes ]\"
135 *${modname}: Choice TitlesOff TitlesOff off \"\$[gt.No ]\"
136
137 *${modname}: Text \"\$[gt. ]\"
138 *${modname}: Text \"\$[gt.Used Icon theme: ]\"
139 *${modname}: Input Theme 20 \"\"
140
141 *${modname}: Line left
142 *${modname}: Text \"\$[gt.Directory Icon: ]\"
143 *${modname}: Input DirIcon 20 \"gnome-fs-directory\"
144
145 *${modname}: Text \"\$[gt. ]\"
146 *${modname}: Text \"\$[gt.Application Icon: ]\"
147 *${modname}: Input AppIcon 20 \"gnome-applications\"
148
149 *${modname}: Line left
150 *${modname}: Text \"\$[gt.Top Menu Name: ]\"
151 *${modname}: Input Title 20 \"XDGMenu\"
152
153 *${modname}: Text \"\$[gt. ]\"
154 *${modname}: Text \"\$[gt.Insert Menu Into: ]\"
155 *${modname}: Input InsertInto 20 \"\"
156
157 *${modname}: Line left
158 *${modname}: Text \"\$[gt.Terminal command: ]\"
159 *${modname}: Input TermCmd 30 \"xterm -e\"
160 *${modname}: Text \"\$[gt. (Used to run Terminal entries)]\"
161
162 *${modname}: Line left
163 *${modname}: Text \"\$[gt.Icon directory: ]\"
164 *${modname}: Input IconDir 30 \"~/.fvwm/icons\"
165 *${modname}: Text \"\$[gt. (Directory for converted icons)]\"
166
167 *${modname}: Line left
168 *${modname}: Text \"\$[gt.Output path: ]\"
169 *${modname}: Input Path 30 \"\$FVWM_USERDIR/.XDGMenu\"
170 *${modname}: Text \"\$[gt. (Full path to store output)]\"
171
172 *${modname}: Line left
173 *${modname}: Line
174 *${modname}: Separator
175
176 *${modname}: Line
177 *${modname}: Line expand
178 *${modname}: Button continue \"\$[gt.Export Menu]\"
179 *${modname}: Command InfoStoreAdd XDGMenuList \"\\
180 ";
181
182 foreach my $key (keys %all_menus) {
183 foreach my $file (keys %{$all_menus{$key}}) {
184 my $menu = $all_menus{$key}{$file};
185 $fvwmform_commands .= "\$($menu->[1]\?$key$menu->[0].menu )\\\n";
186 }
187 }
188
189 $fvwmform_commands .= "\"
190 *${modname}: Command PipeRead 'fvwm-menu-desktop \\
191 \$(IconsOn\?--enable-mini-icons )\\
192 \$(Size\?-s \$(Size) )\\
193 \$(TitlesOn\?--with-titles )\\
194 \$(TitlesOff\?--without-titles )\\
195 --include-items \$(IncludeConfig\?config)\\
196 \$(IncludeRegen\?regenerate)\\
197 \$(IncludeBoth\?both)\\
198 \$(IncludeNone\?none) \\
199 \$(TermCmd\?--term-cmd \"\$(TermCmd)\" )\\
200 \$(IconDir\?--mini-icon-dir \$(IconDir) )\\
201 \$(DirIcon\?--dir-icon \$(DirIcon) )\\
202 \$(AppIcon\?--app-icon \$(AppIcon) )\\
203 \$(InsertInto\?--insert-in-menu \$(InsertInto) )\\
204 \$(Title\?--title \$(Title) )\\
205 \$(Theme\?--theme \$(Theme) )\\
206 --set-menus \"\$[infostore.XDGMenuList]\" \\
207 \$(Path\? > \$(Path)) 2>> ~/.xsession-errors && echo \"Read \$(Path\? \$(Path))\"'
208
209 *${modname}: Button continue \"\$[gt.Save and Regenerate]\"
210
211 # Before saving the data, remove any previously saved data:
212 *${modname}: Command DestroyModuleConfig ${modname}Default: *
213 *${modname}: Command !(/bin/echo \"# This file last created by ${modname} on: `/bin/date`.\") > \$FVWM_USERDIR/.${modname}
214 ";
215
216 foreach my $key (keys %all_menus) {
217 foreach my $count (keys %{$all_menus{$key}}) {
218 my $menu = $all_menus{$key}{$count};
219 $fvwmform_commands .= "*${modname}: Command !(/bin/echo '*${modname}Default: $menu->[1] \$($menu->[1]\?on) ') >> \$FVWM_USERDIR/.${modname}\n";
220 }
221 }
222
223 $fvwmform_commands .= "
224 *${modname}: Command !(/bin/echo \\
225 '*${modname}Default: IncludeConfig \$(IncludeConfig\?on) ' ; /bin/echo \\
226 '*${modname}Default: IncludeRegen \$(IncludeRegen\?on) ' ; /bin/echo \\
227 '*${modname}Default: IncludeBoth \$(IncludeBoth\?on) ' ; /bin/echo \\
228 '*${modname}Default: IncludeNone \$(IncludeNone\?on) ' ; /bin/echo \\
229 '*${modname}Default: IconsOn \$(IconsOn\?on) ' ; /bin/echo \\
230 '*${modname}Default: IconsOff \$(IconsOff\?on) ' ; /bin/echo \\
231 '*${modname}Default: Size \$(Size) ' ; /bin/echo \\
232 '*${modname}Default: TitlesOn \$(TitlesOn\?on) ' ; /bin/echo \\
233 '*${modname}Default: TitlesOff \$(TitlesOff\?on) ' ; /bin/echo \\
234 '*${modname}Default: Theme \$(Theme) ' \\
235 ) >> \$FVWM_USERDIR/.${modname}
236
237 *${modname}: Command !(/bin/echo \\
238 '*${modname}Default: Title \$(Title) ' ; /bin/echo \\
239 '*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
240 '*${modname}Default: Path \$(Path) ' ; /bin/echo \\
241 '*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
242 '*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
243 '*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
244 '*${modname}Default: AppIcon \$(AppIcon) ' \\
245 ) >> \$FVWM_USERDIR/.${modname}
246
247 *${modname}: Command PipeRead 'fvwm-menu-desktop'
248
249 *${modname}: Button continue \"\$[gt.Save]\"
250
251 # Before saving the data, remove any previously saved data:
252 *${modname}: Command DestroyModuleConfig ${modname}Default: *
253 *${modname}: Command !(/bin/echo \"# This file last created by ${modname} on: `/bin/date`.\") > \$FVWM_USERDIR/.${modname}
254 ";
255
256 foreach my $key (keys %all_menus) {
257 foreach my $count (keys %{$all_menus{$key}}) {
258 my $menu = $all_menus{$key}{$count};
259 $fvwmform_commands .= "*${modname}: Command !(/bin/echo '*${modname}Default: $menu->[1] \$($menu->[1]\?on) ') >> \$FVWM_USERDIR/.${modname}\n";
260 }
261 }
262
263 $fvwmform_commands .= "
264 *${modname}: Command !(/bin/echo \\
265 '*${modname}Default: IncludeConfig \$(IncludeConfig\?on) ' ; /bin/echo \\
266 '*${modname}Default: IncludeRegen \$(IncludeRegen\?on) ' ; /bin/echo \\
267 '*${modname}Default: IncludeBoth \$(IncludeBoth\?on) ' ; /bin/echo \\
268 '*${modname}Default: IncludeNone \$(IncludeNone\?on) ' ; /bin/echo \\
269 '*${modname}Default: IconsOn \$(IconsOn\?on) ' ; /bin/echo \\
270 '*${modname}Default: IconsOff \$(IconsOff\?on) ' ; /bin/echo \\
271 '*${modname}Default: Size \$(Size) ' ; /bin/echo \\
272 '*${modname}Default: TitlesOn \$(TitlesOn\?on) ' ; /bin/echo \\
273 '*${modname}Default: TitlesOff \$(TitlesOff\?on) ' ; /bin/echo \\
274 '*${modname}Default: Theme \$(Theme) ' \\
275 ) >> \$FVWM_USERDIR/.${modname}
276
277 *${modname}: Command !(/bin/echo \\
278 '*${modname}Default: Title \$(Title) ' ; /bin/echo \\
279 '*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
280 '*${modname}Default: Path \$(Path) ' ; /bin/echo \\
281 '*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
282 '*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
283 '*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
284 '*${modname}Default: AppIcon \$(AppIcon) ' \\
285 ) >> \$FVWM_USERDIR/.${modname}
286
287 *${modname}: Button restart \"\$[gt.Reset]\"
288 *${modname}: Command Nop
289 *${modname}: Button continue \"\$[gt.Help]\"
290 *${modname}: Command Module FvwmForm FvwmForm-XDGMenuHelp
291 *${modname}: Button quit \"\$[gt.Close]\"
292 *${modname}: Command Nop
293
294 # Tell ${modname} to read vars from .${modname}Default file:
295 *${modname}: UseData .${modname} *${modname}Default
296 ";
297
298 # We are just asked to open a window, give fvwm a chance to do it
299 ::unlock();
300
301 $fvwmform_commands =~ s/^\s+//; # trim leading whitespace
302
303 print MSG "$fvwmform_commands\n\n";
304 close(MSG);
305
306 ::command(qq[
307 Read $configtmp
308 FvwmForm ${modname}
309 ]);
310
311 sleep(2);
312 unlink $configtmp
313
314 # Local Variables:
315 # mode: perl
316 # End: