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}: Colorset 5
54 *${modname}: ItemColorset 5
55 *${modname}: Title \"\$[gt.Fvwm XDGMenu Config]\"
56 *${modname}: WarpPointer
57 #*${modname}: Line center
58 #*${modname}: Text \"\$[gt.Fvwm XDGMenu Config]\"
59 #*${modname}: Line
60 *${modname}: Separator
61 *${modname}: Line center
62 *${modname}: Text \"\$[gt.Available Menus]\"
63 *${modname}: Line
64 ";
65
66 if (scalar keys %all_menus != 0) {
67 foreach my $key (sort( keys %all_menus)) {
68 $fvwmform_commands .= "
69 *${modname}: Line left
70 *${modname}: Text \"\$[gt.Menus in]\"
71 *${modname}: Text \" $key\"
72 *${modname}: Line left
73 *${modname}: Selection meth multiple
74 ";
75 my $m_count = 0;
76 foreach my $count (sort(keys %{$all_menus{$key}})) {
77 my $menu = $all_menus{$key}{$count};
78 my $newstring = $menu->[0] . ' ' x eval($max_length-length($menu->[0]));
79 $fvwmform_commands .= "*${modname}: Choice $menu->[1] $menu->[1] $menu->[2] \"$newstring\"\n";
80 $m_count++;
81 if ($m_count == 4) {
82 $fvwmform_commands .= "
83 *${modname}: Line left
84 *${modname}: Selection meth multiple
85 ";
86 $m_count = 0;
87 }
88 }
89 $fvwmform_commands .= "
90 *${modname}: Line left
91 *${modname}: Text \" \"
92 ";
93 }
94 }
95 else {
96 $fvwmform_commands .= "
97 *${modname}: Line center
98 *${modname}: Text \"\$[gt.No menus found! Check why from within a terminal with]\"
99 *${modname}: Line center
100 *${modname}: Text \"'fvwm-menu-desktop -v'\"
101 *${modname}: Line left
102 *${modname}: Text \" \"
103 ";
104 }
105
106 $fvwmform_commands .= "
107 *${modname}: Separator
108 *${modname}: Line center
109 *${modname}: Text \"\$[gt.Options]\"
110 *${modname}: Button continue \"\$[gt.Help]\"
111 *${modname}: Command Module FvwmForm FvwmForm-XDGOptionsHelp
112 *${modname}: Line
113
114 *${modname}: Line Left
115 *${modname}: Text \"\$[gt.Include in Menu? ]\"
116 *${modname}: Selection SelItype single
117 *${modname}: Choice IncludeConfig IncludeConfig off \"\$[gt.Config ]\"
118 *${modname}: Choice IncludeRegen IncludeRegen off \"\$[gt.Regenerate ]\"
119 *${modname}: Choice IncludeBoth IncludeBoth on \"\$[gt.Both ]\"
120 *${modname}: Choice IncludeNone IncludeNone off \"\$[gt.None ]\"
121
122 *${modname}: Line Left
123 *${modname}: Text \"\$[gt.Use Icons? ]\"
124 *${modname}: Selection SelItype single
125 *${modname}: Choice IconsOn IconsOn off \"\$[gt.Yes ]\"
126 *${modname}: Choice IconsOff IconsOff on \"\$[gt.No ]\"
127
128 *${modname}: Text \"\$[gt. ]\"
129 *${modname}: Text \"\$[gt.Icon size: ]\"
130 *${modname}: Input Size 2 \"\"
131 *${modname}: Text \"\$[gt. (Default is 24)]\"
132
133 *${modname}: Line Left
134 *${modname}: Text \"\$[gt.Use Titles? ]\"
135 *${modname}: Selection SelItype single
136 *${modname}: Choice TitlesOn TitlesOn on \"\$[gt.Yes ]\"
137 *${modname}: Choice TitlesOff TitlesOff off \"\$[gt.No ]\"
138
139 *${modname}: Text \"\$[gt. ]\"
140 *${modname}: Text \"\$[gt.Used Icon theme: ]\"
141 *${modname}: Input Theme 20 \"\"
142
143 *${modname}: Line left
144 *${modname}: Text \"\$[gt.Directory Icon: ]\"
145 *${modname}: Input DirIcon 20 \"gnome-fs-directory\"
146
147 *${modname}: Text \"\$[gt. ]\"
148 *${modname}: Text \"\$[gt.Application Icon: ]\"
149 *${modname}: Input AppIcon 20 \"gnome-applications\"
150
151 *${modname}: Line left
152 *${modname}: Text \"\$[gt.Top Menu Name: ]\"
153 *${modname}: Input Title 20 \"XDGMenu\"
154
155 *${modname}: Text \"\$[gt. ]\"
156 *${modname}: Text \"\$[gt.Insert Menu Into: ]\"
157 *${modname}: Input InsertInto 20 \"\"
158
159 *${modname}: Line left
160 *${modname}: Text \"\$[gt.Terminal command: ]\"
161 *${modname}: Input TermCmd 30 \"xterm -e\"
162 *${modname}: Text \"\$[gt. (Used to run Terminal entries)]\"
163
164 *${modname}: Line left
165 *${modname}: Text \"\$[gt.Icon directory: ]\"
166 *${modname}: Input IconDir 30 \"~/.fvwm/icons\"
167 *${modname}: Text \"\$[gt. (Directory for converted icons)]\"
168
169 *${modname}: Line left
170 *${modname}: Text \"\$[gt.Output path: ]\"
171 *${modname}: Input Path 30 \"\$FVWM_USERDIR/.XDGMenu\"
172 *${modname}: Text \"\$[gt. (Full path to store output)]\"
173
174 *${modname}: Line left
175 *${modname}: Line
176 *${modname}: Separator
177
178 *${modname}: Line
179 *${modname}: Line expand
180 *${modname}: Button continue \"\$[gt.Export Menu]\"
181 *${modname}: Command InfoStoreAdd XDGMenuList \"\\
182 ";
183
184 foreach my $key (keys %all_menus) {
185 foreach my $file (keys %{$all_menus{$key}}) {
186 my $menu = $all_menus{$key}{$file};
187 $fvwmform_commands .= "\$($menu->[1]\?$key$menu->[0].menu )\\\n";
188 }
189 }
190
191 $fvwmform_commands .= "\"
192 *${modname}: Command PipeRead 'fvwm-menu-desktop \\
193 \$(IconsOn\?--enable-mini-icons )\\
194 \$(Size\?-s \$(Size) )\\
195 \$(TitlesOn\?--with-titles )\\
196 \$(TitlesOff\?--without-titles )\\
197 --include-items \$(IncludeConfig\?config)\\
198 \$(IncludeRegen\?regenerate)\\
199 \$(IncludeBoth\?both)\\
200 \$(IncludeNone\?none) \\
201 \$(TermCmd\?--term-cmd \"\$(TermCmd)\" )\\
202 \$(IconDir\?--mini-icon-dir \$(IconDir) )\\
203 \$(DirIcon\?--dir-icon \$(DirIcon) )\\
204 \$(AppIcon\?--app-icon \$(AppIcon) )\\
205 \$(InsertInto\?--insert-in-menu \$(InsertInto) )\\
206 \$(Title\?--title \$(Title) )\\
207 \$(Theme\?--theme \$(Theme) )\\
208 --set-menus \"\$[infostore.XDGMenuList]\" \\
209 \$(Path\? > \$(Path)) 2>> ~/.xsession-errors && echo \"Read \$(Path\? \$(Path))\"'
210
211 *${modname}: Button continue \"\$[gt.Save and Regenerate]\"
212
213 # Before saving the data, remove any previously saved data:
214 *${modname}: Command DestroyModuleConfig ${modname}Default: *
215 *${modname}: Command !(/bin/echo \"# This file last created by ${modname} on: `/bin/date`.\") > \$FVWM_USERDIR/.${modname}
216 ";
217
218 foreach my $key (keys %all_menus) {
219 foreach my $count (keys %{$all_menus{$key}}) {
220 my $menu = $all_menus{$key}{$count};
221 $fvwmform_commands .= "*${modname}: Command !(/bin/echo '*${modname}Default: $menu->[1] \$($menu->[1]\?on) ') >> \$FVWM_USERDIR/.${modname}\n";
222 }
223 }
224
225 $fvwmform_commands .= "
226 *${modname}: Command !(/bin/echo \\
227 '*${modname}Default: IncludeConfig \$(IncludeConfig\?on) ' ; /bin/echo \\
228 '*${modname}Default: IncludeRegen \$(IncludeRegen\?on) ' ; /bin/echo \\
229 '*${modname}Default: IncludeBoth \$(IncludeBoth\?on) ' ; /bin/echo \\
230 '*${modname}Default: IncludeNone \$(IncludeNone\?on) ' ; /bin/echo \\
231 '*${modname}Default: IconsOn \$(IconsOn\?on) ' ; /bin/echo \\
232 '*${modname}Default: IconsOff \$(IconsOff\?on) ' ; /bin/echo \\
233 '*${modname}Default: Size \$(Size) ' ; /bin/echo \\
234 '*${modname}Default: TitlesOn \$(TitlesOn\?on) ' ; /bin/echo \\
235 '*${modname}Default: TitlesOff \$(TitlesOff\?on) ' ; /bin/echo \\
236 '*${modname}Default: Theme \$(Theme) ' \\
237 ) >> \$FVWM_USERDIR/.${modname}
238
239 *${modname}: Command !(/bin/echo \\
240 '*${modname}Default: Title \$(Title) ' ; /bin/echo \\
241 '*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
242 '*${modname}Default: Path \$(Path) ' ; /bin/echo \\
243 '*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
244 '*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
245 '*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
246 '*${modname}Default: AppIcon \$(AppIcon) ' \\
247 ) >> \$FVWM_USERDIR/.${modname}
248
249 *${modname}: Command PipeRead 'fvwm-menu-desktop'
250
251 *${modname}: Button continue \"\$[gt.Save]\"
252
253 # Before saving the data, remove any previously saved data:
254 *${modname}: Command DestroyModuleConfig ${modname}Default: *
255 *${modname}: Command !(/bin/echo \"# This file last created by ${modname} on: `/bin/date`.\") > \$FVWM_USERDIR/.${modname}
256 ";
257
258 foreach my $key (keys %all_menus) {
259 foreach my $count (keys %{$all_menus{$key}}) {
260 my $menu = $all_menus{$key}{$count};
261 $fvwmform_commands .= "*${modname}: Command !(/bin/echo '*${modname}Default: $menu->[1] \$($menu->[1]\?on) ') >> \$FVWM_USERDIR/.${modname}\n";
262 }
263 }
264
265 $fvwmform_commands .= "
266 *${modname}: Command !(/bin/echo \\
267 '*${modname}Default: IncludeConfig \$(IncludeConfig\?on) ' ; /bin/echo \\
268 '*${modname}Default: IncludeRegen \$(IncludeRegen\?on) ' ; /bin/echo \\
269 '*${modname}Default: IncludeBoth \$(IncludeBoth\?on) ' ; /bin/echo \\
270 '*${modname}Default: IncludeNone \$(IncludeNone\?on) ' ; /bin/echo \\
271 '*${modname}Default: IconsOn \$(IconsOn\?on) ' ; /bin/echo \\
272 '*${modname}Default: IconsOff \$(IconsOff\?on) ' ; /bin/echo \\
273 '*${modname}Default: Size \$(Size) ' ; /bin/echo \\
274 '*${modname}Default: TitlesOn \$(TitlesOn\?on) ' ; /bin/echo \\
275 '*${modname}Default: TitlesOff \$(TitlesOff\?on) ' ; /bin/echo \\
276 '*${modname}Default: Theme \$(Theme) ' \\
277 ) >> \$FVWM_USERDIR/.${modname}
278
279 *${modname}: Command !(/bin/echo \\
280 '*${modname}Default: Title \$(Title) ' ; /bin/echo \\
281 '*${modname}Default: InsertInto \$(InsertInto) ' ; /bin/echo \\
282 '*${modname}Default: Path \$(Path) ' ; /bin/echo \\
283 '*${modname}Default: TermCmd \$(TermCmd) ' ; /bin/echo \\
284 '*${modname}Default: IconDir \$(IconDir) ' ; /bin/echo \\
285 '*${modname}Default: DirIcon \$(DirIcon) ' ; /bin/echo \\
286 '*${modname}Default: AppIcon \$(AppIcon) ' \\
287 ) >> \$FVWM_USERDIR/.${modname}
288
289 *${modname}: Button restart \"\$[gt.Reset]\"
290 *${modname}: Command Nop
291 *${modname}: Button continue \"\$[gt.Help]\"
292 *${modname}: Command Module FvwmForm FvwmForm-XDGMenuHelp
293 *${modname}: Button quit \"\$[gt.Close]\"
294 *${modname}: Command Nop
295
296 # Tell ${modname} to read vars from .${modname}Default file:
297 *${modname}: UseData .${modname} *${modname}Default
298 ";
299
300 # We are just asked to open a window, give fvwm a chance to do it
301 ::unlock();
302
303 $fvwmform_commands =~ s/^\s+//; # trim leading whitespace
304
305 print MSG "$fvwmform_commands\n\n";
306 close(MSG);
307
308 ::command(qq[
309 Read $configtmp
310 FvwmForm ${modname}
311 ]);
312
313 sleep(2);
314 unlink $configtmp
315
316 # Local Variables:
317 # mode: perl
318 # End: