]>
Dogcows Code - chaz/tint2/blob - src/config.c
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>
42 #include "systraybar.h"
53 char *config_path
= 0;
54 char *thumbnail_path
= 0;
56 // --------------------------------------------------
57 // backward compatibility
58 static int old_task_icon_size
;
59 static char *old_task_font
;
60 static char *old_time1_font
;
61 static char *old_time2_font
;
62 static Area
*area_task
, *area_task_active
;
65 // temporary list of background
66 static GSList
*list_back
;
72 // append full transparency background
73 list_back
= g_slist_append(0, calloc(1, sizeof(Area
)));
75 // tint2 could reload config, so we cleanup objects
81 // panel's default value
82 memset(&panel_config
, 0, sizeof(Panel
));
83 panel_config
.g_task
.alpha
= 100;
84 panel_config
.g_task
.alpha_active
= 100;
87 // window manager's menu default value == false
95 // cleanup background list
97 for (l0
= list_back
; l0
; l0
= l0
->next
) {
100 g_slist_free(list_back
);
105 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
109 if (*value1
) free (*value1
);
110 if (*value2
) free (*value2
);
111 if (*value3
) free (*value3
);
113 if ((b
= strchr (value
, ' '))) {
121 *value1
= strdup (value
);
125 if ((c
= strchr (b
, ' '))) {
133 *value2
= strdup (b
);
138 *value3
= strdup (c
);
144 void get_action (char *event
, int *action
)
146 if (strcmp (event
, "none") == 0)
148 else if (strcmp (event
, "close") == 0)
150 else if (strcmp (event
, "toggle") == 0)
152 else if (strcmp (event
, "iconify") == 0)
154 else if (strcmp (event
, "shade") == 0)
156 else if (strcmp (event
, "toggle_iconify") == 0)
157 *action
= TOGGLE_ICONIFY
;
158 else if (strcmp (event
, "maximize_restore") == 0)
159 *action
= MAXIMIZE_RESTORE
;
160 else if (strcmp (event
, "desktop_left") == 0)
161 *action
= DESKTOP_LEFT
;
162 else if (strcmp (event
, "desktop_right") == 0)
163 *action
= DESKTOP_RIGHT
;
167 void add_entry (char *key
, char *value
)
169 char *value1
=0, *value2
=0, *value3
=0;
171 /* Background and border */
172 if (strcmp (key
, "rounded") == 0) {
173 // 'rounded' is the first parameter => alloc a new background
174 Area
*a
= calloc(1, sizeof(Area
));
175 a
->pix
.border
.rounded
= atoi (value
);
176 list_back
= g_slist_append(list_back
, a
);
178 else if (strcmp (key
, "border_width") == 0) {
179 Area
*a
= g_slist_last(list_back
)->data
;
180 a
->pix
.border
.width
= atoi (value
);
182 else if (strcmp (key
, "background_color") == 0) {
183 Area
*a
= g_slist_last(list_back
)->data
;
184 extract_values(value
, &value1
, &value2
, &value3
);
185 get_color (value1
, a
->pix
.back
.color
);
186 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
187 else a
->pix
.back
.alpha
= 0.5;
189 else if (strcmp (key
, "border_color") == 0) {
190 Area
*a
= g_slist_last(list_back
)->data
;
191 extract_values(value
, &value1
, &value2
, &value3
);
192 get_color (value1
, a
->pix
.border
.color
);
193 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
194 else a
->pix
.border
.alpha
= 0.5;
198 else if (strcmp (key
, "panel_monitor") == 0) {
199 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
201 panel_config
.monitor
= atoi (value
);
202 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
204 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
205 // server.nb_monitor minimum value is 1 (see get_monitors())
206 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
207 panel_config
.monitor
= 0;
210 else if (strcmp (key
, "panel_size") == 0) {
211 extract_values(value
, &value1
, &value2
, &value3
);
214 if ((b
= strchr (value1
, '%'))) {
216 panel_config
.pourcentx
= 1;
218 panel_config
.area
.width
= atoi(value1
);
219 if (panel_config
.area
.width
== 0) {
221 panel_config
.area
.width
= 100;
222 panel_config
.pourcentx
= 1;
225 if ((b
= strchr (value2
, '%'))) {
227 panel_config
.pourcenty
= 1;
229 panel_config
.area
.height
= atoi(value2
);
232 else if (strcmp (key
, "panel_margin") == 0) {
233 extract_values(value
, &value1
, &value2
, &value3
);
234 panel_config
.marginx
= atoi (value1
);
235 if (value2
) panel_config
.marginy
= atoi (value2
);
237 else if (strcmp (key
, "panel_padding") == 0) {
238 extract_values(value
, &value1
, &value2
, &value3
);
239 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
240 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
241 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
243 else if (strcmp (key
, "panel_position") == 0) {
244 extract_values(value
, &value1
, &value2
, &value3
);
245 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
247 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
248 else panel_position
= CENTER
;
251 if (!value2
) panel_position
|= CENTER
;
253 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
255 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
256 else panel_position
|= CENTER
;
259 if (!value3
) panel_horizontal
= 1;
261 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
262 else panel_horizontal
= 1;
265 else if (strcmp (key
, "font_shadow") == 0)
266 panel_config
.g_task
.font_shadow
= atoi (value
);
267 else if (strcmp (key
, "panel_background_id") == 0) {
268 int id
= atoi (value
);
269 Area
*a
= g_slist_nth_data(list_back
, id
);
270 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
271 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
273 else if (strcmp (key
, "wm_menu") == 0)
274 wm_menu
= atoi (value
);
275 else if (strcmp (key
, "panel_dock") == 0)
276 panel_dock
= atoi (value
);
277 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
278 max_tick_urgent
= (atoi (value
) * 2) + 1;
281 else if (strcmp (key
, "battery") == 0) {
282 #ifdef ENABLE_BATTERY
287 fprintf(stderr
, "tint2 is build without battery support\n");
290 else if (strcmp (key
, "battery_low_status") == 0) {
291 #ifdef ENABLE_BATTERY
292 battery_low_status
= atoi(value
);
293 if(battery_low_status
< 0 || battery_low_status
> 100)
294 battery_low_status
= 0;
297 else if (strcmp (key
, "battery_low_cmd") == 0) {
298 #ifdef ENABLE_BATTERY
299 if (strlen(value
) > 0)
300 battery_low_cmd
= strdup (value
);
303 else if (strcmp (key
, "bat1_font") == 0) {
304 #ifdef ENABLE_BATTERY
305 bat1_font_desc
= pango_font_description_from_string (value
);
308 else if (strcmp (key
, "bat2_font") == 0) {
309 #ifdef ENABLE_BATTERY
310 bat2_font_desc
= pango_font_description_from_string (value
);
313 else if (strcmp (key
, "battery_font_color") == 0) {
314 #ifdef ENABLE_BATTERY
315 extract_values(value
, &value1
, &value2
, &value3
);
316 get_color (value1
, panel_config
.battery
.font
.color
);
317 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
318 else panel_config
.battery
.font
.alpha
= 0.5;
321 else if (strcmp (key
, "battery_padding") == 0) {
322 #ifdef ENABLE_BATTERY
323 extract_values(value
, &value1
, &value2
, &value3
);
324 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
325 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
326 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
329 else if (strcmp (key
, "battery_background_id") == 0) {
330 #ifdef ENABLE_BATTERY
331 int id
= atoi (value
);
332 Area
*a
= g_slist_nth_data(list_back
, id
);
333 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
334 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
339 else if (strcmp (key
, "time1_format") == 0) {
340 if (strlen(value
) > 0) {
341 time1_format
= strdup (value
);
345 else if (strcmp (key
, "time2_format") == 0) {
346 if (strlen(value
) > 0)
347 time2_format
= strdup (value
);
349 else if (strcmp (key
, "time1_font") == 0) {
350 time1_font_desc
= pango_font_description_from_string (value
);
352 else if (strcmp (key
, "time2_font") == 0) {
353 time2_font_desc
= pango_font_description_from_string (value
);
355 else if (strcmp (key
, "clock_font_color") == 0) {
356 extract_values(value
, &value1
, &value2
, &value3
);
357 get_color (value1
, panel_config
.clock
.font
.color
);
358 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
359 else panel_config
.clock
.font
.alpha
= 0.5;
361 else if (strcmp (key
, "clock_padding") == 0) {
362 extract_values(value
, &value1
, &value2
, &value3
);
363 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
364 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
365 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
367 else if (strcmp (key
, "clock_background_id") == 0) {
368 int id
= atoi (value
);
369 Area
*a
= g_slist_nth_data(list_back
, id
);
370 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
371 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
373 else if (strcmp(key
, "clock_lclick_command") == 0) {
374 if (strlen(value
) > 0)
375 clock_lclick_command
= strdup(value
);
377 else if (strcmp(key
, "clock_rclick_command") == 0) {
378 if (strlen(value
) > 0)
379 clock_rclick_command
= strdup(value
);
383 else if (strcmp (key
, "taskbar_mode") == 0) {
384 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
385 else panel_mode
= SINGLE_DESKTOP
;
387 else if (strcmp (key
, "taskbar_padding") == 0) {
388 extract_values(value
, &value1
, &value2
, &value3
);
389 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
390 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
391 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
393 else if (strcmp (key
, "taskbar_background_id") == 0) {
394 int id
= atoi (value
);
395 Area
*a
= g_slist_nth_data(list_back
, id
);
396 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
397 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
399 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
400 int id
= atoi (value
);
401 Area
*a
= g_slist_nth_data(list_back
, id
);
402 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
403 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
404 panel_config
.g_taskbar
.use_active
= 1;
408 else if (strcmp (key
, "task_text") == 0)
409 panel_config
.g_task
.text
= atoi (value
);
410 else if (strcmp (key
, "task_icon") == 0)
411 panel_config
.g_task
.icon
= atoi (value
);
412 else if (strcmp (key
, "task_centered") == 0)
413 panel_config
.g_task
.centered
= atoi (value
);
414 else if (strcmp (key
, "task_width") == 0) {
415 // old parameter : just for backward compatibility
416 panel_config
.g_task
.maximum_width
= atoi (value
);
417 panel_config
.g_task
.maximum_height
= 30;
419 else if (strcmp (key
, "task_maximum_size") == 0) {
420 extract_values(value
, &value1
, &value2
, &value3
);
421 panel_config
.g_task
.maximum_width
= atoi (value1
);
422 panel_config
.g_task
.maximum_height
= 30;
424 panel_config
.g_task
.maximum_height
= atoi (value2
);
426 else if (strcmp (key
, "task_padding") == 0) {
427 extract_values(value
, &value1
, &value2
, &value3
);
428 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
429 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
430 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
432 else if (strcmp (key
, "task_font") == 0) {
433 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
435 else if (strcmp (key
, "task_font_color") == 0) {
436 extract_values(value
, &value1
, &value2
, &value3
);
437 get_color (value1
, panel_config
.g_task
.font
.color
);
438 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
439 else panel_config
.g_task
.font
.alpha
= 0.1;
441 else if (strcmp (key
, "task_active_font_color") == 0) {
442 extract_values(value
, &value1
, &value2
, &value3
);
443 get_color (value1
, panel_config
.g_task
.font_active
.color
);
444 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
445 else panel_config
.g_task
.font_active
.alpha
= 0.1;
447 else if (strcmp (key
, "task_icon_asb") == 0) {
448 extract_values(value
, &value1
, &value2
, &value3
);
449 panel_config
.g_task
.alpha
= atoi(value1
);
450 panel_config
.g_task
.saturation
= atoi(value2
);
451 panel_config
.g_task
.brightness
= atoi(value3
);
453 else if (strcmp (key
, "task_active_icon_asb") == 0) {
454 extract_values(value
, &value1
, &value2
, &value3
);
455 panel_config
.g_task
.alpha_active
= atoi(value1
);
456 panel_config
.g_task
.saturation_active
= atoi(value2
);
457 panel_config
.g_task
.brightness_active
= atoi(value3
);
459 else if (strcmp (key
, "task_background_id") == 0) {
460 int id
= atoi (value
);
461 Area
*a
= g_slist_nth_data(list_back
, id
);
462 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
463 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
465 else if (strcmp (key
, "task_active_background_id") == 0) {
466 int id
= atoi (value
);
467 Area
*a
= g_slist_nth_data(list_back
, id
);
468 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
469 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
473 else if (strcmp (key
, "systray") == 0) {
477 else if (strcmp (key
, "systray_padding") == 0) {
478 extract_values(value
, &value1
, &value2
, &value3
);
479 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
480 if (value2
) systray
.area
.paddingy
= atoi (value2
);
481 if (value3
) systray
.area
.paddingx
= atoi (value3
);
483 else if (strcmp (key
, "systray_background_id") == 0) {
484 int id
= atoi (value
);
485 Area
*a
= g_slist_nth_data(list_back
, id
);
486 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
487 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
489 else if (strcmp(key
, "systray_sort") == 0) {
490 if (strcmp(value
, "descending") == 0)
492 else if (strcmp(value
, "ascending") == 0)
494 else if (strcmp(value
, "left2right") == 0)
496 else if (strcmp(value
, "right2left") == 0)
501 else if (strcmp (key
, "tooltip") == 0)
502 g_tooltip
.enabled
= atoi(value
);
503 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
504 double timeout
= atof(value
);
505 int sec
= (int)timeout
;
506 int usec
= (timeout
-sec
)*1e6
;
507 g_tooltip
.show_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
509 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
510 double timeout
= atof(value
);
511 int sec
= (int)timeout
;
512 int usec
= (timeout
-sec
)*1e6
;
513 g_tooltip
.hide_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
515 else if (strcmp (key
, "tooltip_padding") == 0) {
516 extract_values(value
, &value1
, &value2
, &value3
);
517 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
518 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
520 else if (strcmp (key
, "tooltip_background_id") == 0) {
521 int id
= atoi (value
);
522 Area
*a
= g_slist_nth_data(list_back
, id
);
523 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
524 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
526 else if (strcmp (key
, "tooltip_font_color") == 0) {
527 extract_values(value
, &value1
, &value2
, &value3
);
528 get_color(value1
, g_tooltip
.font_color
.color
);
529 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
530 else g_tooltip
.font_color
.alpha
= 0.1;
532 else if (strcmp (key
, "tooltip_font") == 0) {
533 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
537 else if (strcmp (key
, "mouse_middle") == 0)
538 get_action (value
, &mouse_middle
);
539 else if (strcmp (key
, "mouse_right") == 0)
540 get_action (value
, &mouse_right
);
541 else if (strcmp (key
, "mouse_scroll_up") == 0)
542 get_action (value
, &mouse_scroll_up
);
543 else if (strcmp (key
, "mouse_scroll_down") == 0)
544 get_action (value
, &mouse_scroll_down
);
547 /* Read tint-0.6 config for backward compatibility */
548 else if (strcmp (key
, "panel_mode") == 0) {
549 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
550 else panel_mode
= MULTI_DESKTOP
;
552 else if (strcmp (key
, "panel_rounded") == 0) {
553 Area
*a
= calloc(1, sizeof(Area
));
554 a
->pix
.border
.rounded
= atoi (value
);
555 list_back
= g_slist_append(list_back
, a
);
557 else if (strcmp (key
, "panel_border_width") == 0) {
558 Area
*a
= g_slist_last(list_back
)->data
;
559 a
->pix
.border
.width
= atoi (value
);
561 else if (strcmp (key
, "panel_background_color") == 0) {
562 Area
*a
= g_slist_last(list_back
)->data
;
563 extract_values(value
, &value1
, &value2
, &value3
);
564 get_color (value1
, a
->pix
.back
.color
);
565 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
566 else a
->pix
.back
.alpha
= 0.5;
568 else if (strcmp (key
, "panel_border_color") == 0) {
569 Area
*a
= g_slist_last(list_back
)->data
;
570 extract_values(value
, &value1
, &value2
, &value3
);
571 get_color (value1
, a
->pix
.border
.color
);
572 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
573 else a
->pix
.border
.alpha
= 0.5;
575 else if (strcmp (key
, "task_text_centered") == 0)
576 panel_config
.g_task
.centered
= atoi (value
);
577 else if (strcmp (key
, "task_margin") == 0) {
578 panel_config
.g_taskbar
.paddingxlr
= 0;
579 panel_config
.g_taskbar
.paddingx
= atoi (value
);
581 else if (strcmp (key
, "task_icon_size") == 0)
582 old_task_icon_size
= atoi (value
);
583 else if (strcmp (key
, "task_rounded") == 0) {
584 area_task
= calloc(1, sizeof(Area
));
585 area_task
->pix
.border
.rounded
= atoi (value
);
586 list_back
= g_slist_append(list_back
, area_task
);
588 area_task_active
= calloc(1, sizeof(Area
));
589 area_task_active
->pix
.border
.rounded
= atoi (value
);
590 list_back
= g_slist_append(list_back
, area_task_active
);
592 else if (strcmp (key
, "task_background_color") == 0) {
593 extract_values(value
, &value1
, &value2
, &value3
);
594 get_color (value1
, area_task
->pix
.back
.color
);
595 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
596 else area_task
->pix
.back
.alpha
= 0.5;
598 else if (strcmp (key
, "task_active_background_color") == 0) {
599 extract_values(value
, &value1
, &value2
, &value3
);
600 get_color (value1
, area_task_active
->pix
.back
.color
);
601 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
602 else area_task_active
->pix
.back
.alpha
= 0.5;
604 else if (strcmp (key
, "task_border_width") == 0) {
605 area_task
->pix
.border
.width
= atoi (value
);
606 area_task_active
->pix
.border
.width
= atoi (value
);
608 else if (strcmp (key
, "task_border_color") == 0) {
609 extract_values(value
, &value1
, &value2
, &value3
);
610 get_color (value1
, area_task
->pix
.border
.color
);
611 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
612 else area_task
->pix
.border
.alpha
= 0.5;
614 else if (strcmp (key
, "task_active_border_color") == 0) {
615 extract_values(value
, &value1
, &value2
, &value3
);
616 get_color (value1
, area_task_active
->pix
.border
.color
);
617 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
618 else area_task_active
->pix
.border
.alpha
= 0.5;
622 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
624 if (value1
) free (value1
);
625 if (value2
) free (value2
);
626 if (value3
) free (value3
);
632 const gchar
* const * system_dirs
;
636 // follow XDG specification
637 // check tint2rc in user directory
638 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
639 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
640 i
= config_read_file (path1
);
641 config_path
= strdup(path1
);
647 // copy tint2rc from system directory to user directory
650 system_dirs
= g_get_system_config_dirs();
651 for (i
= 0; system_dirs
[i
]; i
++) {
652 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
654 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
660 // copy file in user directory (path1)
661 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
662 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
665 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
666 copy_file(path2
, path1
);
669 i
= config_read_file (path1
);
670 config_path
= strdup(path1
);
678 int config_read_file (const char *path
)
684 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
689 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
690 if (parse_line(line
, &key
, &value
)) {
691 add_entry (key
, value
);
698 if (old_task_icon_size
) {
699 panel_config
.g_task
.area
.paddingy
= ((int)panel_config
.area
.height
- (2 * panel_config
.area
.paddingy
) - old_task_icon_size
) / 2;
702 g_free(old_task_font
);
705 if (old_time1_font
) {
706 g_free(old_time1_font
);
709 if (old_time2_font
) {
710 g_free(old_time2_font
);
This page took 0.069293 seconds and 5 git commands to generate.