]>
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 Area
*area_task
;
60 static Area
*area_task_active
;
63 // temporary list of background
64 static GSList
*list_back
;
70 // append full transparency background
71 list_back
= g_slist_append(0, calloc(1, sizeof(Area
)));
73 // tint2 could reload config, so we cleanup objects
79 // panel's default value
80 if (panel_config
.g_task
.font_desc
) {
81 pango_font_description_free(panel_config
.g_task
.font_desc
);
83 memset(&panel_config
, 0, sizeof(Panel
));
84 panel_config
.g_task
.alpha
= 100;
85 panel_config
.g_task
.alpha_active
= 100;
88 // window manager's menu default value == false
96 // cleanup background list
98 for (l0
= list_back
; l0
; l0
= l0
->next
) {
101 g_slist_free(list_back
);
106 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
110 if (*value1
) free (*value1
);
111 if (*value2
) free (*value2
);
112 if (*value3
) free (*value3
);
114 if ((b
= strchr (value
, ' '))) {
122 *value1
= strdup (value
);
126 if ((c
= strchr (b
, ' '))) {
134 *value2
= strdup (b
);
139 *value3
= strdup (c
);
145 void get_action (char *event
, int *action
)
147 if (strcmp (event
, "none") == 0)
149 else if (strcmp (event
, "close") == 0)
151 else if (strcmp (event
, "toggle") == 0)
153 else if (strcmp (event
, "iconify") == 0)
155 else if (strcmp (event
, "shade") == 0)
157 else if (strcmp (event
, "toggle_iconify") == 0)
158 *action
= TOGGLE_ICONIFY
;
159 else if (strcmp (event
, "maximize_restore") == 0)
160 *action
= MAXIMIZE_RESTORE
;
161 else if (strcmp (event
, "desktop_left") == 0)
162 *action
= DESKTOP_LEFT
;
163 else if (strcmp (event
, "desktop_right") == 0)
164 *action
= DESKTOP_RIGHT
;
168 void add_entry (char *key
, char *value
)
170 char *value1
=0, *value2
=0, *value3
=0;
172 /* Background and border */
173 if (strcmp (key
, "rounded") == 0) {
174 // 'rounded' is the first parameter => alloc a new background
175 Area
*a
= calloc(1, sizeof(Area
));
176 a
->pix
.border
.rounded
= atoi (value
);
177 list_back
= g_slist_append(list_back
, a
);
179 else if (strcmp (key
, "border_width") == 0) {
180 Area
*a
= g_slist_last(list_back
)->data
;
181 a
->pix
.border
.width
= atoi (value
);
183 else if (strcmp (key
, "background_color") == 0) {
184 Area
*a
= g_slist_last(list_back
)->data
;
185 extract_values(value
, &value1
, &value2
, &value3
);
186 get_color (value1
, a
->pix
.back
.color
);
187 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
188 else a
->pix
.back
.alpha
= 0.5;
190 else if (strcmp (key
, "border_color") == 0) {
191 Area
*a
= g_slist_last(list_back
)->data
;
192 extract_values(value
, &value1
, &value2
, &value3
);
193 get_color (value1
, a
->pix
.border
.color
);
194 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
195 else a
->pix
.border
.alpha
= 0.5;
199 else if (strcmp (key
, "panel_monitor") == 0) {
200 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
202 panel_config
.monitor
= atoi (value
);
203 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
205 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
206 // server.nb_monitor minimum value is 1 (see get_monitors())
207 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
208 panel_config
.monitor
= 0;
211 else if (strcmp (key
, "panel_size") == 0) {
212 extract_values(value
, &value1
, &value2
, &value3
);
215 if ((b
= strchr (value1
, '%'))) {
217 panel_config
.pourcentx
= 1;
219 panel_config
.area
.width
= atoi(value1
);
220 if (panel_config
.area
.width
== 0) {
222 panel_config
.area
.width
= 100;
223 panel_config
.pourcentx
= 1;
226 if ((b
= strchr (value2
, '%'))) {
228 panel_config
.pourcenty
= 1;
230 panel_config
.area
.height
= atoi(value2
);
233 else if (strcmp (key
, "panel_margin") == 0) {
234 extract_values(value
, &value1
, &value2
, &value3
);
235 panel_config
.marginx
= atoi (value1
);
236 if (value2
) panel_config
.marginy
= atoi (value2
);
238 else if (strcmp (key
, "panel_padding") == 0) {
239 extract_values(value
, &value1
, &value2
, &value3
);
240 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
241 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
242 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
244 else if (strcmp (key
, "panel_position") == 0) {
245 extract_values(value
, &value1
, &value2
, &value3
);
246 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
248 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
249 else panel_position
= CENTER
;
252 if (!value2
) panel_position
|= CENTER
;
254 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
256 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
257 else panel_position
|= CENTER
;
260 if (!value3
) panel_horizontal
= 1;
262 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
263 else panel_horizontal
= 1;
266 else if (strcmp (key
, "font_shadow") == 0)
267 panel_config
.g_task
.font_shadow
= atoi (value
);
268 else if (strcmp (key
, "panel_background_id") == 0) {
269 int id
= atoi (value
);
270 Area
*a
= g_slist_nth_data(list_back
, id
);
271 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
272 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
274 else if (strcmp (key
, "wm_menu") == 0)
275 wm_menu
= atoi (value
);
276 else if (strcmp (key
, "panel_dock") == 0)
277 panel_dock
= atoi (value
);
278 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
279 max_tick_urgent
= (atoi (value
) * 2) + 1;
282 else if (strcmp (key
, "battery") == 0) {
283 #ifdef ENABLE_BATTERY
288 fprintf(stderr
, "tint2 is build without battery support\n");
291 else if (strcmp (key
, "battery_low_status") == 0) {
292 #ifdef ENABLE_BATTERY
293 battery_low_status
= atoi(value
);
294 if(battery_low_status
< 0 || battery_low_status
> 100)
295 battery_low_status
= 0;
298 else if (strcmp (key
, "battery_low_cmd") == 0) {
299 #ifdef ENABLE_BATTERY
300 if (strlen(value
) > 0)
301 battery_low_cmd
= strdup (value
);
304 else if (strcmp (key
, "bat1_font") == 0) {
305 #ifdef ENABLE_BATTERY
306 bat1_font_desc
= pango_font_description_from_string (value
);
309 else if (strcmp (key
, "bat2_font") == 0) {
310 #ifdef ENABLE_BATTERY
311 bat2_font_desc
= pango_font_description_from_string (value
);
314 else if (strcmp (key
, "battery_font_color") == 0) {
315 #ifdef ENABLE_BATTERY
316 extract_values(value
, &value1
, &value2
, &value3
);
317 get_color (value1
, panel_config
.battery
.font
.color
);
318 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
319 else panel_config
.battery
.font
.alpha
= 0.5;
322 else if (strcmp (key
, "battery_padding") == 0) {
323 #ifdef ENABLE_BATTERY
324 extract_values(value
, &value1
, &value2
, &value3
);
325 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
326 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
327 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
330 else if (strcmp (key
, "battery_background_id") == 0) {
331 #ifdef ENABLE_BATTERY
332 int id
= atoi (value
);
333 Area
*a
= g_slist_nth_data(list_back
, id
);
334 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
335 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
340 else if (strcmp (key
, "time1_format") == 0) {
341 if (strlen(value
) > 0) {
342 time1_format
= strdup (value
);
346 else if (strcmp (key
, "time2_format") == 0) {
347 if (strlen(value
) > 0)
348 time2_format
= strdup (value
);
350 else if (strcmp (key
, "time1_font") == 0) {
351 time1_font_desc
= pango_font_description_from_string (value
);
353 else if (strcmp (key
, "time2_font") == 0) {
354 time2_font_desc
= pango_font_description_from_string (value
);
356 else if (strcmp (key
, "clock_font_color") == 0) {
357 extract_values(value
, &value1
, &value2
, &value3
);
358 get_color (value1
, panel_config
.clock
.font
.color
);
359 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
360 else panel_config
.clock
.font
.alpha
= 0.5;
362 else if (strcmp (key
, "clock_padding") == 0) {
363 extract_values(value
, &value1
, &value2
, &value3
);
364 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
365 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
366 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
368 else if (strcmp (key
, "clock_background_id") == 0) {
369 int id
= atoi (value
);
370 Area
*a
= g_slist_nth_data(list_back
, id
);
371 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
372 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
374 else if (strcmp(key
, "clock_lclick_command") == 0) {
375 if (strlen(value
) > 0)
376 clock_lclick_command
= strdup(value
);
378 else if (strcmp(key
, "clock_rclick_command") == 0) {
379 if (strlen(value
) > 0)
380 clock_rclick_command
= strdup(value
);
384 else if (strcmp (key
, "taskbar_mode") == 0) {
385 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
386 else panel_mode
= SINGLE_DESKTOP
;
388 else if (strcmp (key
, "taskbar_padding") == 0) {
389 extract_values(value
, &value1
, &value2
, &value3
);
390 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
391 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
392 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
394 else if (strcmp (key
, "taskbar_background_id") == 0) {
395 int id
= atoi (value
);
396 Area
*a
= g_slist_nth_data(list_back
, id
);
397 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
398 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
400 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
401 int id
= atoi (value
);
402 Area
*a
= g_slist_nth_data(list_back
, id
);
403 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
404 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
405 panel_config
.g_taskbar
.use_active
= 1;
409 else if (strcmp (key
, "task_text") == 0)
410 panel_config
.g_task
.text
= atoi (value
);
411 else if (strcmp (key
, "task_icon") == 0)
412 panel_config
.g_task
.icon
= atoi (value
);
413 else if (strcmp (key
, "task_centered") == 0)
414 panel_config
.g_task
.centered
= atoi (value
);
415 else if (strcmp (key
, "task_width") == 0) {
416 // old parameter : just for backward compatibility
417 panel_config
.g_task
.maximum_width
= atoi (value
);
418 panel_config
.g_task
.maximum_height
= 30;
420 else if (strcmp (key
, "task_maximum_size") == 0) {
421 extract_values(value
, &value1
, &value2
, &value3
);
422 panel_config
.g_task
.maximum_width
= atoi (value1
);
423 panel_config
.g_task
.maximum_height
= 30;
425 panel_config
.g_task
.maximum_height
= atoi (value2
);
427 else if (strcmp (key
, "task_padding") == 0) {
428 extract_values(value
, &value1
, &value2
, &value3
);
429 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
430 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
431 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
433 else if (strcmp (key
, "task_font") == 0) {
434 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
436 else if (strcmp (key
, "task_font_color") == 0) {
437 extract_values(value
, &value1
, &value2
, &value3
);
438 get_color (value1
, panel_config
.g_task
.font
.color
);
439 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
440 else panel_config
.g_task
.font
.alpha
= 0.1;
442 else if (strcmp (key
, "task_active_font_color") == 0) {
443 extract_values(value
, &value1
, &value2
, &value3
);
444 get_color (value1
, panel_config
.g_task
.font_active
.color
);
445 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
446 else panel_config
.g_task
.font_active
.alpha
= 0.1;
448 else if (strcmp (key
, "task_icon_asb") == 0) {
449 extract_values(value
, &value1
, &value2
, &value3
);
450 panel_config
.g_task
.alpha
= atoi(value1
);
451 panel_config
.g_task
.saturation
= atoi(value2
);
452 panel_config
.g_task
.brightness
= atoi(value3
);
454 else if (strcmp (key
, "task_active_icon_asb") == 0) {
455 extract_values(value
, &value1
, &value2
, &value3
);
456 panel_config
.g_task
.alpha_active
= atoi(value1
);
457 panel_config
.g_task
.saturation_active
= atoi(value2
);
458 panel_config
.g_task
.brightness_active
= atoi(value3
);
460 else if (strcmp (key
, "task_background_id") == 0) {
461 int id
= atoi (value
);
462 Area
*a
= g_slist_nth_data(list_back
, id
);
463 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
464 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
466 else if (strcmp (key
, "task_active_background_id") == 0) {
467 int id
= atoi (value
);
468 Area
*a
= g_slist_nth_data(list_back
, id
);
469 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
470 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
474 else if (strcmp (key
, "systray") == 0) {
478 else if (strcmp (key
, "systray_padding") == 0) {
479 extract_values(value
, &value1
, &value2
, &value3
);
480 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
481 if (value2
) systray
.area
.paddingy
= atoi (value2
);
482 if (value3
) systray
.area
.paddingx
= atoi (value3
);
484 else if (strcmp (key
, "systray_background_id") == 0) {
485 int id
= atoi (value
);
486 Area
*a
= g_slist_nth_data(list_back
, id
);
487 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
488 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
490 else if (strcmp(key
, "systray_sort") == 0) {
491 if (strcmp(value
, "descending") == 0)
493 else if (strcmp(value
, "ascending") == 0)
495 else if (strcmp(value
, "left2right") == 0)
497 else if (strcmp(value
, "right2left") == 0)
502 else if (strcmp (key
, "tooltip") == 0)
503 g_tooltip
.enabled
= atoi(value
);
504 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
505 double timeout
= atof(value
);
506 int sec
= (int)timeout
;
507 int usec
= (timeout
-sec
)*1e6
;
508 g_tooltip
.show_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
510 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
511 double timeout
= atof(value
);
512 int sec
= (int)timeout
;
513 int usec
= (timeout
-sec
)*1e6
;
514 g_tooltip
.hide_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
516 else if (strcmp (key
, "tooltip_padding") == 0) {
517 extract_values(value
, &value1
, &value2
, &value3
);
518 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
519 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
521 else if (strcmp (key
, "tooltip_background_id") == 0) {
522 int id
= atoi (value
);
523 Area
*a
= g_slist_nth_data(list_back
, id
);
524 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
525 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
527 else if (strcmp (key
, "tooltip_font_color") == 0) {
528 extract_values(value
, &value1
, &value2
, &value3
);
529 get_color(value1
, g_tooltip
.font_color
.color
);
530 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
531 else g_tooltip
.font_color
.alpha
= 0.1;
533 else if (strcmp (key
, "tooltip_font") == 0) {
534 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
538 else if (strcmp (key
, "mouse_middle") == 0)
539 get_action (value
, &mouse_middle
);
540 else if (strcmp (key
, "mouse_right") == 0)
541 get_action (value
, &mouse_right
);
542 else if (strcmp (key
, "mouse_scroll_up") == 0)
543 get_action (value
, &mouse_scroll_up
);
544 else if (strcmp (key
, "mouse_scroll_down") == 0)
545 get_action (value
, &mouse_scroll_down
);
548 /* Read tint-0.6 config for backward compatibility */
549 else if (strcmp (key
, "panel_mode") == 0) {
550 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
551 else panel_mode
= MULTI_DESKTOP
;
553 else if (strcmp (key
, "panel_rounded") == 0) {
554 Area
*a
= calloc(1, sizeof(Area
));
555 a
->pix
.border
.rounded
= atoi (value
);
556 list_back
= g_slist_append(list_back
, a
);
558 else if (strcmp (key
, "panel_border_width") == 0) {
559 Area
*a
= g_slist_last(list_back
)->data
;
560 a
->pix
.border
.width
= atoi (value
);
562 else if (strcmp (key
, "panel_background_color") == 0) {
563 Area
*a
= g_slist_last(list_back
)->data
;
564 extract_values(value
, &value1
, &value2
, &value3
);
565 get_color (value1
, a
->pix
.back
.color
);
566 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
567 else a
->pix
.back
.alpha
= 0.5;
569 else if (strcmp (key
, "panel_border_color") == 0) {
570 Area
*a
= g_slist_last(list_back
)->data
;
571 extract_values(value
, &value1
, &value2
, &value3
);
572 get_color (value1
, a
->pix
.border
.color
);
573 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
574 else a
->pix
.border
.alpha
= 0.5;
576 else if (strcmp (key
, "task_text_centered") == 0)
577 panel_config
.g_task
.centered
= atoi (value
);
578 else if (strcmp (key
, "task_margin") == 0) {
579 panel_config
.g_taskbar
.paddingxlr
= 0;
580 panel_config
.g_taskbar
.paddingx
= atoi (value
);
582 else if (strcmp (key
, "task_icon_size") == 0)
583 old_task_icon_size
= atoi (value
);
584 else if (strcmp (key
, "task_rounded") == 0) {
585 area_task
= calloc(1, sizeof(Area
));
586 area_task
->pix
.border
.rounded
= atoi (value
);
587 list_back
= g_slist_append(list_back
, area_task
);
589 area_task_active
= calloc(1, sizeof(Area
));
590 area_task_active
->pix
.border
.rounded
= atoi (value
);
591 list_back
= g_slist_append(list_back
, area_task_active
);
593 else if (strcmp (key
, "task_background_color") == 0) {
594 extract_values(value
, &value1
, &value2
, &value3
);
595 get_color (value1
, area_task
->pix
.back
.color
);
596 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
597 else area_task
->pix
.back
.alpha
= 0.5;
599 else if (strcmp (key
, "task_active_background_color") == 0) {
600 extract_values(value
, &value1
, &value2
, &value3
);
601 get_color (value1
, area_task_active
->pix
.back
.color
);
602 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
603 else area_task_active
->pix
.back
.alpha
= 0.5;
605 else if (strcmp (key
, "task_border_width") == 0) {
606 area_task
->pix
.border
.width
= atoi (value
);
607 area_task_active
->pix
.border
.width
= atoi (value
);
609 else if (strcmp (key
, "task_border_color") == 0) {
610 extract_values(value
, &value1
, &value2
, &value3
);
611 get_color (value1
, area_task
->pix
.border
.color
);
612 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
613 else area_task
->pix
.border
.alpha
= 0.5;
615 else if (strcmp (key
, "task_active_border_color") == 0) {
616 extract_values(value
, &value1
, &value2
, &value3
);
617 get_color (value1
, area_task_active
->pix
.border
.color
);
618 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
619 else area_task_active
->pix
.border
.alpha
= 0.5;
623 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
625 if (value1
) free (value1
);
626 if (value2
) free (value2
);
627 if (value3
) free (value3
);
633 const gchar
* const * system_dirs
;
637 // follow XDG specification
638 // check tint2rc in user directory
639 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
640 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
641 i
= config_read_file (path1
);
642 config_path
= strdup(path1
);
648 // 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;
686 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
687 if (parse_line(line
, &key
, &value
)) {
688 add_entry (key
, value
);
695 if (old_task_icon_size
) {
696 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.069782 seconds and 5 git commands to generate.