1 /* Copyright (C) 2010 Carlos R. Mafra */
8 #define _(text) gettext(text)
10 #include <WINGs/WUtil.h>
12 #define MAX_NR_APPS 50 /* Maximum number of entries in each apps list */
13 #define MAX_WMS 10 /* Maximum number of other window managers to check */
14 #include "wmgenmenu.h"
16 static void find_and_write(char **list
);
17 static inline void workspaces(void);
18 static inline void lock_screen(void);
19 static inline void wmaker_config(void);
20 static inline void run_command(void);
21 static void other_window_managers(char **other_wm
);
22 static inline void wm_visual(void);
23 static inline void write_first_line(int count
);
27 int main(int argc
, char *argv
[])
32 path
= getenv("PATH");
33 locale
= getenv("LANG");
34 setlocale(LC_ALL
, "");
36 if (getenv("NLSPATH"))
37 bindtextdomain("wmgenmenu", getenv("NLSPATH"));
39 bindtextdomain("wmgenmenu", LOCALEDIR
);
41 bind_textdomain_codeset("wmgenmenu", "UTF-8");
42 textdomain("wmgenmenu");
44 printf("\(\"Window Maker\",\n");
47 printf(_("Applications"));
50 /* This "first" printf is different from the others! */
52 printf(_("Terminals"));
54 find_and_write(terminals
);
56 printf("\n ),\n \(\"");
57 printf(_("Internet"));
59 find_and_write(internet
);
61 printf("\n ),\n \(\"");
64 find_and_write(email
);
66 printf("\n ),\n \(\"");
67 printf(_("Mathematics"));
69 find_and_write(Mathematiks
);
71 printf("\n ),\n \(\"");
72 printf(_("File Managers"));
74 find_and_write(file_managers
);
76 printf("\n ),\n \(\"");
77 printf(_("Graphics"));
79 find_and_write(Graphics
);
81 printf("\n ),\n \(\"");
82 printf(_("Multimedia"));
84 find_and_write(Multimedia
);
86 printf("\n ),\n \(\"");
89 find_and_write(Editors
);
91 printf("\n ),\n \(\"");
92 printf(_("Development"));
94 find_and_write(development
);
96 printf("\n ),\n \(\"");
97 printf(_("Window Maker"));
99 find_and_write(WindowMaker
);
101 printf("\n ),\n \(\"");
104 find_and_write(Office
);
106 printf("\n ),\n \(\"");
107 printf(_("Astronomy"));
109 find_and_write(Astronomie
);
111 printf("\n ),\n \(\"");
114 find_and_write(Sound
);
116 printf("\n ),\n \(\"");
119 find_and_write(Comics
);
121 printf("\n ),\n \(\"");
122 printf(_("Viewers"));
124 find_and_write(Viewers
);
126 printf("\n ),\n \(\"");
127 printf(_("Utilities"));
129 find_and_write(Utilities
);
131 printf("\n ),\n \(\"");
134 find_and_write(System
);
136 printf("\n ),\n \(\"");
139 find_and_write(Video
);
141 printf("\n ),\n \(\"");
142 printf(_("Chat and Talk"));
144 find_and_write(Chat
);
146 printf("\n ),\n \(\"");
147 printf(_("P2P-Network"));
151 printf("\n ),\n \(\"");
154 find_and_write(Games
);
156 printf("\n ),\n \(\"");
157 printf(_("OpenSUSE"));
159 find_and_write(OpenSUSE
);
161 printf("\n ),\n \(\"");
162 printf(_("Mandriva"));
164 find_and_write(Mandriva
);
166 /* This must be after the last entry */
176 printf(_("Info Panel"));
177 printf("\", INFO_PANEL),\n");
180 printf(_("Restart"));
181 printf("\", RESTART),\n");
183 other_window_managers(other_wm
);
187 printf(_("Exit..."));
188 printf("\", EXIT)\n");
190 /* Final closing parenthesis */
196 static void find_and_write(char **list
)
199 char *location
, **argv
;
202 for (i
= 0; i
<= MAX_NR_APPS
; i
++) {
204 /* Before checking if app exists, split its options */
205 wtokensplit(list
[i
], &argv
, &argc
);
206 location
= wfindfile(path
, argv
[0]);
208 /* check whether it is to be executed in a terminal */
209 if (strcmp("!", argv
[argc
- 1]) < 0)
210 printf(",\n \(\"%s\", EXEC, \"%s\")", argv
[0], list
[i
]);
212 char comm
[50], *ptr
[1];
214 strcpy(comm
, list
[i
]);
215 /* ugly hack to delete character ! from list[i] */
216 ptr
[0] = strchr(comm
,'!');
218 printf(",\n \(\"%s\", EXEC, \"xterm -e %s\")", argv
[0], comm
);
225 static inline void wmaker_config(void)
227 char *location
= wfindfile(path
, "WPrefs");
231 printf(_("Config wmaker..."));
232 printf("\", EXEC, \"WPrefs\"),\n");
236 static inline void workspaces(void)
239 printf(_("Workspaces"));
240 printf("\", WORKSPACE_MENU),\n");
243 printf(_("Workspace"));
247 printf(_("Hide others"));
248 printf("\", HIDE_OTHERS),\n");
251 printf(_("Show all"));
252 printf("\", SHOW_ALL),\n");
255 printf(_("Arrange Icons"));
256 printf("\", ARRANGE_ICONS),\n");
259 printf(_("Refresh"));
260 printf("\", REFRESH),\n");
263 printf(_("Save Session"));
264 printf("\", SAVE_SESSION),\n");
267 printf(_("Clear Session"));
268 printf("\", CLEAR_SESSION)\n");
273 static inline void lock_screen(void)
277 location
= wfindfile(path
, "xlock");
280 printf(_("Lock Screen"));
281 printf("\", EXEC, \"xlock -allowroot -usefirst -mode matrix\"),\n");
285 static void other_window_managers(char **other_wm
)
292 printf(_("Other Window Managers"));
295 for (i
= 0; i
<= MAX_WMS
; i
++) {
297 location
= wfindfile(path
, other_wm
[i
]);
299 write_first_line(count
);
300 printf(_("Start %s"), other_wm
[i
]);
301 printf("\", RESTART, \"%s\")", other_wm
[i
]);
309 static void wm_visual(void)
311 /* TODO: add more pre-defined dirs to Themes etc */
313 printf(_("Workspace Appearance"));
318 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Themes WITH setstyle\"),\n");
322 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Styles WITH setstyle\"),\n");
326 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/IconSets WITH seticons\"),\n");
329 printf(_("Background"));
330 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Backgrounds WITH wmsetbg -u -t\"),\n");
333 printf(_("Save Theme"));
334 printf("\", SHEXEC, \"getstyle -t $HOME/GNUstep/Library/WindowMaker/Themes/\\\"%%a(Theme name)\\\"\"),\n");
337 printf(_("Save Icons"));
338 printf("\", SHEXEC, \"geticonset $HOME/GNUstep/Library/WindowMaker/IconSets/\\\"%%a(IconSet name)\\\"\")\n");
343 static inline void run_command(void)
346 * %A below requires Voinov's "Add dialog history" (which
347 * is included in wmaker-crm), otherwise it should be %a
351 printf("\", SHEXEC, \"%%A(");
352 printf(_("Run, Type command:"));
356 static inline void write_first_line(int count
)
358 /* All lines inside a menu must end with a comma, except for
359 * the last one. To cope with this let's check if there is a
360 * previous entry before writing the "start of the line", and
361 * write the trailing comma if there is.