]>
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"
54 char *config_path
= 0;
55 char *thumbnail_path
= 0;
57 // --------------------------------------------------
58 // backward compatibility
59 static int old_task_icon_size
;
60 static Area
*area_task
;
61 static Area
*area_task_active
;
64 // temporary list of background
65 static GSList
*list_back
;
71 // append full transparency background
72 list_back
= g_slist_append(0, calloc(1, sizeof(Area
)));
74 // tint2 could reload config, so we cleanup objects
82 // panel's default value
83 if (panel_config
.g_task
.font_desc
) {
84 pango_font_description_free(panel_config
.g_task
.font_desc
);
86 memset(&panel_config
, 0, sizeof(Panel
));
87 panel_config
.g_task
.alpha
= 100;
88 panel_config
.g_task
.alpha_active
= 100;
91 // window manager's menu default value == false
95 // flush pango cache if possible
96 //pango_xft_shutdown_display(server.dsp, server.screen);
97 //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
98 //pango_fc_font_map_shutdown(font_map);
102 void cleanup_config()
104 // cleanup background list
106 for (l0
= list_back
; l0
; l0
= l0
->next
) {
109 g_slist_free(list_back
);
114 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
118 if (*value1
) free (*value1
);
119 if (*value2
) free (*value2
);
120 if (*value3
) free (*value3
);
122 if ((b
= strchr (value
, ' '))) {
130 *value1
= strdup (value
);
134 if ((c
= strchr (b
, ' '))) {
142 *value2
= strdup (b
);
147 *value3
= strdup (c
);
153 void get_action (char *event
, int *action
)
155 if (strcmp (event
, "none") == 0)
157 else if (strcmp (event
, "close") == 0)
159 else if (strcmp (event
, "toggle") == 0)
161 else if (strcmp (event
, "iconify") == 0)
163 else if (strcmp (event
, "shade") == 0)
165 else if (strcmp (event
, "toggle_iconify") == 0)
166 *action
= TOGGLE_ICONIFY
;
167 else if (strcmp (event
, "maximize_restore") == 0)
168 *action
= MAXIMIZE_RESTORE
;
169 else if (strcmp (event
, "desktop_left") == 0)
170 *action
= DESKTOP_LEFT
;
171 else if (strcmp (event
, "desktop_right") == 0)
172 *action
= DESKTOP_RIGHT
;
176 void add_entry (char *key
, char *value
)
178 char *value1
=0, *value2
=0, *value3
=0;
180 /* Background and border */
181 if (strcmp (key
, "rounded") == 0) {
182 // 'rounded' is the first parameter => alloc a new background
183 Area
*a
= calloc(1, sizeof(Area
));
184 a
->pix
.border
.rounded
= atoi (value
);
185 list_back
= g_slist_append(list_back
, a
);
187 else if (strcmp (key
, "border_width") == 0) {
188 Area
*a
= g_slist_last(list_back
)->data
;
189 a
->pix
.border
.width
= atoi (value
);
191 else if (strcmp (key
, "background_color") == 0) {
192 Area
*a
= g_slist_last(list_back
)->data
;
193 extract_values(value
, &value1
, &value2
, &value3
);
194 get_color (value1
, a
->pix
.back
.color
);
195 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
196 else a
->pix
.back
.alpha
= 0.5;
198 else if (strcmp (key
, "border_color") == 0) {
199 Area
*a
= g_slist_last(list_back
)->data
;
200 extract_values(value
, &value1
, &value2
, &value3
);
201 get_color (value1
, a
->pix
.border
.color
);
202 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
203 else a
->pix
.border
.alpha
= 0.5;
207 else if (strcmp (key
, "panel_monitor") == 0) {
208 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
210 panel_config
.monitor
= atoi (value
);
211 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
213 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
214 // server.nb_monitor minimum value is 1 (see get_monitors())
215 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
216 panel_config
.monitor
= 0;
219 else if (strcmp (key
, "panel_size") == 0) {
220 extract_values(value
, &value1
, &value2
, &value3
);
223 if ((b
= strchr (value1
, '%'))) {
225 panel_config
.pourcentx
= 1;
227 panel_config
.area
.width
= atoi(value1
);
228 if (panel_config
.area
.width
== 0) {
230 panel_config
.area
.width
= 100;
231 panel_config
.pourcentx
= 1;
234 if ((b
= strchr (value2
, '%'))) {
236 panel_config
.pourcenty
= 1;
238 panel_config
.area
.height
= atoi(value2
);
241 else if (strcmp (key
, "panel_margin") == 0) {
242 extract_values(value
, &value1
, &value2
, &value3
);
243 panel_config
.marginx
= atoi (value1
);
244 if (value2
) panel_config
.marginy
= atoi (value2
);
246 else if (strcmp (key
, "panel_padding") == 0) {
247 extract_values(value
, &value1
, &value2
, &value3
);
248 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
249 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
250 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
252 else if (strcmp (key
, "panel_position") == 0) {
253 extract_values(value
, &value1
, &value2
, &value3
);
254 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
256 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
257 else panel_position
= CENTER
;
260 if (!value2
) panel_position
|= CENTER
;
262 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
264 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
265 else panel_position
|= CENTER
;
268 if (!value3
) panel_horizontal
= 1;
270 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
271 else panel_horizontal
= 1;
274 else if (strcmp (key
, "font_shadow") == 0)
275 panel_config
.g_task
.font_shadow
= atoi (value
);
276 else if (strcmp (key
, "panel_background_id") == 0) {
277 int id
= atoi (value
);
278 Area
*a
= g_slist_nth_data(list_back
, id
);
279 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
280 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
282 else if (strcmp (key
, "wm_menu") == 0)
283 wm_menu
= atoi (value
);
284 else if (strcmp (key
, "panel_dock") == 0)
285 panel_dock
= atoi (value
);
286 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
287 max_tick_urgent
= (atoi (value
) * 2) + 1;
290 else if (strcmp (key
, "battery") == 0) {
291 #ifdef ENABLE_BATTERY
296 fprintf(stderr
, "tint2 is build without battery support\n");
299 else if (strcmp (key
, "battery_low_status") == 0) {
300 #ifdef ENABLE_BATTERY
301 battery_low_status
= atoi(value
);
302 if(battery_low_status
< 0 || battery_low_status
> 100)
303 battery_low_status
= 0;
306 else if (strcmp (key
, "battery_low_cmd") == 0) {
307 #ifdef ENABLE_BATTERY
308 if (strlen(value
) > 0)
309 battery_low_cmd
= strdup (value
);
312 else if (strcmp (key
, "bat1_font") == 0) {
313 #ifdef ENABLE_BATTERY
314 bat1_font_desc
= pango_font_description_from_string (value
);
317 else if (strcmp (key
, "bat2_font") == 0) {
318 #ifdef ENABLE_BATTERY
319 bat2_font_desc
= pango_font_description_from_string (value
);
322 else if (strcmp (key
, "battery_font_color") == 0) {
323 #ifdef ENABLE_BATTERY
324 extract_values(value
, &value1
, &value2
, &value3
);
325 get_color (value1
, panel_config
.battery
.font
.color
);
326 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
327 else panel_config
.battery
.font
.alpha
= 0.5;
330 else if (strcmp (key
, "battery_padding") == 0) {
331 #ifdef ENABLE_BATTERY
332 extract_values(value
, &value1
, &value2
, &value3
);
333 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
334 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
335 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
338 else if (strcmp (key
, "battery_background_id") == 0) {
339 #ifdef ENABLE_BATTERY
340 int id
= atoi (value
);
341 Area
*a
= g_slist_nth_data(list_back
, id
);
342 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
343 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
348 else if (strcmp (key
, "time1_format") == 0) {
349 if (strlen(value
) > 0) {
350 time1_format
= strdup (value
);
354 else if (strcmp (key
, "time2_format") == 0) {
355 if (strlen(value
) > 0)
356 time2_format
= strdup (value
);
358 else if (strcmp (key
, "time1_font") == 0) {
359 time1_font_desc
= pango_font_description_from_string (value
);
361 else if (strcmp (key
, "time2_font") == 0) {
362 time2_font_desc
= pango_font_description_from_string (value
);
364 else if (strcmp (key
, "clock_font_color") == 0) {
365 extract_values(value
, &value1
, &value2
, &value3
);
366 get_color (value1
, panel_config
.clock
.font
.color
);
367 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
368 else panel_config
.clock
.font
.alpha
= 0.5;
370 else if (strcmp (key
, "clock_padding") == 0) {
371 extract_values(value
, &value1
, &value2
, &value3
);
372 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
373 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
374 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
376 else if (strcmp (key
, "clock_background_id") == 0) {
377 int id
= atoi (value
);
378 Area
*a
= g_slist_nth_data(list_back
, id
);
379 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
380 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
382 else if (strcmp(key
, "clock_lclick_command") == 0) {
383 if (strlen(value
) > 0)
384 clock_lclick_command
= strdup(value
);
386 else if (strcmp(key
, "clock_rclick_command") == 0) {
387 if (strlen(value
) > 0)
388 clock_rclick_command
= strdup(value
);
392 else if (strcmp (key
, "taskbar_mode") == 0) {
393 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
394 else panel_mode
= SINGLE_DESKTOP
;
396 else if (strcmp (key
, "taskbar_padding") == 0) {
397 extract_values(value
, &value1
, &value2
, &value3
);
398 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
399 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
400 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
402 else if (strcmp (key
, "taskbar_background_id") == 0) {
403 int id
= atoi (value
);
404 Area
*a
= g_slist_nth_data(list_back
, id
);
405 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
406 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
408 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
409 int id
= atoi (value
);
410 Area
*a
= g_slist_nth_data(list_back
, id
);
411 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
412 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
413 panel_config
.g_taskbar
.use_active
= 1;
417 else if (strcmp (key
, "task_text") == 0)
418 panel_config
.g_task
.text
= atoi (value
);
419 else if (strcmp (key
, "task_icon") == 0)
420 panel_config
.g_task
.icon
= atoi (value
);
421 else if (strcmp (key
, "task_centered") == 0)
422 panel_config
.g_task
.centered
= atoi (value
);
423 else if (strcmp (key
, "task_width") == 0) {
424 // old parameter : just for backward compatibility
425 panel_config
.g_task
.maximum_width
= atoi (value
);
426 panel_config
.g_task
.maximum_height
= 30;
428 else if (strcmp (key
, "task_maximum_size") == 0) {
429 extract_values(value
, &value1
, &value2
, &value3
);
430 panel_config
.g_task
.maximum_width
= atoi (value1
);
431 panel_config
.g_task
.maximum_height
= 30;
433 panel_config
.g_task
.maximum_height
= atoi (value2
);
435 else if (strcmp (key
, "task_padding") == 0) {
436 extract_values(value
, &value1
, &value2
, &value3
);
437 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
438 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
439 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
441 else if (strcmp (key
, "task_font") == 0) {
442 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
444 else if (strcmp (key
, "task_font_color") == 0) {
445 extract_values(value
, &value1
, &value2
, &value3
);
446 get_color (value1
, panel_config
.g_task
.font
.color
);
447 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
448 else panel_config
.g_task
.font
.alpha
= 0.1;
450 else if (strcmp (key
, "task_active_font_color") == 0) {
451 extract_values(value
, &value1
, &value2
, &value3
);
452 get_color (value1
, panel_config
.g_task
.font_active
.color
);
453 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
454 else panel_config
.g_task
.font_active
.alpha
= 0.1;
456 else if (strcmp (key
, "task_icon_asb") == 0) {
457 extract_values(value
, &value1
, &value2
, &value3
);
458 panel_config
.g_task
.alpha
= atoi(value1
);
459 panel_config
.g_task
.saturation
= atoi(value2
);
460 panel_config
.g_task
.brightness
= atoi(value3
);
462 else if (strcmp (key
, "task_active_icon_asb") == 0) {
463 extract_values(value
, &value1
, &value2
, &value3
);
464 panel_config
.g_task
.alpha_active
= atoi(value1
);
465 panel_config
.g_task
.saturation_active
= atoi(value2
);
466 panel_config
.g_task
.brightness_active
= atoi(value3
);
468 else if (strcmp (key
, "task_background_id") == 0) {
469 int id
= atoi (value
);
470 Area
*a
= g_slist_nth_data(list_back
, id
);
471 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
472 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
474 else if (strcmp (key
, "task_active_background_id") == 0) {
475 int id
= atoi (value
);
476 Area
*a
= g_slist_nth_data(list_back
, id
);
477 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
478 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
482 else if (strcmp (key
, "systray") == 0) {
486 else if (strcmp (key
, "systray_padding") == 0) {
487 extract_values(value
, &value1
, &value2
, &value3
);
488 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
489 if (value2
) systray
.area
.paddingy
= atoi (value2
);
490 if (value3
) systray
.area
.paddingx
= atoi (value3
);
492 else if (strcmp (key
, "systray_background_id") == 0) {
493 int id
= atoi (value
);
494 Area
*a
= g_slist_nth_data(list_back
, id
);
495 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
496 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
498 else if (strcmp(key
, "systray_sort") == 0) {
499 if (strcmp(value
, "descending") == 0)
501 else if (strcmp(value
, "ascending") == 0)
503 else if (strcmp(value
, "left2right") == 0)
505 else if (strcmp(value
, "right2left") == 0)
510 else if (strcmp (key
, "tooltip") == 0)
511 g_tooltip
.enabled
= atoi(value
);
512 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
513 double timeout
= atof(value
);
514 int sec
= (int)timeout
;
515 int usec
= (timeout
-sec
)*1e6
;
516 g_tooltip
.show_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
518 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
519 double timeout
= atof(value
);
520 int sec
= (int)timeout
;
521 int usec
= (timeout
-sec
)*1e6
;
522 g_tooltip
.hide_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
524 else if (strcmp (key
, "tooltip_padding") == 0) {
525 extract_values(value
, &value1
, &value2
, &value3
);
526 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
527 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
529 else if (strcmp (key
, "tooltip_background_id") == 0) {
530 int id
= atoi (value
);
531 Area
*a
= g_slist_nth_data(list_back
, id
);
532 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
533 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
535 else if (strcmp (key
, "tooltip_font_color") == 0) {
536 extract_values(value
, &value1
, &value2
, &value3
);
537 get_color(value1
, g_tooltip
.font_color
.color
);
538 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
539 else g_tooltip
.font_color
.alpha
= 0.1;
541 else if (strcmp (key
, "tooltip_font") == 0) {
542 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
546 else if (strcmp (key
, "mouse_middle") == 0)
547 get_action (value
, &mouse_middle
);
548 else if (strcmp (key
, "mouse_right") == 0)
549 get_action (value
, &mouse_right
);
550 else if (strcmp (key
, "mouse_scroll_up") == 0)
551 get_action (value
, &mouse_scroll_up
);
552 else if (strcmp (key
, "mouse_scroll_down") == 0)
553 get_action (value
, &mouse_scroll_down
);
556 /* Read tint-0.6 config for backward compatibility */
557 else if (strcmp (key
, "panel_mode") == 0) {
558 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
559 else panel_mode
= MULTI_DESKTOP
;
561 else if (strcmp (key
, "panel_rounded") == 0) {
562 Area
*a
= calloc(1, sizeof(Area
));
563 a
->pix
.border
.rounded
= atoi (value
);
564 list_back
= g_slist_append(list_back
, a
);
566 else if (strcmp (key
, "panel_border_width") == 0) {
567 Area
*a
= g_slist_last(list_back
)->data
;
568 a
->pix
.border
.width
= atoi (value
);
570 else if (strcmp (key
, "panel_background_color") == 0) {
571 Area
*a
= g_slist_last(list_back
)->data
;
572 extract_values(value
, &value1
, &value2
, &value3
);
573 get_color (value1
, a
->pix
.back
.color
);
574 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
575 else a
->pix
.back
.alpha
= 0.5;
577 else if (strcmp (key
, "panel_border_color") == 0) {
578 Area
*a
= g_slist_last(list_back
)->data
;
579 extract_values(value
, &value1
, &value2
, &value3
);
580 get_color (value1
, a
->pix
.border
.color
);
581 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
582 else a
->pix
.border
.alpha
= 0.5;
584 else if (strcmp (key
, "task_text_centered") == 0)
585 panel_config
.g_task
.centered
= atoi (value
);
586 else if (strcmp (key
, "task_margin") == 0) {
587 panel_config
.g_taskbar
.paddingxlr
= 0;
588 panel_config
.g_taskbar
.paddingx
= atoi (value
);
590 else if (strcmp (key
, "task_icon_size") == 0)
591 old_task_icon_size
= atoi (value
);
592 else if (strcmp (key
, "task_rounded") == 0) {
593 area_task
= calloc(1, sizeof(Area
));
594 area_task
->pix
.border
.rounded
= atoi (value
);
595 list_back
= g_slist_append(list_back
, area_task
);
597 area_task_active
= calloc(1, sizeof(Area
));
598 area_task_active
->pix
.border
.rounded
= atoi (value
);
599 list_back
= g_slist_append(list_back
, area_task_active
);
601 else if (strcmp (key
, "task_background_color") == 0) {
602 extract_values(value
, &value1
, &value2
, &value3
);
603 get_color (value1
, area_task
->pix
.back
.color
);
604 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
605 else area_task
->pix
.back
.alpha
= 0.5;
607 else if (strcmp (key
, "task_active_background_color") == 0) {
608 extract_values(value
, &value1
, &value2
, &value3
);
609 get_color (value1
, area_task_active
->pix
.back
.color
);
610 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
611 else area_task_active
->pix
.back
.alpha
= 0.5;
613 else if (strcmp (key
, "task_border_width") == 0) {
614 area_task
->pix
.border
.width
= atoi (value
);
615 area_task_active
->pix
.border
.width
= atoi (value
);
617 else if (strcmp (key
, "task_border_color") == 0) {
618 extract_values(value
, &value1
, &value2
, &value3
);
619 get_color (value1
, area_task
->pix
.border
.color
);
620 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
621 else area_task
->pix
.border
.alpha
= 0.5;
623 else if (strcmp (key
, "task_active_border_color") == 0) {
624 extract_values(value
, &value1
, &value2
, &value3
);
625 get_color (value1
, area_task_active
->pix
.border
.color
);
626 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
627 else area_task_active
->pix
.border
.alpha
= 0.5;
631 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
633 if (value1
) free (value1
);
634 if (value2
) free (value2
);
635 if (value3
) free (value3
);
641 const gchar
* const * system_dirs
;
645 // follow XDG specification
646 // check tint2rc in user directory
647 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
648 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
649 i
= config_read_file (path1
);
650 config_path
= strdup(path1
);
656 // copy tint2rc from system directory to user directory
658 system_dirs
= g_get_system_config_dirs();
659 for (i
= 0; system_dirs
[i
]; i
++) {
660 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
662 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
668 // copy file in user directory (path1)
669 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
670 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
673 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
674 copy_file(path2
, path1
);
677 i
= config_read_file (path1
);
678 config_path
= strdup(path1
);
686 int config_read_file (const char *path
)
692 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
694 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
695 if (parse_line(line
, &key
, &value
)) {
696 add_entry (key
, value
);
703 if (old_task_icon_size
) {
704 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.07121 seconds and 5 git commands to generate.