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[])
33 path = getenv("PATH");
34 locale = getenv("LANG");
35 setlocale(LC_ALL, "");
37 if (getenv("NLSPATH"))
38 bindtextdomain("wmgenmenu", getenv("NLSPATH"));
40 bindtextdomain("wmgenmenu", LOCALEDIR);
42 bind_textdomain_codeset("wmgenmenu", "UTF-8");
43 textdomain("wmgenmenu");
45 printf("\(\"Window Maker\",\n");
48 printf(_("Applications"));
51 /* This "first" printf is different from the others! */
53 printf(_("Terminals"));
55 find_and_write(terminals);
57 printf("\n ),\n \(\"");
58 printf(_("Internet"));
60 find_and_write(internet);
62 printf("\n ),\n \(\"");
65 find_and_write(email);
67 printf("\n ),\n \(\"");
68 printf(_("Mathematics"));
70 find_and_write(Mathematiks);
72 printf("\n ),\n \(\"");
73 printf(_("File Managers"));
75 find_and_write(file_managers);
77 printf("\n ),\n \(\"");
78 printf(_("Graphics"));
80 find_and_write(Graphics);
82 printf("\n ),\n \(\"");
83 printf(_("Multimedia"));
85 find_and_write(Multimedia);
87 printf("\n ),\n \(\"");
90 find_and_write(Editors);
92 printf("\n ),\n \(\"");
93 printf(_("Development"));
95 find_and_write(development);
97 printf("\n ),\n \(\"");
98 printf(_("Window Maker"));
100 find_and_write(WindowMaker);
102 printf("\n ),\n \(\"");
105 find_and_write(Office);
107 printf("\n ),\n \(\"");
108 printf(_("Astronomy"));
110 find_and_write(Astronomie);
112 printf("\n ),\n \(\"");
115 find_and_write(Sound);
117 printf("\n ),\n \(\"");
120 find_and_write(Comics);
122 printf("\n ),\n \(\"");
123 printf(_("Viewers"));
125 find_and_write(Viewers);
127 printf("\n ),\n \(\"");
128 printf(_("Utilities"));
130 find_and_write(Utilities);
132 printf("\n ),\n \(\"");
135 find_and_write(System);
137 printf("\n ),\n \(\"");
140 find_and_write(Video);
142 printf("\n ),\n \(\"");
143 printf(_("Chat and Talk"));
145 find_and_write(Chat);
147 printf("\n ),\n \(\"");
148 printf(_("P2P-Network"));
152 printf("\n ),\n \(\"");
155 find_and_write(Games);
157 printf("\n ),\n \(\"");
158 printf(_("OpenSUSE"));
160 find_and_write(OpenSUSE);
162 printf("\n ),\n \(\"");
163 printf(_("Mandriva"));
165 find_and_write(Mandriva);
167 /* This must be after the last entry */
177 printf(_("Info Panel"));
178 printf("\", INFO_PANEL),\n");
181 printf(_("Restart"));
182 printf("\", RESTART),\n");
184 other_window_managers(other_wm);
188 printf(_("Exit..."));
189 printf("\", EXIT)\n");
191 /* Final closing parenthesis */
197 static void find_and_write(char **list)
200 char *location, **argv;
203 for (i = 0; i <= MAX_NR_APPS; i++) {
205 /* Before checking if app exists, split its options */
206 wtokensplit(list[i], &argv, &argc);
207 location = wfindfile(path, argv[0]);
209 /* check whether it is to be executed in a terminal */
210 if (strcmp("!", argv[argc - 1]) < 0)
211 printf(",\n \(\"%s\", EXEC, \"%s\")", argv[0], list[i]);
213 char comm[50], *ptr[1];
215 strcpy(comm, list[i]);
216 /* ugly hack to delete character ! from list[i] */
217 ptr[0] = strchr(comm,'!');
219 printf(",\n \(\"%s\", EXEC, \"xterm -e %s\")", argv[0], comm);
226 static inline void wmaker_config(void)
228 char *location = wfindfile(path, "WPrefs");
232 printf(_("Config wmaker..."));
233 printf("\", EXEC, \"WPrefs\"),\n");
237 static inline void workspaces(void)
240 printf(_("Workspaces"));
241 printf("\", WORKSPACE_MENU),\n");
244 printf(_("Workspace"));
248 printf(_("Hide others"));
249 printf("\", HIDE_OTHERS),\n");
252 printf(_("Show all"));
253 printf("\", SHOW_ALL),\n");
256 printf(_("Arrange Icons"));
257 printf("\", ARRANGE_ICONS),\n");
260 printf(_("Refresh"));
261 printf("\", REFRESH),\n");
264 printf(_("Save Session"));
265 printf("\", SAVE_SESSION),\n");
268 printf(_("Clear Session"));
269 printf("\", CLEAR_SESSION)\n");
274 static inline void lock_screen(void)
278 location = wfindfile(path, "xlock");
281 printf(_("Lock Screen"));
282 printf("\", EXEC, \"xlock -allowroot -usefirst -mode matrix\"),\n");
286 static void other_window_managers(char **other_wm)
293 printf(_("Other Window Managers"));
296 for (i = 0; i <= MAX_WMS; i++) {
298 location = wfindfile(path, other_wm[i]);
300 write_first_line(count);
301 printf(_("Start %s"), other_wm[i]);
302 printf("\", RESTART, \"%s\")", other_wm[i]);
310 static void wm_visual(void)
312 /* TODO: add more pre-defined dirs to Themes etc */
314 printf(_("Workspace Appearance"));
319 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Themes WITH setstyle\"),\n");
323 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Styles WITH setstyle\"),\n");
327 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/IconSets WITH seticons\"),\n");
330 printf(_("Background"));
331 printf("\", OPEN_MENU, \"-noext $HOME/GNUstep/Library/WindowMaker/Backgrounds WITH wmsetbg -u -t\"),\n");
334 printf(_("Save Theme"));
335 printf("\", SHEXEC, \"getstyle -t $HOME/GNUstep/Library/WindowMaker/Themes/\\\"%%a(Theme name)\\\"\"),\n");
338 printf(_("Save Icons"));
339 printf("\", SHEXEC, \"geticonset $HOME/GNUstep/Library/WindowMaker/IconSets/\\\"%%a(IconSet name)\\\"\")\n");
344 static inline void run_command(void)
347 * %A below requires Voinov's "Add dialog history" (which
348 * is included in wmaker-crm), otherwise it should be %a
352 printf("\", SHEXEC, \"%%A(");
353 printf(_("Run, Type command:"));
357 static inline void write_first_line(int count)
359 /* All lines inside a menu must end with a comma, except for
360 * the last one. To cope with this let's check if there is a
361 * previous entry before writing the "start of the line", and
362 * write the trailing comma if there is.