]> Dogcows Code - chaz/tint2/blob - src/config.c
big change : panel_monitor = all will draw one panel per monitor, panel_size accept...
[chaz/tint2] / src / config.c
1 /**************************************************************************
2 *
3 * Tint2 : read/write config file
4 *
5 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
6 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
20
21 #include <sys/stat.h>
22 #include <sys/time.h>
23 #include <unistd.h>
24 #include <cairo.h>
25 #include <cairo-xlib.h>
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <ctype.h>
33 #include <glib/gstdio.h>
34 #include <pango/pangocairo.h>
35 #include <Imlib2.h>
36
37 #include "common.h"
38 #include "server.h"
39 #include "task.h"
40 #include "taskbar.h"
41 #include "clock.h"
42 #include "panel.h"
43 #include "config.h"
44 #include "window.h"
45
46 // --------------------------------------------------
47 // backward compatibility
48 static int old_config_file = 0;
49 static int old_task_icon;
50 static int old_panel_background;
51 static int old_task_background;
52 static char *old_task_font = 0;
53
54 // temporary panel
55 static Panel *panel_config = 0;
56
57 // temporary list of background
58 static GSList *list_back;
59
60
61 void init_config()
62 {
63 cleanup_panel();
64
65 // get monitor and desktop config
66 get_monitors_and_desktops();
67
68 // append full transparency background
69 list_back = g_slist_append(0, calloc(1, sizeof(Area)));
70
71 panel_config = calloc(1, sizeof(Panel));
72 }
73
74
75 void cleanup_config()
76 {
77 if (old_task_font) free(old_task_font);
78 if (panel_config) free(panel_config);
79
80 // cleanup background list
81 GSList *l0;
82 for (l0 = list_back; l0 ; l0 = l0->next) {
83 free(l0->data);
84 }
85 g_slist_free(list_back);
86 list_back = NULL;
87 }
88
89
90 void copy_file(const char *pathSrc, const char *pathDest)
91 {
92 FILE *fileSrc, *fileDest;
93 char line[100];
94 int nb;
95
96 fileSrc = fopen(pathSrc, "rb");
97 if (fileSrc == NULL) return;
98
99 fileDest = fopen(pathDest, "wb");
100 if (fileDest == NULL) return;
101
102 while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest);
103
104 fclose (fileDest);
105 fclose (fileSrc);
106 }
107
108
109 void extract_values (const char *value, char **value1, char **value2, char **value3)
110 {
111 char *b=0, *c=0;
112
113 if (*value1) free (*value1);
114 if (*value2) free (*value2);
115 if (*value3) free (*value3);
116
117 if ((b = strchr (value, ' '))) {
118 b[0] = '\0';
119 b++;
120 }
121 else {
122 *value2 = 0;
123 *value3 = 0;
124 }
125 *value1 = strdup (value);
126 g_strstrip(*value1);
127
128 if (b) {
129 if ((c = strchr (b, ' '))) {
130 c[0] = '\0';
131 c++;
132 }
133 else {
134 c = 0;
135 *value3 = 0;
136 }
137 *value2 = strdup (b);
138 g_strstrip(*value2);
139 }
140
141 if (c) {
142 *value3 = strdup (c);
143 g_strstrip(*value3);
144 }
145 }
146
147
148 int hex_char_to_int (char c)
149 {
150 int r;
151
152 if (c >= '0' && c <= '9') r = c - '0';
153 else if (c >= 'a' && c <= 'f') r = c - 'a' + 10;
154 else if (c >= 'A' && c <= 'F') r = c - 'A' + 10;
155 else r = 0;
156
157 return r;
158 }
159
160
161 int hex_to_rgb (char *hex, int *r, int *g, int *b)
162 {
163 int len;
164
165 if (hex == NULL || hex[0] != '#') return (0);
166
167 len = strlen (hex);
168 if (len == 3 + 1) {
169 *r = hex_char_to_int (hex[1]);
170 *g = hex_char_to_int (hex[2]);
171 *b = hex_char_to_int (hex[3]);
172 }
173 else if (len == 6 + 1) {
174 *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]);
175 *g = hex_char_to_int (hex[3]) * 16 + hex_char_to_int (hex[4]);
176 *b = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]);
177 }
178 else if (len == 12 + 1) {
179 *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]);
180 *g = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]);
181 *b = hex_char_to_int (hex[9]) * 16 + hex_char_to_int (hex[10]);
182 }
183 else return 0;
184
185 return 1;
186 }
187
188
189 void get_color (char *hex, double *rgb)
190 {
191 int r, g, b;
192 hex_to_rgb (hex, &r, &g, &b);
193
194 rgb[0] = (r / 255.0);
195 rgb[1] = (g / 255.0);
196 rgb[2] = (b / 255.0);
197 }
198
199
200 void get_action (char *event, int *action)
201 {
202 if (strcmp (event, "none") == 0)
203 *action = NONE;
204 else if (strcmp (event, "close") == 0)
205 *action = CLOSE;
206 else if (strcmp (event, "toggle") == 0)
207 *action = TOGGLE;
208 else if (strcmp (event, "iconify") == 0)
209 *action = ICONIFY;
210 else if (strcmp (event, "shade") == 0)
211 *action = SHADE;
212 else if (strcmp (event, "toggle_iconify") == 0)
213 *action = TOGGLE_ICONIFY;
214 }
215
216
217 void add_entry (char *key, char *value)
218 {
219 char *value1=0, *value2=0, *value3=0;
220
221 /* Background and border */
222 if (strcmp (key, "rounded") == 0) {
223 // 'rounded' is the first parameter => alloc a new background
224 Area *a = calloc(1, sizeof(Area));
225 a->pix.border.rounded = atoi (value);
226 list_back = g_slist_append(list_back, a);
227 }
228 else if (strcmp (key, "border_width") == 0) {
229 Area *a = g_slist_last(list_back)->data;
230 a->pix.border.width = atoi (value);
231 }
232 else if (strcmp (key, "background_color") == 0) {
233 Area *a = g_slist_last(list_back)->data;
234 extract_values(value, &value1, &value2, &value3);
235 get_color (value1, a->pix.back.color);
236 if (value2) a->pix.back.alpha = (atoi (value2) / 100.0);
237 else a->pix.back.alpha = 0.5;
238 }
239 else if (strcmp (key, "border_color") == 0) {
240 Area *a = g_slist_last(list_back)->data;
241 extract_values(value, &value1, &value2, &value3);
242 get_color (value1, a->pix.border.color);
243 if (value2) a->pix.border.alpha = (atoi (value2) / 100.0);
244 else a->pix.border.alpha = 0.5;
245 }
246
247 /* Panel */
248 else if (strcmp (key, "panel_monitor") == 0) {
249 if (strcmp (value, "all") == 0) panel_config->monitor = -1;
250 else {
251 panel_config->monitor = atoi (value);
252 if (panel_config->monitor > 0) panel_config->monitor -= 1;
253 }
254 }
255 else if (strcmp (key, "panel_size") == 0) {
256 extract_values(value, &value1, &value2, &value3);
257
258 char *b;
259 if ((b = strchr (value1, '%'))) {
260 b[0] = '\0';
261 panel_config->pourcentx = 1;
262 }
263 panel_config->initial_width = atof(value1);
264 if (value2) {
265 if ((b = strchr (value2, '%'))) {
266 b[0] = '\0';
267 panel_config->pourcenty = 1;
268 }
269 panel_config->initial_height = atof(value2);
270 }
271 }
272 else if (strcmp (key, "panel_margin") == 0) {
273 extract_values(value, &value1, &value2, &value3);
274 panel_config->marginx = atoi (value1);
275 if (value2) panel_config->marginy = atoi (value2);
276 }
277 else if (strcmp (key, "panel_padding") == 0) {
278 extract_values(value, &value1, &value2, &value3);
279 panel_config->area.paddingxlr = panel_config->area.paddingx = atoi (value1);
280 if (value2) panel_config->area.paddingy = atoi (value2);
281 if (value3) panel_config->area.paddingx = atoi (value3);
282 }
283 else if (strcmp (key, "panel_position") == 0) {
284 extract_values(value, &value1, &value2, &value3);
285 if (strcmp (value1, "top") == 0) panel_position = TOP;
286 else panel_position = BOTTOM;
287
288 if (!value2) panel_position = CENTER;
289 else {
290 if (strcmp (value2, "left") == 0) panel_position |= LEFT;
291 else {
292 if (strcmp (value2, "right") == 0) panel_position |= RIGHT;
293 else panel_position |= CENTER;
294 }
295 }
296 }
297 else if (strcmp (key, "font_shadow") == 0)
298 panel_config->g_task.font_shadow = atoi (value);
299 else if (strcmp (key, "panel_background_id") == 0) {
300 int id = atoi (value);
301 Area *a = g_slist_nth_data(list_back, id);
302 memcpy(&panel_config->area.pix.back, &a->pix.back, sizeof(Color));
303 memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border));
304 }
305
306 /* Clock */
307 else if (strcmp (key, "time1_format") == 0) {
308 if (time1_format) g_free(time1_format);
309 if (strlen(value) > 0) time1_format = strdup (value);
310 else time1_format = 0;
311 }
312 else if (strcmp (key, "time2_format") == 0) {
313 if (time2_format) g_free(time2_format);
314 if (strlen(value) > 0) time2_format = strdup (value);
315 else time2_format = 0;
316 }
317 else if (strcmp (key, "time1_font") == 0) {
318 if (time1_font_desc) pango_font_description_free(time1_font_desc);
319 time1_font_desc = pango_font_description_from_string (value);
320 }
321 else if (strcmp (key, "time2_font") == 0) {
322 if (time2_font_desc) pango_font_description_free(time2_font_desc);
323 time2_font_desc = pango_font_description_from_string (value);
324 }
325 else if (strcmp (key, "clock_font_color") == 0) {
326 extract_values(value, &value1, &value2, &value3);
327 get_color (value1, panel_config->clock.font.color);
328 if (value2) panel_config->clock.font.alpha = (atoi (value2) / 100.0);
329 else panel_config->clock.font.alpha = 0.5;
330 }
331 else if (strcmp (key, "clock_padding") == 0) {
332 extract_values(value, &value1, &value2, &value3);
333 panel_config->clock.area.paddingxlr = panel_config->clock.area.paddingx = atoi (value1);
334 if (value2) panel_config->clock.area.paddingy = atoi (value2);
335 if (value3) panel_config->clock.area.paddingx = atoi (value3);
336 }
337 else if (strcmp (key, "clock_background_id") == 0) {
338 int id = atoi (value);
339 Area *a = g_slist_nth_data(list_back, id);
340 memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color));
341 memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border));
342 }
343
344 /* Taskbar */
345 else if (strcmp (key, "taskbar_mode") == 0) {
346 if (strcmp (value, "multi_desktop") == 0) panel_mode = MULTI_DESKTOP;
347 else if (strcmp (value, "single_desktop") == 0) panel_mode = SINGLE_DESKTOP;
348 else panel_mode = SINGLE_MONITOR;
349 }
350 else if (strcmp (key, "taskbar_padding") == 0) {
351 extract_values(value, &value1, &value2, &value3);
352 panel_config->g_taskbar.paddingxlr = panel_config->g_taskbar.paddingx = atoi (value1);
353 if (value2) panel_config->g_taskbar.paddingy = atoi (value2);
354 if (value3) panel_config->g_taskbar.paddingx = atoi (value3);
355 }
356 else if (strcmp (key, "taskbar_background_id") == 0) {
357 int id = atoi (value);
358 Area *a = g_slist_nth_data(list_back, id);
359 memcpy(&panel_config->g_taskbar.pix.back, &a->pix.back, sizeof(Color));
360 memcpy(&panel_config->g_taskbar.pix.border, &a->pix.border, sizeof(Border));
361 }
362
363 /* Task */
364 else if (strcmp (key, "task_text") == 0)
365 panel_config->g_task.text = atoi (value);
366 else if (strcmp (key, "task_icon") == 0)
367 panel_config->g_task.icon = atoi (value);
368 else if (strcmp (key, "task_centered") == 0)
369 panel_config->g_task.centered = atoi (value);
370 else if (strcmp (key, "task_width") == 0)
371 panel_config->g_task.maximum_width = atoi (value);
372 else if (strcmp (key, "task_padding") == 0) {
373 extract_values(value, &value1, &value2, &value3);
374 panel_config->g_task.area.paddingxlr = panel_config->g_task.area.paddingx = atoi (value1);
375 if (value2) panel_config->g_task.area.paddingy = atoi (value2);
376 if (value3) panel_config->g_task.area.paddingx = atoi (value3);
377 }
378 else if (strcmp (key, "task_font") == 0) {
379 if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc);
380 panel_config->g_task.font_desc = pango_font_description_from_string (value);
381 }
382 else if (strcmp (key, "task_font_color") == 0) {
383 extract_values(value, &value1, &value2, &value3);
384 get_color (value1, panel_config->g_task.font.color);
385 if (value2) panel_config->g_task.font.alpha = (atoi (value2) / 100.0);
386 else panel_config->g_task.font.alpha = 0.1;
387 }
388 else if (strcmp (key, "task_active_font_color") == 0) {
389 extract_values(value, &value1, &value2, &value3);
390 get_color (value1, panel_config->g_task.font_active.color);
391 if (value2) panel_config->g_task.font_active.alpha = (atoi (value2) / 100.0);
392 else panel_config->g_task.font_active.alpha = 0.1;
393 }
394 else if (strcmp (key, "task_background_id") == 0) {
395 int id = atoi (value);
396 Area *a = g_slist_nth_data(list_back, id);
397 memcpy(&panel_config->g_task.area.pix.back, &a->pix.back, sizeof(Color));
398 memcpy(&panel_config->g_task.area.pix.border, &a->pix.border, sizeof(Border));
399 }
400 else if (strcmp (key, "task_active_background_id") == 0) {
401 int id = atoi (value);
402 Area *a = g_slist_nth_data(list_back, id);
403 memcpy(&panel_config->g_task.area.pix_active.back, &a->pix.back, sizeof(Color));
404 memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border));
405 }
406
407 /* Mouse actions */
408 else if (strcmp (key, "mouse_middle") == 0)
409 get_action (value, &mouse_middle);
410 else if (strcmp (key, "mouse_right") == 0)
411 get_action (value, &mouse_right);
412 else if (strcmp (key, "mouse_scroll_up") == 0)
413 get_action (value, &mouse_scroll_up);
414 else if (strcmp (key, "mouse_scroll_down") == 0)
415 get_action (value, &mouse_scroll_down);
416
417
418 /* Read old config for backward compatibility */
419 else if (strcmp (key, "font") == 0) {
420 old_config_file = 1;
421 if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc);
422 panel_config->g_task.font_desc = pango_font_description_from_string (value);
423 if (old_task_font) free(old_task_font);
424 old_task_font = strdup (value);
425 }
426 else if (strcmp (key, "font_color") == 0)
427 get_color (value, panel_config->g_task.font.color);
428 else if (strcmp (key, "font_alpha") == 0)
429 panel_config->g_task.font.alpha = (atoi (value) / 100.0);
430 else if (strcmp (key, "font_active_color") == 0)
431 get_color (value, panel_config->g_task.font_active.color);
432 else if (strcmp (key, "font_active_alpha") == 0)
433 panel_config->g_task.font_active.alpha = (atoi (value) / 100.0);
434 else if (strcmp (key, "panel_show_all_desktop") == 0) {
435 if (atoi (value) == 0) panel_mode = SINGLE_DESKTOP;
436 else panel_mode = MULTI_DESKTOP;
437 }
438 else if (strcmp (key, "panel_width") == 0)
439 panel_config->area.width = atoi (value);
440 else if (strcmp (key, "panel_height") == 0)
441 panel_config->area.height = atoi (value);
442 else if (strcmp (key, "panel_background") == 0)
443 old_panel_background = atoi (value);
444 else if (strcmp (key, "panel_background_alpha") == 0)
445 panel_config->area.pix.back.alpha = (atoi (value) / 100.0);
446 else if (strcmp (key, "panel_border_alpha") == 0)
447 panel_config->area.pix.border.alpha = (atoi (value) / 100.0);
448 else if (strcmp (key, "task_icon") == 0)
449 old_task_icon = atoi (value);
450 else if (strcmp (key, "task_background") == 0)
451 old_task_background = atoi (value);
452 else if (strcmp (key, "task_background_alpha") == 0)
453 panel_config->g_task.area.pix.back.alpha = (atoi (value) / 100.0);
454 else if (strcmp (key, "task_active_background_alpha") == 0)
455 panel_config->g_task.area.pix_active.back.alpha = (atoi (value) / 100.0);
456 else if (strcmp (key, "task_border_alpha") == 0)
457 panel_config->g_task.area.pix.border.alpha = (atoi (value) / 100.0);
458 else if (strcmp (key, "task_active_border_alpha") == 0)
459 panel_config->g_task.area.pix_active.border.alpha = (atoi (value) / 100.0);
460 // disabled parameters
461 else if (strcmp (key, "task_active_border_width") == 0) ;
462 else if (strcmp (key, "task_active_rounded") == 0) ;
463
464 else
465 fprintf(stderr, "Invalid option: \"%s\", correct your config file\n", key);
466
467 if (value1) free (value1);
468 if (value2) free (value2);
469 if (value3) free (value3);
470 }
471
472
473 int parse_line (const char *line)
474 {
475 char *a, *b, *key, *value;
476
477 /* Skip useless lines */
478 if ((line[0] == '#') || (line[0] == '\n')) return 0;
479 if (!(a = strchr (line, '='))) return 0;
480
481 /* overwrite '=' with '\0' */
482 a[0] = '\0';
483 key = strdup (line);
484 a++;
485
486 /* overwrite '\n' with '\0' if '\n' present */
487 if ((b = strchr (a, '\n'))) b[0] = '\0';
488
489 value = strdup (a);
490
491 g_strstrip(key);
492 g_strstrip(value);
493
494 add_entry (key, value);
495
496 free (key);
497 free (value);
498 return 1;
499 }
500
501
502 void config_finish ()
503 {
504 if (old_config_file) save_config();
505
506 if (panel_config->monitor > (server.nb_monitor-1)) {
507 fprintf(stderr, "tint2 exit : monitor %d not found.\n", panel_config->monitor+1);
508 exit(0);
509 }
510 else {
511 if (!server.monitor[panel_config->monitor].width || !server.monitor[panel_config->monitor].height)
512 fprintf(stderr, "tint2 error : invalid monitor size.\n");
513 }
514
515 // alloc panels
516 int i;
517 if (panel_config->monitor >= 0) {
518 nb_panel = 1;
519 panel1 = calloc(nb_panel, sizeof(Panel));
520 memcpy(panel1, panel_config, sizeof(Panel));
521 }
522 else {
523 // multi monitor
524 nb_panel = server.nb_monitor;
525 panel1 = calloc(nb_panel, sizeof(Panel));
526
527 for (i=0 ; i < nb_panel ; i++) {
528 memcpy(&panel1[i], panel_config, sizeof(Panel));
529 panel1[i].monitor = i;
530 }
531 }
532
533 init_panel();
534 init_taskbar();
535 visible_object();
536
537 task_refresh_tasklist();
538 panel_refresh = 1;
539 // XFlush (server.dsp);
540
541 cleanup_config();
542 }
543
544
545 int config_read ()
546 {
547 const gchar * const * system_dirs;
548 char *path1, *path2, *dir;
549 gint i;
550
551 // check tint2rc file according to XDG specification
552 path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
553 if (!g_file_test (path1, G_FILE_TEST_EXISTS)) {
554
555 path2 = 0;
556 system_dirs = g_get_system_config_dirs();
557 for (i = 0; system_dirs[i]; i++) {
558 path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL);
559
560 if (g_file_test(path2, G_FILE_TEST_EXISTS)) break;
561 g_free (path2);
562 path2 = 0;
563 }
564
565 if (path2) {
566 // copy file in user directory (path1)
567 dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
568 if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777);
569 g_free(dir);
570
571 copy_file(path2, path1);
572 g_free(path2);
573 }
574 }
575
576 i = config_read_file (path1);
577 g_free(path1);
578 return i;
579 }
580
581
582 int config_read_file (const char *path)
583 {
584 FILE *fp;
585 char line[80];
586
587 if ((fp = fopen(path, "r")) == NULL) return 0;
588
589 while (fgets(line, sizeof(line), fp) != NULL)
590 parse_line (line);
591
592 fclose (fp);
593 return 1;
594 }
595
596
597 void save_config ()
598 {
599 /*
600 fprintf(stderr, "tint2 warning : convert user's config file\n");
601 panel.area.paddingx = panel.area.paddingy = panel.marginx;
602 panel.marginx = panel.marginy = 0;
603
604 if (old_task_icon == 0) g_task.icon_size1 = 0;
605 if (old_panel_background == 0) panel.area.pix.back.alpha = 0;
606 if (old_task_background == 0) {
607 g_task.area.pix.back.alpha = 0;
608 g_task.area.pix_active.back.alpha = 0;
609 }
610 g_task.area.pix.border.rounded = g_task.area.pix.border.rounded / 2;
611 g_task.area.pix_active.border.rounded = g_task.area.pix.border.rounded;
612 panel.area.pix.border.rounded = panel.area.pix.border.rounded / 2;
613
614 char *path;
615 FILE *fp;
616
617 path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
618 fp = fopen(path, "w");
619 g_free(path);
620 if (fp == NULL) return;
621
622 fputs("#---------------------------------------------\n", fp);
623 fputs("# TINT CONFIG FILE\n", fp);
624 fputs("#---------------------------------------------\n\n", fp);
625 fputs("#---------------------------------------------\n", fp);
626 fputs("# PANEL\n", fp);
627 fputs("#---------------------------------------------\n", fp);
628 if (panel_mode == SINGLE_DESKTOP) fputs("panel_mode = single_desktop\n", fp);
629 else fputs("panel_mode = multi_desktop\n", fp);
630 fputs("panel_monitor = 1\n", fp);
631 if (panel_position & BOTTOM) fputs("panel_position = bottom", fp);
632 else fputs("panel_position = top", fp);
633 if (panel_position & LEFT) fputs(" left\n", fp);
634 else if (panel_position & RIGHT) fputs(" right\n", fp);
635 else fputs(" center\n", fp);
636 fprintf(fp, "panel_size = %d %d\n", panel.area.width, panel.area.height);
637 fprintf(fp, "panel_margin = %d %d\n", panel.marginx, panel.marginy);
638 fprintf(fp, "panel_padding = %d %d\n", panel.area.paddingx, panel.area.paddingy);
639 fprintf(fp, "font_shadow = %d\n", g_task.font_shadow);
640
641 fputs("\n#---------------------------------------------\n", fp);
642 fputs("# PANEL BACKGROUND AND BORDER\n", fp);
643 fputs("#---------------------------------------------\n", fp);
644 fprintf(fp, "panel_rounded = %d\n", panel.area.pix.border.rounded);
645 fprintf(fp, "panel_border_width = %d\n", panel.area.pix.border.width);
646 fprintf(fp, "panel_background_color = #%02x%02x%02x %d\n", (int)(panel.area.pix.back.color[0]*255), (int)(panel.area.pix.back.color[1]*255), (int)(panel.area.pix.back.color[2]*255), (int)(panel.area.pix.back.alpha*100));
647 fprintf(fp, "panel_border_color = #%02x%02x%02x %d\n", (int)(panel.area.pix.border.color[0]*255), (int)(panel.area.pix.border.color[1]*255), (int)(panel.area.pix.border.color[2]*255), (int)(panel.area.pix.border.alpha*100));
648
649 fputs("\n#---------------------------------------------\n", fp);
650 fputs("# TASKS\n", fp);
651 fputs("#---------------------------------------------\n", fp);
652 fprintf(fp, "task_centered = %d\n", g_task.centered);
653 fprintf(fp, "task_width = %d\n", g_task.maximum_width);
654 fprintf(fp, "task_padding = %d\n", g_task.area.paddingx);
655 fprintf(fp, "task_icon = %d\n", g_task.icon);
656 fprintf(fp, "task_font = %s\n", old_task_font);
657 fprintf(fp, "task_font_color = #%02x%02x%02x %d\n", (int)(g_task.font.color[0]*255), (int)(g_task.font.color[1]*255), (int)(g_task.font.color[2]*255), (int)(g_task.font.alpha*100));
658 fprintf(fp, "task_active_font_color = #%02x%02x%02x %d\n", (int)(g_task.font_active.color[0]*255), (int)(g_task.font_active.color[1]*255), (int)(g_task.font_active.color[2]*255), (int)(g_task.font_active.alpha*100));
659
660 fputs("\n#---------------------------------------------\n", fp);
661 fputs("# TASK BACKGROUND AND BORDER\n", fp);
662 fputs("#---------------------------------------------\n", fp);
663 fprintf(fp, "task_rounded = %d\n", g_task.area.pix.border.rounded);
664 fprintf(fp, "task_background_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix.back.color[0]*255), (int)(g_task.area.pix.back.color[1]*255), (int)(g_task.area.pix.back.color[2]*255), (int)(g_task.area.pix.back.alpha*100));
665 fprintf(fp, "task_active_background_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix_active.back.color[0]*255), (int)(g_task.area.pix_active.back.color[1]*255), (int)(g_task.area.pix_active.back.color[2]*255), (int)(g_task.area.pix_active.back.alpha*100));
666 fprintf(fp, "task_border_width = %d\n", g_task.area.pix.border.width);
667 fprintf(fp, "task_border_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix.border.color[0]*255), (int)(g_task.area.pix.border.color[1]*255), (int)(g_task.area.pix.border.color[2]*255), (int)(g_task.area.pix.border.alpha*100));
668 fprintf(fp, "task_active_border_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix_active.border.color[0]*255), (int)(g_task.area.pix_active.border.color[1]*255), (int)(g_task.area.pix_active.border.color[2]*255), (int)(g_task.area.pix_active.border.alpha*100));
669
670 fputs("\n#---------------------------------------------\n", fp);
671 fputs("# CLOCK\n", fp);
672 fputs("#---------------------------------------------\n", fp);
673 fputs("#time1_format = %H:%M\n", fp);
674 fputs("time1_font = sans bold 8\n", fp);
675 fputs("#time2_format = %A %d %B\n", fp);
676 fputs("time2_font = sans 6\n", fp);
677 fputs("clock_font_color = #ffffff 75\n", fp);
678
679 fputs("\n#---------------------------------------------\n", fp);
680 fputs("# MOUSE ACTION ON TASK\n", fp);
681 fputs("#---------------------------------------------\n", fp);
682 if (mouse_middle == NONE) fputs("mouse_middle = none\n", fp);
683 else if (mouse_middle == CLOSE) fputs("mouse_middle = close\n", fp);
684 else if (mouse_middle == TOGGLE) fputs("mouse_middle = toggle\n", fp);
685 else if (mouse_middle == ICONIFY) fputs("mouse_middle = iconify\n", fp);
686 else if (mouse_middle == SHADE) fputs("mouse_middle = shade\n", fp);
687 else fputs("mouse_middle = toggle_iconify\n", fp);
688
689 if (mouse_right == NONE) fputs("mouse_right = none\n", fp);
690 else if (mouse_right == CLOSE) fputs("mouse_right = close\n", fp);
691 else if (mouse_right == TOGGLE) fputs("mouse_right = toggle\n", fp);
692 else if (mouse_right == ICONIFY) fputs("mouse_right = iconify\n", fp);
693 else if (mouse_right == SHADE) fputs("mouse_right = shade\n", fp);
694 else fputs("mouse_right = toggle_iconify\n", fp);
695
696 if (mouse_scroll_up == NONE) fputs("mouse_scroll_up = none\n", fp);
697 else if (mouse_scroll_up == CLOSE) fputs("mouse_scroll_up = close\n", fp);
698 else if (mouse_scroll_up == TOGGLE) fputs("mouse_scroll_up = toggle\n", fp);
699 else if (mouse_scroll_up == ICONIFY) fputs("mouse_scroll_up = iconify\n", fp);
700 else if (mouse_scroll_up == SHADE) fputs("mouse_scroll_up = shade\n", fp);
701 else fputs("mouse_scroll_up = toggle_iconify\n", fp);
702
703 if (mouse_scroll_down == NONE) fputs("mouse_scroll_down = none\n", fp);
704 else if (mouse_scroll_down == CLOSE) fputs("mouse_scroll_down = close\n", fp);
705 else if (mouse_scroll_down == TOGGLE) fputs("mouse_scroll_down = toggle\n", fp);
706 else if (mouse_scroll_down == ICONIFY) fputs("mouse_scroll_down = iconify\n", fp);
707 else if (mouse_scroll_down == SHADE) fputs("mouse_scroll_down = shade\n", fp);
708 else fputs("mouse_scroll_down = toggle_iconify\n", fp);
709
710 fputs("\n\n", fp);
711 fclose (fp);
712 */
713 old_config_file = 0;
714 }
715
This page took 0.072418 seconds and 5 git commands to generate.