]>
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>
35 #include <pango/pangoxft.h>
43 #include "systraybar.h"
55 char *config_path
= 0;
56 char *snapshot_path
= 0;
58 // --------------------------------------------------
59 // backward compatibility
60 static int old_task_icon_size
;
61 static Area
*area_task
;
62 static Area
*area_task_active
;
63 // detect if it's an old config file
65 static int old_config_file
;
67 // temporary list of background
68 static GSList
*list_back
;
74 // append full transparency background
75 list_back
= g_slist_append(0, calloc(1, sizeof(Area
)));
77 // tint2 could reload config, so we cleanup objects
78 uninstall_all_timer();
86 // panel's default value
87 if (panel_config
.g_task
.font_desc
) {
88 pango_font_description_free(panel_config
.g_task
.font_desc
);
90 memset(&panel_config
, 0, sizeof(Panel
));
91 panel_config
.g_task
.alpha
= 100;
92 panel_config
.g_task
.alpha_active
= 100;
96 // window manager's menu default value == false
100 // flush pango cache if possible
101 //pango_xft_shutdown_display(server.dsp, server.screen);
102 //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
103 //pango_fc_font_map_shutdown(font_map);
107 void cleanup_config()
109 // cleanup background list
111 for (l0
= list_back
; l0
; l0
= l0
->next
) {
114 g_slist_free(list_back
);
119 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
123 if (*value1
) free (*value1
);
124 if (*value2
) free (*value2
);
125 if (*value3
) free (*value3
);
127 if ((b
= strchr (value
, ' '))) {
135 *value1
= strdup (value
);
139 if ((c
= strchr (b
, ' '))) {
147 *value2
= strdup (b
);
152 *value3
= strdup (c
);
158 void get_action (char *event
, int *action
)
160 if (strcmp (event
, "none") == 0)
162 else if (strcmp (event
, "close") == 0)
164 else if (strcmp (event
, "toggle") == 0)
166 else if (strcmp (event
, "iconify") == 0)
168 else if (strcmp (event
, "shade") == 0)
170 else if (strcmp (event
, "toggle_iconify") == 0)
171 *action
= TOGGLE_ICONIFY
;
172 else if (strcmp (event
, "maximize_restore") == 0)
173 *action
= MAXIMIZE_RESTORE
;
174 else if (strcmp (event
, "desktop_left") == 0)
175 *action
= DESKTOP_LEFT
;
176 else if (strcmp (event
, "desktop_right") == 0)
177 *action
= DESKTOP_RIGHT
;
178 else if (strcmp (event
, "next_task") == 0)
180 else if (strcmp (event
, "prev_task") == 0)
185 void add_entry (char *key
, char *value
)
187 char *value1
=0, *value2
=0, *value3
=0;
189 /* Background and border */
190 if (strcmp (key
, "rounded") == 0) {
191 // 'rounded' is the first parameter => alloc a new background
192 Area
*a
= calloc(1, sizeof(Area
));
193 a
->pix
.border
.rounded
= atoi (value
);
194 list_back
= g_slist_append(list_back
, a
);
196 else if (strcmp (key
, "border_width") == 0) {
197 Area
*a
= g_slist_last(list_back
)->data
;
198 a
->pix
.border
.width
= atoi (value
);
200 else if (strcmp (key
, "background_color") == 0) {
201 Area
*a
= g_slist_last(list_back
)->data
;
202 extract_values(value
, &value1
, &value2
, &value3
);
203 get_color (value1
, a
->pix
.back
.color
);
204 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
205 else a
->pix
.back
.alpha
= 0.5;
207 else if (strcmp (key
, "border_color") == 0) {
208 Area
*a
= g_slist_last(list_back
)->data
;
209 extract_values(value
, &value1
, &value2
, &value3
);
210 get_color (value1
, a
->pix
.border
.color
);
211 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
212 else a
->pix
.border
.alpha
= 0.5;
216 else if (strcmp (key
, "panel_monitor") == 0) {
217 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
219 panel_config
.monitor
= atoi (value
);
220 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
222 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
223 // server.nb_monitor minimum value is 1 (see get_monitors())
224 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
225 panel_config
.monitor
= 0;
228 else if (strcmp (key
, "panel_size") == 0) {
229 extract_values(value
, &value1
, &value2
, &value3
);
232 if ((b
= strchr (value1
, '%'))) {
234 panel_config
.pourcentx
= 1;
236 panel_config
.area
.width
= atoi(value1
);
237 if (panel_config
.area
.width
== 0) {
239 panel_config
.area
.width
= 100;
240 panel_config
.pourcentx
= 1;
243 if ((b
= strchr (value2
, '%'))) {
245 panel_config
.pourcenty
= 1;
247 panel_config
.area
.height
= atoi(value2
);
250 else if (strcmp (key
, "panel_margin") == 0) {
251 extract_values(value
, &value1
, &value2
, &value3
);
252 panel_config
.marginx
= atoi (value1
);
253 if (value2
) panel_config
.marginy
= atoi (value2
);
255 else if (strcmp (key
, "panel_padding") == 0) {
256 extract_values(value
, &value1
, &value2
, &value3
);
257 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
258 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
259 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
261 else if (strcmp (key
, "panel_position") == 0) {
262 extract_values(value
, &value1
, &value2
, &value3
);
263 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
265 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
266 else panel_position
= CENTER
;
269 if (!value2
) panel_position
|= CENTER
;
271 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
273 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
274 else panel_position
|= CENTER
;
277 if (!value3
) panel_horizontal
= 1;
279 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
280 else panel_horizontal
= 1;
283 else if (strcmp (key
, "font_shadow") == 0)
284 panel_config
.g_task
.font_shadow
= atoi (value
);
285 else if (strcmp (key
, "panel_background_id") == 0) {
286 int id
= atoi (value
);
287 Area
*a
= g_slist_nth_data(list_back
, id
);
288 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
289 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
291 else if (strcmp (key
, "wm_menu") == 0)
292 wm_menu
= atoi (value
);
293 else if (strcmp (key
, "panel_dock") == 0)
294 panel_dock
= atoi (value
);
295 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
296 max_tick_urgent
= (atoi (value
) * 2) + 1;
299 else if (strcmp (key
, "battery") == 0) {
300 #ifdef ENABLE_BATTERY
305 fprintf(stderr
, "tint2 is build without battery support\n");
308 else if (strcmp (key
, "battery_low_status") == 0) {
309 #ifdef ENABLE_BATTERY
310 battery_low_status
= atoi(value
);
311 if(battery_low_status
< 0 || battery_low_status
> 100)
312 battery_low_status
= 0;
315 else if (strcmp (key
, "battery_low_cmd") == 0) {
316 #ifdef ENABLE_BATTERY
317 if (strlen(value
) > 0)
318 battery_low_cmd
= strdup (value
);
321 else if (strcmp (key
, "bat1_font") == 0) {
322 #ifdef ENABLE_BATTERY
323 bat1_font_desc
= pango_font_description_from_string (value
);
326 else if (strcmp (key
, "bat2_font") == 0) {
327 #ifdef ENABLE_BATTERY
328 bat2_font_desc
= pango_font_description_from_string (value
);
331 else if (strcmp (key
, "battery_font_color") == 0) {
332 #ifdef ENABLE_BATTERY
333 extract_values(value
, &value1
, &value2
, &value3
);
334 get_color (value1
, panel_config
.battery
.font
.color
);
335 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
336 else panel_config
.battery
.font
.alpha
= 0.5;
339 else if (strcmp (key
, "battery_padding") == 0) {
340 #ifdef ENABLE_BATTERY
341 extract_values(value
, &value1
, &value2
, &value3
);
342 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
343 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
344 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
347 else if (strcmp (key
, "battery_background_id") == 0) {
348 #ifdef ENABLE_BATTERY
349 int id
= atoi (value
);
350 Area
*a
= g_slist_nth_data(list_back
, id
);
351 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
352 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
357 else if (strcmp (key
, "time1_format") == 0) {
358 if (strlen(value
) > 0) {
359 time1_format
= strdup (value
);
363 else if (strcmp (key
, "time2_format") == 0) {
364 if (strlen(value
) > 0)
365 time2_format
= strdup (value
);
367 else if (strcmp (key
, "time1_font") == 0) {
368 time1_font_desc
= pango_font_description_from_string (value
);
370 else if (strcmp (key
, "time2_font") == 0) {
371 time2_font_desc
= pango_font_description_from_string (value
);
373 else if (strcmp (key
, "clock_font_color") == 0) {
374 extract_values(value
, &value1
, &value2
, &value3
);
375 get_color (value1
, panel_config
.clock
.font
.color
);
376 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
377 else panel_config
.clock
.font
.alpha
= 0.5;
379 else if (strcmp (key
, "clock_padding") == 0) {
380 extract_values(value
, &value1
, &value2
, &value3
);
381 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
382 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
383 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
385 else if (strcmp (key
, "clock_background_id") == 0) {
386 int id
= atoi (value
);
387 Area
*a
= g_slist_nth_data(list_back
, id
);
388 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
389 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
391 else if (strcmp(key
, "clock_tooltip") == 0) {
392 if (strlen(value
) > 0)
393 time_tooltip_format
= strdup (value
);
395 else if (strcmp(key
, "clock_lclick_command") == 0) {
396 if (strlen(value
) > 0)
397 clock_lclick_command
= strdup(value
);
399 else if (strcmp(key
, "clock_rclick_command") == 0) {
400 if (strlen(value
) > 0)
401 clock_rclick_command
= strdup(value
);
405 else if (strcmp (key
, "taskbar_mode") == 0) {
406 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
407 else panel_mode
= SINGLE_DESKTOP
;
409 else if (strcmp (key
, "taskbar_padding") == 0) {
410 extract_values(value
, &value1
, &value2
, &value3
);
411 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
412 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
413 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
415 else if (strcmp (key
, "taskbar_background_id") == 0) {
416 int id
= atoi (value
);
417 Area
*a
= g_slist_nth_data(list_back
, id
);
418 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
419 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
421 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
422 int id
= atoi (value
);
423 Area
*a
= g_slist_nth_data(list_back
, id
);
424 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
425 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
426 panel_config
.g_taskbar
.use_active
= 1;
430 else if (strcmp (key
, "task_text") == 0)
431 panel_config
.g_task
.text
= atoi (value
);
432 else if (strcmp (key
, "task_icon") == 0)
433 panel_config
.g_task
.icon
= atoi (value
);
434 else if (strcmp (key
, "task_centered") == 0)
435 panel_config
.g_task
.centered
= atoi (value
);
436 else if (strcmp (key
, "task_width") == 0) {
437 // old parameter : just for backward compatibility
438 panel_config
.g_task
.maximum_width
= atoi (value
);
439 panel_config
.g_task
.maximum_height
= 30;
441 else if (strcmp (key
, "task_maximum_size") == 0) {
442 extract_values(value
, &value1
, &value2
, &value3
);
443 panel_config
.g_task
.maximum_width
= atoi (value1
);
444 panel_config
.g_task
.maximum_height
= 30;
446 panel_config
.g_task
.maximum_height
= atoi (value2
);
448 else if (strcmp (key
, "task_padding") == 0) {
449 extract_values(value
, &value1
, &value2
, &value3
);
450 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
451 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
452 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
454 else if (strcmp (key
, "task_font") == 0) {
455 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
457 else if (strcmp (key
, "task_font_color") == 0) {
458 extract_values(value
, &value1
, &value2
, &value3
);
459 get_color (value1
, panel_config
.g_task
.font
.color
);
460 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
461 else panel_config
.g_task
.font
.alpha
= 0.1;
463 else if (strcmp (key
, "task_active_font_color") == 0) {
464 extract_values(value
, &value1
, &value2
, &value3
);
465 get_color (value1
, panel_config
.g_task
.font_active
.color
);
466 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
467 else panel_config
.g_task
.font_active
.alpha
= 0.1;
469 else if (strcmp (key
, "task_icon_asb") == 0) {
470 extract_values(value
, &value1
, &value2
, &value3
);
471 panel_config
.g_task
.alpha
= atoi(value1
);
472 panel_config
.g_task
.saturation
= atoi(value2
);
473 panel_config
.g_task
.brightness
= atoi(value3
);
475 else if (strcmp (key
, "task_active_icon_asb") == 0) {
476 extract_values(value
, &value1
, &value2
, &value3
);
477 panel_config
.g_task
.alpha_active
= atoi(value1
);
478 panel_config
.g_task
.saturation_active
= atoi(value2
);
479 panel_config
.g_task
.brightness_active
= atoi(value3
);
481 else if (strcmp (key
, "task_background_id") == 0) {
482 int id
= atoi (value
);
483 Area
*a
= g_slist_nth_data(list_back
, id
);
484 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
485 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
487 else if (strcmp (key
, "task_active_background_id") == 0) {
488 int id
= atoi (value
);
489 Area
*a
= g_slist_nth_data(list_back
, id
);
490 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
491 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
495 else if (strcmp (key
, "systray") == 0) {
496 systray_enabled
= atoi(value
);
497 // systray is latest option added. files without 'systray' are old.
500 else if (strcmp (key
, "systray_padding") == 0) {
503 extract_values(value
, &value1
, &value2
, &value3
);
504 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
505 if (value2
) systray
.area
.paddingy
= atoi (value2
);
506 if (value3
) systray
.area
.paddingx
= atoi (value3
);
508 else if (strcmp (key
, "systray_background_id") == 0) {
509 int id
= atoi (value
);
510 Area
*a
= g_slist_nth_data(list_back
, id
);
511 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
512 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
514 else if (strcmp(key
, "systray_sort") == 0) {
515 if (strcmp(value
, "descending") == 0)
517 else if (strcmp(value
, "ascending") == 0)
519 else if (strcmp(value
, "left2right") == 0)
521 else if (strcmp(value
, "right2left") == 0)
526 else if (strcmp (key
, "tooltip") == 0)
527 g_tooltip
.enabled
= atoi(value
);
528 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
529 double timeout
= atof(value
);
530 int sec
= (int)timeout
;
531 int nsec
= (timeout
-sec
)*1e9
;
532 if (nsec
< 0) // can happen because of double is not precise such that (sec > timeout)==TRUE
534 g_tooltip
.show_timeout
= (struct timespec
){.tv_sec
=sec
, .tv_nsec
=nsec
};
536 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
537 double timeout
= atof(value
);
538 int sec
= (int)timeout
;
539 int nsec
= (timeout
-sec
)*1e9
;
540 if (nsec
< 0) // can happen because of double is not precise such that (sec > timeout)==TRUE
542 g_tooltip
.hide_timeout
= (struct timespec
){.tv_sec
=sec
, .tv_nsec
=nsec
};
544 else if (strcmp (key
, "tooltip_padding") == 0) {
545 extract_values(value
, &value1
, &value2
, &value3
);
546 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
547 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
549 else if (strcmp (key
, "tooltip_background_id") == 0) {
550 int id
= atoi (value
);
551 Area
*a
= g_slist_nth_data(list_back
, id
);
552 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
553 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
555 else if (strcmp (key
, "tooltip_font_color") == 0) {
556 extract_values(value
, &value1
, &value2
, &value3
);
557 get_color(value1
, g_tooltip
.font_color
.color
);
558 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
559 else g_tooltip
.font_color
.alpha
= 0.1;
561 else if (strcmp (key
, "tooltip_font") == 0) {
562 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
566 else if (strcmp (key
, "mouse_middle") == 0)
567 get_action (value
, &mouse_middle
);
568 else if (strcmp (key
, "mouse_right") == 0)
569 get_action (value
, &mouse_right
);
570 else if (strcmp (key
, "mouse_scroll_up") == 0)
571 get_action (value
, &mouse_scroll_up
);
572 else if (strcmp (key
, "mouse_scroll_down") == 0)
573 get_action (value
, &mouse_scroll_down
);
576 /* Read tint-0.6 config for backward compatibility */
577 else if (strcmp (key
, "panel_mode") == 0) {
578 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
579 else panel_mode
= MULTI_DESKTOP
;
581 else if (strcmp (key
, "panel_rounded") == 0) {
582 Area
*a
= calloc(1, sizeof(Area
));
583 a
->pix
.border
.rounded
= atoi (value
);
584 list_back
= g_slist_append(list_back
, a
);
586 else if (strcmp (key
, "panel_border_width") == 0) {
587 Area
*a
= g_slist_last(list_back
)->data
;
588 a
->pix
.border
.width
= atoi (value
);
590 else if (strcmp (key
, "panel_background_color") == 0) {
591 Area
*a
= g_slist_last(list_back
)->data
;
592 extract_values(value
, &value1
, &value2
, &value3
);
593 get_color (value1
, a
->pix
.back
.color
);
594 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
595 else a
->pix
.back
.alpha
= 0.5;
597 else if (strcmp (key
, "panel_border_color") == 0) {
598 Area
*a
= g_slist_last(list_back
)->data
;
599 extract_values(value
, &value1
, &value2
, &value3
);
600 get_color (value1
, a
->pix
.border
.color
);
601 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
602 else a
->pix
.border
.alpha
= 0.5;
604 else if (strcmp (key
, "task_text_centered") == 0)
605 panel_config
.g_task
.centered
= atoi (value
);
606 else if (strcmp (key
, "task_margin") == 0) {
607 panel_config
.g_taskbar
.paddingxlr
= 0;
608 panel_config
.g_taskbar
.paddingx
= atoi (value
);
610 else if (strcmp (key
, "task_icon_size") == 0)
611 old_task_icon_size
= atoi (value
);
612 else if (strcmp (key
, "task_rounded") == 0) {
613 area_task
= calloc(1, sizeof(Area
));
614 area_task
->pix
.border
.rounded
= atoi (value
);
615 list_back
= g_slist_append(list_back
, area_task
);
617 area_task_active
= calloc(1, sizeof(Area
));
618 area_task_active
->pix
.border
.rounded
= atoi (value
);
619 list_back
= g_slist_append(list_back
, area_task_active
);
621 else if (strcmp (key
, "task_background_color") == 0) {
622 extract_values(value
, &value1
, &value2
, &value3
);
623 get_color (value1
, area_task
->pix
.back
.color
);
624 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
625 else area_task
->pix
.back
.alpha
= 0.5;
627 else if (strcmp (key
, "task_active_background_color") == 0) {
628 extract_values(value
, &value1
, &value2
, &value3
);
629 get_color (value1
, area_task_active
->pix
.back
.color
);
630 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
631 else area_task_active
->pix
.back
.alpha
= 0.5;
633 else if (strcmp (key
, "task_border_width") == 0) {
634 area_task
->pix
.border
.width
= atoi (value
);
635 area_task_active
->pix
.border
.width
= atoi (value
);
637 else if (strcmp (key
, "task_border_color") == 0) {
638 extract_values(value
, &value1
, &value2
, &value3
);
639 get_color (value1
, area_task
->pix
.border
.color
);
640 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
641 else area_task
->pix
.border
.alpha
= 0.5;
643 else if (strcmp (key
, "task_active_border_color") == 0) {
644 extract_values(value
, &value1
, &value2
, &value3
);
645 get_color (value1
, area_task_active
->pix
.border
.color
);
646 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
647 else area_task_active
->pix
.border
.alpha
= 0.5;
651 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
653 if (value1
) free (value1
);
654 if (value2
) free (value2
);
655 if (value3
) free (value3
);
661 const gchar
* const * system_dirs
;
665 // follow XDG specification
666 // check tint2rc in user directory
667 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
668 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
669 i
= config_read_file (path1
);
670 config_path
= strdup(path1
);
676 // copy tint2rc from system directory to user directory
678 system_dirs
= g_get_system_config_dirs();
679 for (i
= 0; system_dirs
[i
]; i
++) {
680 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
682 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
688 // copy file in user directory (path1)
689 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
690 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
693 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
694 copy_file(path2
, path1
);
697 i
= config_read_file (path1
);
698 config_path
= strdup(path1
);
706 int config_read_file (const char *path
)
712 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
714 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
715 if (parse_line(line
, &key
, &value
)) {
716 add_entry (key
, value
);
723 if (old_task_icon_size
) {
724 panel_config
.g_task
.area
.paddingy
= ((int)panel_config
.area
.height
- (2 * panel_config
.area
.paddingy
) - old_task_icon_size
) / 2;
This page took 0.083627 seconds and 5 git commands to generate.