1 /**************************************************************************
3 * Tint2 : read/write config file
5 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
6 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
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.
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 **************************************************************************/
25 #include <cairo-xlib.h>
27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
33 #include <glib/gstdio.h>
34 #include <pango/pangocairo.h>
35 #include <pango/pangoxft.h>
43 #include "systraybar.h"
59 // --------------------------------------------------
60 // backward compatibility
61 // detect if it's an old config file (==1)
62 static int old_config_file
;
74 if (config_path
) g_free(config_path
);
75 if (snapshot_path
) g_free(snapshot_path
);
79 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
83 if (*value1
) free (*value1
);
84 if (*value2
) free (*value2
);
85 if (*value3
) free (*value3
);
87 if ((b
= strchr (value
, ' '))) {
95 *value1
= strdup (value
);
99 if ((c
= strchr (b
, ' '))) {
107 *value2
= strdup (b
);
112 *value3
= strdup (c
);
118 void get_action (char *event
, int *action
)
120 if (strcmp (event
, "none") == 0)
122 else if (strcmp (event
, "close") == 0)
124 else if (strcmp (event
, "toggle") == 0)
126 else if (strcmp (event
, "iconify") == 0)
128 else if (strcmp (event
, "shade") == 0)
130 else if (strcmp (event
, "toggle_iconify") == 0)
131 *action
= TOGGLE_ICONIFY
;
132 else if (strcmp (event
, "maximize_restore") == 0)
133 *action
= MAXIMIZE_RESTORE
;
134 else if (strcmp (event
, "desktop_left") == 0)
135 *action
= DESKTOP_LEFT
;
136 else if (strcmp (event
, "desktop_right") == 0)
137 *action
= DESKTOP_RIGHT
;
138 else if (strcmp (event
, "next_task") == 0)
140 else if (strcmp (event
, "prev_task") == 0)
145 int get_task_status(char* status
)
147 if (strcmp(status
, "active") == 0)
149 if (strcmp(status
, "iconified") == 0)
150 return TASK_ICONIFIED
;
151 if (strcmp(status
, "urgent") == 0)
157 int config_get_monitor(char* monitor
)
159 if (strcmp(monitor
, "all") != 0) {
161 int ret_int
= strtol(monitor
, &endptr
, 10);
165 // monitor specified by name, not by index
167 for (i
=0; i
<server
.nb_monitor
; ++i
) {
168 if (server
.monitor
[i
].names
== 0)
169 // xrandr can't identify monitors
172 while (server
.monitor
[i
].names
[j
] != 0) {
173 if (strcmp(monitor
, server
.monitor
[i
].names
[j
++]) == 0)
179 // monitor == "all" or monitor not found or xrandr can't identify monitors
183 void add_entry (char *key
, char *value
)
185 char *value1
=0, *value2
=0, *value3
=0;
187 /* Background and border */
188 if (strcmp (key
, "rounded") == 0) {
189 // 'rounded' is the first parameter => alloc a new background
191 bg
.border
.rounded
= atoi(value
);
192 g_array_append_val(backgrounds
, bg
);
194 else if (strcmp (key
, "border_width") == 0) {
195 g_array_index(backgrounds
, Background
, backgrounds
->len
-1).border
.width
= atoi(value
);
197 else if (strcmp (key
, "background_color") == 0) {
198 Background
* bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
199 extract_values(value
, &value1
, &value2
, &value3
);
200 get_color (value1
, bg
->back
.color
);
201 if (value2
) bg
->back
.alpha
= (atoi (value2
) / 100.0);
202 else bg
->back
.alpha
= 0.5;
204 else if (strcmp (key
, "border_color") == 0) {
205 Background
* bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
206 extract_values(value
, &value1
, &value2
, &value3
);
207 get_color (value1
, bg
->border
.color
);
208 if (value2
) bg
->border
.alpha
= (atoi (value2
) / 100.0);
209 else bg
->border
.alpha
= 0.5;
213 else if (strcmp (key
, "panel_monitor") == 0) {
214 panel_config
.monitor
= config_get_monitor(value
);
216 else if (strcmp (key
, "panel_size") == 0) {
217 extract_values(value
, &value1
, &value2
, &value3
);
220 if ((b
= strchr (value1
, '%'))) {
222 panel_config
.pourcentx
= 1;
224 panel_config
.area
.width
= atoi(value1
);
225 if (panel_config
.area
.width
== 0) {
227 panel_config
.area
.width
= 100;
228 panel_config
.pourcentx
= 1;
231 if ((b
= strchr (value2
, '%'))) {
233 panel_config
.pourcenty
= 1;
235 panel_config
.area
.height
= atoi(value2
);
238 else if (strcmp (key
, "panel_items") == 0) {
239 if (panel_items_order
) g_free(panel_items_order
);
240 panel_items_order
= strdup(value
);
242 for (j
=0 ; j
< strlen(panel_items_order
) ; j
++) {
243 if (panel_items_order
[j
] == 'L')
244 launcher_enabled
= 1;
245 //if (panel_items_order[j] == 'T')
246 if (panel_items_order
[j
] == 'B') {
247 #ifdef ENABLE_BATTERY
250 fprintf(stderr
, "tint2 is build without battery support\n");
253 if (panel_items_order
[j
] == 'S') {
254 // systray disabled in snapshot mode
255 if (snapshot_path
== 0)
258 if (panel_items_order
[j
] == 'C')
262 else if (strcmp (key
, "panel_margin") == 0) {
263 extract_values(value
, &value1
, &value2
, &value3
);
264 panel_config
.marginx
= atoi (value1
);
265 if (value2
) panel_config
.marginy
= atoi (value2
);
267 else if (strcmp (key
, "panel_padding") == 0) {
268 extract_values(value
, &value1
, &value2
, &value3
);
269 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
270 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
271 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
273 else if (strcmp (key
, "panel_position") == 0) {
274 extract_values(value
, &value1
, &value2
, &value3
);
275 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
277 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
278 else panel_position
= CENTER
;
281 if (!value2
) panel_position
|= CENTER
;
283 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
285 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
286 else panel_position
|= CENTER
;
289 if (!value3
) panel_horizontal
= 1;
291 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
292 else panel_horizontal
= 1;
295 else if (strcmp (key
, "font_shadow") == 0)
296 panel_config
.g_task
.font_shadow
= atoi (value
);
297 else if (strcmp (key
, "panel_background_id") == 0) {
298 int id
= atoi (value
);
299 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
300 panel_config
.area
.bg
= &g_array_index(backgrounds
, Background
, id
);
302 else if (strcmp (key
, "wm_menu") == 0)
303 wm_menu
= atoi (value
);
304 else if (strcmp (key
, "panel_dock") == 0)
305 panel_dock
= atoi (value
);
306 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
307 max_tick_urgent
= atoi (value
);
308 else if (strcmp (key
, "panel_layer") == 0) {
309 if (strcmp(value
, "bottom") == 0)
310 panel_layer
= BOTTOM_LAYER
;
311 else if (strcmp(value
, "top") == 0)
312 panel_layer
= TOP_LAYER
;
314 panel_layer
= NORMAL_LAYER
;
318 else if (strcmp (key
, "battery_low_status") == 0) {
319 #ifdef ENABLE_BATTERY
320 battery_low_status
= atoi(value
);
321 if(battery_low_status
< 0 || battery_low_status
> 100)
322 battery_low_status
= 0;
325 else if (strcmp (key
, "battery_low_cmd") == 0) {
326 #ifdef ENABLE_BATTERY
327 if (strlen(value
) > 0)
328 battery_low_cmd
= strdup (value
);
331 else if (strcmp (key
, "bat1_font") == 0) {
332 #ifdef ENABLE_BATTERY
333 bat1_font_desc
= pango_font_description_from_string (value
);
336 else if (strcmp (key
, "bat2_font") == 0) {
337 #ifdef ENABLE_BATTERY
338 bat2_font_desc
= pango_font_description_from_string (value
);
341 else if (strcmp (key
, "battery_font_color") == 0) {
342 #ifdef ENABLE_BATTERY
343 extract_values(value
, &value1
, &value2
, &value3
);
344 get_color (value1
, panel_config
.battery
.font
.color
);
345 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
346 else panel_config
.battery
.font
.alpha
= 0.5;
349 else if (strcmp (key
, "battery_padding") == 0) {
350 #ifdef ENABLE_BATTERY
351 extract_values(value
, &value1
, &value2
, &value3
);
352 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
353 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
354 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
357 else if (strcmp (key
, "battery_background_id") == 0) {
358 #ifdef ENABLE_BATTERY
359 int id
= atoi (value
);
360 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
361 panel_config
.battery
.area
.bg
= &g_array_index(backgrounds
, Background
, id
);
364 else if (strcmp (key
, "battery_hide") == 0) {
365 #ifdef ENABLE_BATTERY
366 percentage_hide
= atoi (value
);
367 if (percentage_hide
== 0)
368 percentage_hide
= 101;
373 else if (strcmp (key
, "time1_format") == 0) {
374 if (strlen(value
) > 0) {
375 time1_format
= strdup (value
);
379 else if (strcmp (key
, "time2_format") == 0) {
380 if (strlen(value
) > 0)
381 time2_format
= strdup (value
);
383 else if (strcmp (key
, "time1_font") == 0) {
384 time1_font_desc
= pango_font_description_from_string (value
);
386 else if (strcmp(key
, "time1_timezone") == 0) {
387 if (strlen(value
) > 0)
388 time1_timezone
= strdup(value
);
390 else if (strcmp(key
, "time2_timezone") == 0) {
391 if (strlen(value
) > 0)
392 time2_timezone
= strdup(value
);
394 else if (strcmp (key
, "time2_font") == 0) {
395 time2_font_desc
= pango_font_description_from_string (value
);
397 else if (strcmp (key
, "clock_font_color") == 0) {
398 extract_values(value
, &value1
, &value2
, &value3
);
399 get_color (value1
, panel_config
.clock
.font
.color
);
400 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
401 else panel_config
.clock
.font
.alpha
= 0.5;
403 else if (strcmp (key
, "clock_padding") == 0) {
404 extract_values(value
, &value1
, &value2
, &value3
);
405 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
406 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
407 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
409 else if (strcmp (key
, "clock_background_id") == 0) {
410 int id
= atoi (value
);
411 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
412 panel_config
.clock
.area
.bg
= &g_array_index(backgrounds
, Background
, id
);
414 else if (strcmp(key
, "clock_tooltip") == 0) {
415 if (strlen(value
) > 0)
416 time_tooltip_format
= strdup (value
);
418 else if (strcmp(key
, "clock_tooltip_timezone") == 0) {
419 if (strlen(value
) > 0)
420 time_tooltip_timezone
= strdup(value
);
422 else if (strcmp(key
, "clock_lclick_command") == 0) {
423 if (strlen(value
) > 0)
424 clock_lclick_command
= strdup(value
);
426 else if (strcmp(key
, "clock_rclick_command") == 0) {
427 if (strlen(value
) > 0)
428 clock_rclick_command
= strdup(value
);
432 else if (strcmp (key
, "taskbar_mode") == 0) {
433 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
434 else panel_mode
= SINGLE_DESKTOP
;
436 else if (strcmp (key
, "taskbar_padding") == 0) {
437 extract_values(value
, &value1
, &value2
, &value3
);
438 panel_config
.g_taskbar
.area
.paddingxlr
= panel_config
.g_taskbar
.area
.paddingx
= atoi (value1
);
439 if (value2
) panel_config
.g_taskbar
.area
.paddingy
= atoi (value2
);
440 if (value3
) panel_config
.g_taskbar
.area
.paddingx
= atoi (value3
);
442 else if (strcmp (key
, "taskbar_background_id") == 0) {
443 int id
= atoi (value
);
444 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
445 panel_config
.g_taskbar
.bg
= &g_array_index(backgrounds
, Background
, id
);
446 panel_config
.g_taskbar
.area
.bg
= panel_config
.g_taskbar
.bg
;
448 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
449 int id
= atoi (value
);
450 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
451 panel_config
.g_taskbar
.bg_active
= &g_array_index(backgrounds
, Background
, id
);
452 panel_config
.g_taskbar
.use_active
= 1;
456 else if (strcmp (key
, "task_text") == 0)
457 panel_config
.g_task
.text
= atoi (value
);
458 else if (strcmp (key
, "task_icon") == 0)
459 panel_config
.g_task
.icon
= atoi (value
);
460 else if (strcmp (key
, "task_centered") == 0)
461 panel_config
.g_task
.centered
= atoi (value
);
462 else if (strcmp (key
, "task_width") == 0) {
463 // old parameter : just for backward compatibility
464 panel_config
.g_task
.maximum_width
= atoi (value
);
465 panel_config
.g_task
.maximum_height
= 30;
467 else if (strcmp (key
, "task_maximum_size") == 0) {
468 extract_values(value
, &value1
, &value2
, &value3
);
469 panel_config
.g_task
.maximum_width
= atoi (value1
);
470 panel_config
.g_task
.maximum_height
= 30;
472 panel_config
.g_task
.maximum_height
= atoi (value2
);
474 else if (strcmp (key
, "task_padding") == 0) {
475 extract_values(value
, &value1
, &value2
, &value3
);
476 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
477 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
478 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
480 else if (strcmp (key
, "task_font") == 0) {
481 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
483 else if (g_regex_match_simple("task.*_font_color", key
, 0, 0)) {
484 gchar
** split
= g_regex_split_simple("_", key
, 0, 0);
485 int status
= get_task_status(split
[1]);
487 extract_values(value
, &value1
, &value2
, &value3
);
489 if (value2
) alpha
= (atoi (value2
) / 100.0);
490 get_color (value1
, panel_config
.g_task
.font
[status
].color
);
491 panel_config
.g_task
.font
[status
].alpha
= alpha
;
492 panel_config
.g_task
.config_font_mask
|= (1<<status
);
494 else if (g_regex_match_simple("task.*_icon_asb", key
, 0, 0)) {
495 gchar
** split
= g_regex_split_simple("_", key
, 0, 0);
496 int status
= get_task_status(split
[1]);
498 extract_values(value
, &value1
, &value2
, &value3
);
499 panel_config
.g_task
.alpha
[status
] = atoi(value1
);
500 panel_config
.g_task
.saturation
[status
] = atoi(value2
);
501 panel_config
.g_task
.brightness
[status
] = atoi(value3
);
502 panel_config
.g_task
.config_asb_mask
|= (1<<status
);
504 else if (g_regex_match_simple("task.*_background_id", key
, 0, 0)) {
505 gchar
** split
= g_regex_split_simple("_", key
, 0, 0);
506 int status
= get_task_status(split
[1]);
508 int id
= atoi (value
);
509 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
510 panel_config
.g_task
.background
[status
] = &g_array_index(backgrounds
, Background
, id
);
511 panel_config
.g_task
.config_background_mask
|= (1<<status
);
512 if (status
== TASK_NORMAL
) panel_config
.g_task
.area
.bg
= panel_config
.g_task
.background
[TASK_NORMAL
];
516 else if (strcmp (key
, "systray_padding") == 0) {
517 extract_values(value
, &value1
, &value2
, &value3
);
518 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
519 if (value2
) systray
.area
.paddingy
= atoi (value2
);
520 if (value3
) systray
.area
.paddingx
= atoi (value3
);
522 else if (strcmp (key
, "systray_background_id") == 0) {
523 int id
= atoi (value
);
524 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
525 systray
.area
.bg
= &g_array_index(backgrounds
, Background
, id
);
527 else if (strcmp(key
, "systray_sort") == 0) {
528 if (strcmp(value
, "descending") == 0)
530 else if (strcmp(value
, "ascending") == 0)
532 else if (strcmp(value
, "left2right") == 0)
534 else if (strcmp(value
, "right2left") == 0)
537 else if (strcmp(key
, "systray_icon_size") == 0) {
538 systray_max_icon_size
= atoi(value
);
540 else if (strcmp(key
, "systray_icon_asb") == 0) {
541 extract_values(value
, &value1
, &value2
, &value3
);
542 systray
.alpha
= atoi(value1
);
543 systray
.saturation
= atoi(value2
);
544 systray
.brightness
= atoi(value3
);
548 else if (strcmp (key
, "launcher_padding") == 0) {
549 extract_values(value
, &value1
, &value2
, &value3
);
550 panel_config
.launcher
.area
.paddingxlr
= panel_config
.launcher
.area
.paddingx
= atoi (value1
);
551 if (value2
) panel_config
.launcher
.area
.paddingy
= atoi (value2
);
552 if (value3
) panel_config
.launcher
.area
.paddingx
= atoi (value3
);
554 else if (strcmp (key
, "launcher_background_id") == 0) {
555 int id
= atoi (value
);
556 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
557 panel_config
.launcher
.area
.bg
= &g_array_index(backgrounds
, Background
, id
);
559 else if (strcmp(key
, "launcher_icon_size") == 0) {
560 launcher_max_icon_size
= atoi(value
);
562 else if (strcmp(key
, "launcher_item_app") == 0) {
563 char *app
= strdup(value
);
564 panel_config
.launcher
.list_apps
= g_slist_append(panel_config
.launcher
.list_apps
, app
);
566 else if (strcmp(key
, "launcher_icon_theme") == 0) {
567 char *app
= strdup(value
);
568 panel_config
.launcher
.icon_theme_names
= g_slist_append(panel_config
.launcher
.icon_theme_names
, app
);
572 else if (strcmp (key
, "tooltip") == 0)
573 g_tooltip
.enabled
= atoi(value
);
574 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
575 int timeout_msec
= 1000*atof(value
);
576 g_tooltip
.show_timeout_msec
= timeout_msec
;
578 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
579 int timeout_msec
= 1000*atof(value
);
580 g_tooltip
.hide_timeout_msec
= timeout_msec
;
582 else if (strcmp (key
, "tooltip_padding") == 0) {
583 extract_values(value
, &value1
, &value2
, &value3
);
584 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
585 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
587 else if (strcmp (key
, "tooltip_background_id") == 0) {
588 int id
= atoi (value
);
589 id
= (id
< backgrounds
->len
&& id
>= 0) ? id
: 0;
590 g_tooltip
.bg
= &g_array_index(backgrounds
, Background
, id
);
592 else if (strcmp (key
, "tooltip_font_color") == 0) {
593 extract_values(value
, &value1
, &value2
, &value3
);
594 get_color(value1
, g_tooltip
.font_color
.color
);
595 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
596 else g_tooltip
.font_color
.alpha
= 0.1;
598 else if (strcmp (key
, "tooltip_font") == 0) {
599 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
603 else if (strcmp (key
, "mouse_middle") == 0)
604 get_action (value
, &mouse_middle
);
605 else if (strcmp (key
, "mouse_right") == 0)
606 get_action (value
, &mouse_right
);
607 else if (strcmp (key
, "mouse_scroll_up") == 0)
608 get_action (value
, &mouse_scroll_up
);
609 else if (strcmp (key
, "mouse_scroll_down") == 0)
610 get_action (value
, &mouse_scroll_down
);
612 /* autohide options */
613 else if (strcmp(key
, "autohide") == 0)
614 panel_autohide
= atoi(value
);
615 else if (strcmp(key
, "autohide_show_timeout") == 0)
616 panel_autohide_show_timeout
= 1000*atof(value
);
617 else if (strcmp(key
, "autohide_hide_timeout") == 0)
618 panel_autohide_hide_timeout
= 1000*atof(value
);
619 else if (strcmp(key
, "strut_policy") == 0) {
620 if (strcmp(value
, "follow_size") == 0)
621 panel_strut_policy
= STRUT_FOLLOW_SIZE
;
622 else if (strcmp(value
, "none") == 0)
623 panel_strut_policy
= STRUT_NONE
;
625 panel_strut_policy
= STRUT_MINIMUM
;
627 else if (strcmp(key
, "autohide_height") == 0) {
628 panel_autohide_height
= atoi(value
);
629 if (panel_autohide_height
== 0) {
630 // autohide need height > 0
631 panel_autohide_height
= 1;
636 fprintf(stderr
, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key
);
638 if (value1
) free (value1
);
639 if (value2
) free (value2
);
640 if (value3
) free (value3
);
646 const gchar
* const * system_dirs
;
650 // follow XDG specification
651 // check tint2rc in user directory
652 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
653 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
654 i
= config_read_file (path1
);
655 config_path
= strdup(path1
);
661 // copy tint2rc from system directory to user directory
663 system_dirs
= g_get_system_config_dirs();
664 for (i
= 0; system_dirs
[i
]; i
++) {
665 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
667 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
673 // copy file in user directory (path1)
674 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
675 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
678 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
679 copy_file(path2
, path1
);
682 i
= config_read_file (path1
);
683 config_path
= strdup(path1
);
691 int config_read_file (const char *path
)
697 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
699 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
700 if (parse_line(line
, &key
, &value
)) {
701 add_entry (key
, value
);