]>
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
85 // panel's default value
86 if (panel_config
.g_task
.font_desc
) {
87 pango_font_description_free(panel_config
.g_task
.font_desc
);
89 memset(&panel_config
, 0, sizeof(Panel
));
90 panel_config
.g_task
.alpha
= 100;
91 panel_config
.g_task
.alpha_active
= 100;
95 // window manager's menu default value == false
99 // flush pango cache if possible
100 //pango_xft_shutdown_display(server.dsp, server.screen);
101 //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
102 //pango_fc_font_map_shutdown(font_map);
106 void cleanup_config()
108 // cleanup background list
110 for (l0
= list_back
; l0
; l0
= l0
->next
) {
113 g_slist_free(list_back
);
118 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
122 if (*value1
) free (*value1
);
123 if (*value2
) free (*value2
);
124 if (*value3
) free (*value3
);
126 if ((b
= strchr (value
, ' '))) {
134 *value1
= strdup (value
);
138 if ((c
= strchr (b
, ' '))) {
146 *value2
= strdup (b
);
151 *value3
= strdup (c
);
157 void get_action (char *event
, int *action
)
159 if (strcmp (event
, "none") == 0)
161 else if (strcmp (event
, "close") == 0)
163 else if (strcmp (event
, "toggle") == 0)
165 else if (strcmp (event
, "iconify") == 0)
167 else if (strcmp (event
, "shade") == 0)
169 else if (strcmp (event
, "toggle_iconify") == 0)
170 *action
= TOGGLE_ICONIFY
;
171 else if (strcmp (event
, "maximize_restore") == 0)
172 *action
= MAXIMIZE_RESTORE
;
173 else if (strcmp (event
, "desktop_left") == 0)
174 *action
= DESKTOP_LEFT
;
175 else if (strcmp (event
, "desktop_right") == 0)
176 *action
= DESKTOP_RIGHT
;
177 else if (strcmp (event
, "next_task") == 0)
179 else if (strcmp (event
, "prev_task") == 0)
184 void add_entry (char *key
, char *value
)
186 char *value1
=0, *value2
=0, *value3
=0;
188 /* Background and border */
189 if (strcmp (key
, "rounded") == 0) {
190 // 'rounded' is the first parameter => alloc a new background
191 Area
*a
= calloc(1, sizeof(Area
));
192 a
->pix
.border
.rounded
= atoi (value
);
193 list_back
= g_slist_append(list_back
, a
);
195 else if (strcmp (key
, "border_width") == 0) {
196 Area
*a
= g_slist_last(list_back
)->data
;
197 a
->pix
.border
.width
= atoi (value
);
199 else if (strcmp (key
, "background_color") == 0) {
200 Area
*a
= g_slist_last(list_back
)->data
;
201 extract_values(value
, &value1
, &value2
, &value3
);
202 get_color (value1
, a
->pix
.back
.color
);
203 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
204 else a
->pix
.back
.alpha
= 0.5;
206 else if (strcmp (key
, "border_color") == 0) {
207 Area
*a
= g_slist_last(list_back
)->data
;
208 extract_values(value
, &value1
, &value2
, &value3
);
209 get_color (value1
, a
->pix
.border
.color
);
210 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
211 else a
->pix
.border
.alpha
= 0.5;
215 else if (strcmp (key
, "panel_monitor") == 0) {
216 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
218 panel_config
.monitor
= atoi (value
);
219 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
221 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
222 // server.nb_monitor minimum value is 1 (see get_monitors())
223 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
224 panel_config
.monitor
= 0;
227 else if (strcmp (key
, "panel_size") == 0) {
228 extract_values(value
, &value1
, &value2
, &value3
);
231 if ((b
= strchr (value1
, '%'))) {
233 panel_config
.pourcentx
= 1;
235 panel_config
.area
.width
= atoi(value1
);
236 if (panel_config
.area
.width
== 0) {
238 panel_config
.area
.width
= 100;
239 panel_config
.pourcentx
= 1;
242 if ((b
= strchr (value2
, '%'))) {
244 panel_config
.pourcenty
= 1;
246 panel_config
.area
.height
= atoi(value2
);
249 else if (strcmp (key
, "panel_margin") == 0) {
250 extract_values(value
, &value1
, &value2
, &value3
);
251 panel_config
.marginx
= atoi (value1
);
252 if (value2
) panel_config
.marginy
= atoi (value2
);
254 else if (strcmp (key
, "panel_padding") == 0) {
255 extract_values(value
, &value1
, &value2
, &value3
);
256 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
257 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
258 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
260 else if (strcmp (key
, "panel_position") == 0) {
261 extract_values(value
, &value1
, &value2
, &value3
);
262 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
264 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
265 else panel_position
= CENTER
;
268 if (!value2
) panel_position
|= CENTER
;
270 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
272 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
273 else panel_position
|= CENTER
;
276 if (!value3
) panel_horizontal
= 1;
278 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
279 else panel_horizontal
= 1;
282 else if (strcmp (key
, "font_shadow") == 0)
283 panel_config
.g_task
.font_shadow
= atoi (value
);
284 else if (strcmp (key
, "panel_background_id") == 0) {
285 int id
= atoi (value
);
286 Area
*a
= g_slist_nth_data(list_back
, id
);
287 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
288 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
290 else if (strcmp (key
, "wm_menu") == 0)
291 wm_menu
= atoi (value
);
292 else if (strcmp (key
, "panel_dock") == 0)
293 panel_dock
= atoi (value
);
294 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
295 max_tick_urgent
= (atoi (value
) * 2) + 1;
296 else if (strcmp (key
, "real_transparency") == 0)
297 real_transparency
= atoi(value
);
298 else if (strcmp (key
, "panel_layer") == 0) {
299 if (strcmp(value
, "bottom") == 0)
300 panel_layer
= BOTTOM_LAYER
;
301 else if (strcmp(value
, "normal") == 0)
302 panel_layer
= NORMAL_LAYER
;
303 else if (strcmp(value
, "top") == 0)
304 panel_layer
= TOP_LAYER
;
308 else if (strcmp (key
, "battery") == 0) {
309 #ifdef ENABLE_BATTERY
314 fprintf(stderr
, "tint2 is build without battery support\n");
317 else if (strcmp (key
, "battery_low_status") == 0) {
318 #ifdef ENABLE_BATTERY
319 battery_low_status
= atoi(value
);
320 if(battery_low_status
< 0 || battery_low_status
> 100)
321 battery_low_status
= 0;
324 else if (strcmp (key
, "battery_low_cmd") == 0) {
325 #ifdef ENABLE_BATTERY
326 if (strlen(value
) > 0)
327 battery_low_cmd
= strdup (value
);
330 else if (strcmp (key
, "bat1_font") == 0) {
331 #ifdef ENABLE_BATTERY
332 bat1_font_desc
= pango_font_description_from_string (value
);
335 else if (strcmp (key
, "bat2_font") == 0) {
336 #ifdef ENABLE_BATTERY
337 bat2_font_desc
= pango_font_description_from_string (value
);
340 else if (strcmp (key
, "battery_font_color") == 0) {
341 #ifdef ENABLE_BATTERY
342 extract_values(value
, &value1
, &value2
, &value3
);
343 get_color (value1
, panel_config
.battery
.font
.color
);
344 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
345 else panel_config
.battery
.font
.alpha
= 0.5;
348 else if (strcmp (key
, "battery_padding") == 0) {
349 #ifdef ENABLE_BATTERY
350 extract_values(value
, &value1
, &value2
, &value3
);
351 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
352 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
353 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
356 else if (strcmp (key
, "battery_background_id") == 0) {
357 #ifdef ENABLE_BATTERY
358 int id
= atoi (value
);
359 Area
*a
= g_slist_nth_data(list_back
, id
);
360 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
361 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
366 else if (strcmp (key
, "time1_format") == 0) {
367 if (strlen(value
) > 0) {
368 time1_format
= strdup (value
);
372 else if (strcmp (key
, "time2_format") == 0) {
373 if (strlen(value
) > 0)
374 time2_format
= strdup (value
);
376 else if (strcmp (key
, "time1_font") == 0) {
377 time1_font_desc
= pango_font_description_from_string (value
);
379 else if (strcmp(key
, "time1_timezone") == 0) {
380 if (strlen(value
) > 0)
381 time1_timezone
= strdup(value
);
383 else if (strcmp(key
, "time2_timezone") == 0) {
384 if (strlen(value
) > 0)
385 time2_timezone
= strdup(value
);
387 else if (strcmp (key
, "time2_font") == 0) {
388 time2_font_desc
= pango_font_description_from_string (value
);
390 else if (strcmp (key
, "clock_font_color") == 0) {
391 extract_values(value
, &value1
, &value2
, &value3
);
392 get_color (value1
, panel_config
.clock
.font
.color
);
393 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
394 else panel_config
.clock
.font
.alpha
= 0.5;
396 else if (strcmp (key
, "clock_padding") == 0) {
397 extract_values(value
, &value1
, &value2
, &value3
);
398 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
399 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
400 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
402 else if (strcmp (key
, "clock_background_id") == 0) {
403 int id
= atoi (value
);
404 Area
*a
= g_slist_nth_data(list_back
, id
);
405 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
406 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
408 else if (strcmp(key
, "clock_tooltip") == 0) {
409 if (strlen(value
) > 0)
410 time_tooltip_format
= strdup (value
);
412 else if (strcmp(key
, "clock_tooltip_timezone") == 0) {
413 if (strlen(value
) > 0)
414 time_tooltip_timezone
= strdup(value
);
416 else if (strcmp(key
, "clock_lclick_command") == 0) {
417 if (strlen(value
) > 0)
418 clock_lclick_command
= strdup(value
);
420 else if (strcmp(key
, "clock_rclick_command") == 0) {
421 if (strlen(value
) > 0)
422 clock_rclick_command
= strdup(value
);
426 else if (strcmp (key
, "taskbar_mode") == 0) {
427 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
428 else panel_mode
= SINGLE_DESKTOP
;
430 else if (strcmp (key
, "taskbar_padding") == 0) {
431 extract_values(value
, &value1
, &value2
, &value3
);
432 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
433 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
434 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
436 else if (strcmp (key
, "taskbar_background_id") == 0) {
437 int id
= atoi (value
);
438 Area
*a
= g_slist_nth_data(list_back
, id
);
439 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
440 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
442 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
443 int id
= atoi (value
);
444 Area
*a
= g_slist_nth_data(list_back
, id
);
445 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
446 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
447 panel_config
.g_taskbar
.use_active
= 1;
451 else if (strcmp (key
, "task_text") == 0)
452 panel_config
.g_task
.text
= atoi (value
);
453 else if (strcmp (key
, "task_icon") == 0)
454 panel_config
.g_task
.icon
= atoi (value
);
455 else if (strcmp (key
, "task_centered") == 0)
456 panel_config
.g_task
.centered
= atoi (value
);
457 else if (strcmp (key
, "task_width") == 0) {
458 // old parameter : just for backward compatibility
459 panel_config
.g_task
.maximum_width
= atoi (value
);
460 panel_config
.g_task
.maximum_height
= 30;
462 else if (strcmp (key
, "task_maximum_size") == 0) {
463 extract_values(value
, &value1
, &value2
, &value3
);
464 panel_config
.g_task
.maximum_width
= atoi (value1
);
465 panel_config
.g_task
.maximum_height
= 30;
467 panel_config
.g_task
.maximum_height
= atoi (value2
);
469 else if (strcmp (key
, "task_padding") == 0) {
470 extract_values(value
, &value1
, &value2
, &value3
);
471 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
472 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
473 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
475 else if (strcmp (key
, "task_font") == 0) {
476 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
478 else if (strcmp (key
, "task_font_color") == 0) {
479 extract_values(value
, &value1
, &value2
, &value3
);
480 get_color (value1
, panel_config
.g_task
.font
.color
);
481 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
482 else panel_config
.g_task
.font
.alpha
= 0.1;
484 else if (strcmp (key
, "task_active_font_color") == 0) {
485 extract_values(value
, &value1
, &value2
, &value3
);
486 get_color (value1
, panel_config
.g_task
.font_active
.color
);
487 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
488 else panel_config
.g_task
.font_active
.alpha
= 0.1;
490 else if (strcmp (key
, "task_icon_asb") == 0) {
491 extract_values(value
, &value1
, &value2
, &value3
);
492 panel_config
.g_task
.alpha
= atoi(value1
);
493 panel_config
.g_task
.saturation
= atoi(value2
);
494 panel_config
.g_task
.brightness
= atoi(value3
);
496 else if (strcmp (key
, "task_active_icon_asb") == 0) {
497 extract_values(value
, &value1
, &value2
, &value3
);
498 panel_config
.g_task
.alpha_active
= atoi(value1
);
499 panel_config
.g_task
.saturation_active
= atoi(value2
);
500 panel_config
.g_task
.brightness_active
= atoi(value3
);
502 else if (strcmp (key
, "task_background_id") == 0) {
503 int id
= atoi (value
);
504 Area
*a
= g_slist_nth_data(list_back
, id
);
505 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
506 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
508 else if (strcmp (key
, "task_active_background_id") == 0) {
509 int id
= atoi (value
);
510 Area
*a
= g_slist_nth_data(list_back
, id
);
511 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
512 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
516 else if (strcmp (key
, "systray") == 0) {
517 systray_enabled
= atoi(value
);
518 // systray is latest option added. files without 'systray' are old.
521 else if (strcmp (key
, "systray_padding") == 0) {
524 extract_values(value
, &value1
, &value2
, &value3
);
525 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
526 if (value2
) systray
.area
.paddingy
= atoi (value2
);
527 if (value3
) systray
.area
.paddingx
= atoi (value3
);
529 else if (strcmp (key
, "systray_background_id") == 0) {
530 int id
= atoi (value
);
531 Area
*a
= g_slist_nth_data(list_back
, id
);
532 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
533 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
535 else if (strcmp(key
, "systray_sort") == 0) {
536 if (strcmp(value
, "descending") == 0)
538 else if (strcmp(value
, "ascending") == 0)
540 else if (strcmp(value
, "left2right") == 0)
542 else if (strcmp(value
, "right2left") == 0)
547 else if (strcmp (key
, "tooltip") == 0)
548 g_tooltip
.enabled
= atoi(value
);
549 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
550 int timeout_msec
= 1000*atof(value
);
551 g_tooltip
.show_timeout_msec
= timeout_msec
;
553 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
554 int timeout_msec
= 1000*atof(value
);
555 g_tooltip
.hide_timeout_msec
= timeout_msec
;
557 else if (strcmp (key
, "tooltip_padding") == 0) {
558 extract_values(value
, &value1
, &value2
, &value3
);
559 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
560 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
562 else if (strcmp (key
, "tooltip_background_id") == 0) {
563 int id
= atoi (value
);
564 Area
*a
= g_slist_nth_data(list_back
, id
);
565 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
566 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
568 else if (strcmp (key
, "tooltip_font_color") == 0) {
569 extract_values(value
, &value1
, &value2
, &value3
);
570 get_color(value1
, g_tooltip
.font_color
.color
);
571 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
572 else g_tooltip
.font_color
.alpha
= 0.1;
574 else if (strcmp (key
, "tooltip_font") == 0) {
575 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
579 else if (strcmp (key
, "mouse_middle") == 0)
580 get_action (value
, &mouse_middle
);
581 else if (strcmp (key
, "mouse_right") == 0)
582 get_action (value
, &mouse_right
);
583 else if (strcmp (key
, "mouse_scroll_up") == 0)
584 get_action (value
, &mouse_scroll_up
);
585 else if (strcmp (key
, "mouse_scroll_down") == 0)
586 get_action (value
, &mouse_scroll_down
);
589 /* Read tint-0.6 config for backward compatibility */
590 else if (strcmp (key
, "panel_mode") == 0) {
591 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
592 else panel_mode
= MULTI_DESKTOP
;
594 else if (strcmp (key
, "panel_rounded") == 0) {
595 Area
*a
= calloc(1, sizeof(Area
));
596 a
->pix
.border
.rounded
= atoi (value
);
597 list_back
= g_slist_append(list_back
, a
);
599 else if (strcmp (key
, "panel_border_width") == 0) {
600 Area
*a
= g_slist_last(list_back
)->data
;
601 a
->pix
.border
.width
= atoi (value
);
603 else if (strcmp (key
, "panel_background_color") == 0) {
604 Area
*a
= g_slist_last(list_back
)->data
;
605 extract_values(value
, &value1
, &value2
, &value3
);
606 get_color (value1
, a
->pix
.back
.color
);
607 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
608 else a
->pix
.back
.alpha
= 0.5;
610 else if (strcmp (key
, "panel_border_color") == 0) {
611 Area
*a
= g_slist_last(list_back
)->data
;
612 extract_values(value
, &value1
, &value2
, &value3
);
613 get_color (value1
, a
->pix
.border
.color
);
614 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
615 else a
->pix
.border
.alpha
= 0.5;
617 else if (strcmp (key
, "task_text_centered") == 0)
618 panel_config
.g_task
.centered
= atoi (value
);
619 else if (strcmp (key
, "task_margin") == 0) {
620 panel_config
.g_taskbar
.paddingxlr
= 0;
621 panel_config
.g_taskbar
.paddingx
= atoi (value
);
623 else if (strcmp (key
, "task_icon_size") == 0)
624 old_task_icon_size
= atoi (value
);
625 else if (strcmp (key
, "task_rounded") == 0) {
626 area_task
= calloc(1, sizeof(Area
));
627 area_task
->pix
.border
.rounded
= atoi (value
);
628 list_back
= g_slist_append(list_back
, area_task
);
630 area_task_active
= calloc(1, sizeof(Area
));
631 area_task_active
->pix
.border
.rounded
= atoi (value
);
632 list_back
= g_slist_append(list_back
, area_task_active
);
634 else if (strcmp (key
, "task_background_color") == 0) {
635 extract_values(value
, &value1
, &value2
, &value3
);
636 get_color (value1
, area_task
->pix
.back
.color
);
637 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
638 else area_task
->pix
.back
.alpha
= 0.5;
640 else if (strcmp (key
, "task_active_background_color") == 0) {
641 extract_values(value
, &value1
, &value2
, &value3
);
642 get_color (value1
, area_task_active
->pix
.back
.color
);
643 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
644 else area_task_active
->pix
.back
.alpha
= 0.5;
646 else if (strcmp (key
, "task_border_width") == 0) {
647 area_task
->pix
.border
.width
= atoi (value
);
648 area_task_active
->pix
.border
.width
= atoi (value
);
650 else if (strcmp (key
, "task_border_color") == 0) {
651 extract_values(value
, &value1
, &value2
, &value3
);
652 get_color (value1
, area_task
->pix
.border
.color
);
653 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
654 else area_task
->pix
.border
.alpha
= 0.5;
656 else if (strcmp (key
, "task_active_border_color") == 0) {
657 extract_values(value
, &value1
, &value2
, &value3
);
658 get_color (value1
, area_task_active
->pix
.border
.color
);
659 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
660 else area_task_active
->pix
.border
.alpha
= 0.5;
664 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
666 if (value1
) free (value1
);
667 if (value2
) free (value2
);
668 if (value3
) free (value3
);
674 const gchar
* const * system_dirs
;
678 // follow XDG specification
679 // check tint2rc in user directory
680 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
681 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
682 i
= config_read_file (path1
);
683 config_path
= strdup(path1
);
689 // copy tint2rc from system directory to user directory
691 system_dirs
= g_get_system_config_dirs();
692 for (i
= 0; system_dirs
[i
]; i
++) {
693 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
695 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
701 // copy file in user directory (path1)
702 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
703 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
706 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
707 copy_file(path2
, path1
);
710 i
= config_read_file (path1
);
711 config_path
= strdup(path1
);
719 int config_read_file (const char *path
)
725 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
727 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
728 if (parse_line(line
, &key
, &value
)) {
729 add_entry (key
, value
);
736 if (old_task_icon_size
) {
737 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.074112 seconds and 4 git commands to generate.