]>
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 *snapshot_path
= 0;
57 // --------------------------------------------------
58 // backward compatibility
59 static int old_task_icon_size
;
60 static Area
*area_task
;
61 static Area
*area_task_active
;
62 // detect if it's an old config file
64 static int old_config_file
;
66 // temporary list of background
67 static GSList
*list_back
;
73 // append full transparency background
74 list_back
= g_slist_append(0, calloc(1, sizeof(Area
)));
76 // tint2 could reload config, so we cleanup objects
84 // panel's default value
85 if (panel_config
.g_task
.font_desc
) {
86 pango_font_description_free(panel_config
.g_task
.font_desc
);
88 memset(&panel_config
, 0, sizeof(Panel
));
89 panel_config
.g_task
.alpha
= 100;
90 panel_config
.g_task
.alpha_active
= 100;
94 // window manager's menu default value == false
98 // flush pango cache if possible
99 //pango_xft_shutdown_display(server.dsp, server.screen);
100 //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
101 //pango_fc_font_map_shutdown(font_map);
105 void cleanup_config()
107 // cleanup background list
109 for (l0
= list_back
; l0
; l0
= l0
->next
) {
112 g_slist_free(list_back
);
117 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
121 if (*value1
) free (*value1
);
122 if (*value2
) free (*value2
);
123 if (*value3
) free (*value3
);
125 if ((b
= strchr (value
, ' '))) {
133 *value1
= strdup (value
);
137 if ((c
= strchr (b
, ' '))) {
145 *value2
= strdup (b
);
150 *value3
= strdup (c
);
156 void get_action (char *event
, int *action
)
158 if (strcmp (event
, "none") == 0)
160 else if (strcmp (event
, "close") == 0)
162 else if (strcmp (event
, "toggle") == 0)
164 else if (strcmp (event
, "iconify") == 0)
166 else if (strcmp (event
, "shade") == 0)
168 else if (strcmp (event
, "toggle_iconify") == 0)
169 *action
= TOGGLE_ICONIFY
;
170 else if (strcmp (event
, "maximize_restore") == 0)
171 *action
= MAXIMIZE_RESTORE
;
172 else if (strcmp (event
, "desktop_left") == 0)
173 *action
= DESKTOP_LEFT
;
174 else if (strcmp (event
, "desktop_right") == 0)
175 *action
= DESKTOP_RIGHT
;
179 void add_entry (char *key
, char *value
)
181 char *value1
=0, *value2
=0, *value3
=0;
183 /* Background and border */
184 if (strcmp (key
, "rounded") == 0) {
185 // 'rounded' is the first parameter => alloc a new background
186 Area
*a
= calloc(1, sizeof(Area
));
187 a
->pix
.border
.rounded
= atoi (value
);
188 list_back
= g_slist_append(list_back
, a
);
190 else if (strcmp (key
, "border_width") == 0) {
191 Area
*a
= g_slist_last(list_back
)->data
;
192 a
->pix
.border
.width
= atoi (value
);
194 else if (strcmp (key
, "background_color") == 0) {
195 Area
*a
= g_slist_last(list_back
)->data
;
196 extract_values(value
, &value1
, &value2
, &value3
);
197 get_color (value1
, a
->pix
.back
.color
);
198 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
199 else a
->pix
.back
.alpha
= 0.5;
201 else if (strcmp (key
, "border_color") == 0) {
202 Area
*a
= g_slist_last(list_back
)->data
;
203 extract_values(value
, &value1
, &value2
, &value3
);
204 get_color (value1
, a
->pix
.border
.color
);
205 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
206 else a
->pix
.border
.alpha
= 0.5;
210 else if (strcmp (key
, "panel_monitor") == 0) {
211 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
213 panel_config
.monitor
= atoi (value
);
214 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
216 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
217 // server.nb_monitor minimum value is 1 (see get_monitors())
218 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
219 panel_config
.monitor
= 0;
222 else if (strcmp (key
, "panel_size") == 0) {
223 extract_values(value
, &value1
, &value2
, &value3
);
226 if ((b
= strchr (value1
, '%'))) {
228 panel_config
.pourcentx
= 1;
230 panel_config
.area
.width
= atoi(value1
);
231 if (panel_config
.area
.width
== 0) {
233 panel_config
.area
.width
= 100;
234 panel_config
.pourcentx
= 1;
237 if ((b
= strchr (value2
, '%'))) {
239 panel_config
.pourcenty
= 1;
241 panel_config
.area
.height
= atoi(value2
);
244 else if (strcmp (key
, "panel_margin") == 0) {
245 extract_values(value
, &value1
, &value2
, &value3
);
246 panel_config
.marginx
= atoi (value1
);
247 if (value2
) panel_config
.marginy
= atoi (value2
);
249 else if (strcmp (key
, "panel_padding") == 0) {
250 extract_values(value
, &value1
, &value2
, &value3
);
251 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
252 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
253 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
255 else if (strcmp (key
, "panel_position") == 0) {
256 extract_values(value
, &value1
, &value2
, &value3
);
257 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
259 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
260 else panel_position
= CENTER
;
263 if (!value2
) panel_position
|= CENTER
;
265 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
267 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
268 else panel_position
|= CENTER
;
271 if (!value3
) panel_horizontal
= 1;
273 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
274 else panel_horizontal
= 1;
277 else if (strcmp (key
, "font_shadow") == 0)
278 panel_config
.g_task
.font_shadow
= atoi (value
);
279 else if (strcmp (key
, "panel_background_id") == 0) {
280 int id
= atoi (value
);
281 Area
*a
= g_slist_nth_data(list_back
, id
);
282 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
283 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
285 else if (strcmp (key
, "wm_menu") == 0)
286 wm_menu
= atoi (value
);
287 else if (strcmp (key
, "panel_dock") == 0)
288 panel_dock
= atoi (value
);
289 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
290 max_tick_urgent
= (atoi (value
) * 2) + 1;
293 else if (strcmp (key
, "battery") == 0) {
294 #ifdef ENABLE_BATTERY
299 fprintf(stderr
, "tint2 is build without battery support\n");
302 else if (strcmp (key
, "battery_low_status") == 0) {
303 #ifdef ENABLE_BATTERY
304 battery_low_status
= atoi(value
);
305 if(battery_low_status
< 0 || battery_low_status
> 100)
306 battery_low_status
= 0;
309 else if (strcmp (key
, "battery_low_cmd") == 0) {
310 #ifdef ENABLE_BATTERY
311 if (strlen(value
) > 0)
312 battery_low_cmd
= strdup (value
);
315 else if (strcmp (key
, "bat1_font") == 0) {
316 #ifdef ENABLE_BATTERY
317 bat1_font_desc
= pango_font_description_from_string (value
);
320 else if (strcmp (key
, "bat2_font") == 0) {
321 #ifdef ENABLE_BATTERY
322 bat2_font_desc
= pango_font_description_from_string (value
);
325 else if (strcmp (key
, "battery_font_color") == 0) {
326 #ifdef ENABLE_BATTERY
327 extract_values(value
, &value1
, &value2
, &value3
);
328 get_color (value1
, panel_config
.battery
.font
.color
);
329 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
330 else panel_config
.battery
.font
.alpha
= 0.5;
333 else if (strcmp (key
, "battery_padding") == 0) {
334 #ifdef ENABLE_BATTERY
335 extract_values(value
, &value1
, &value2
, &value3
);
336 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
337 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
338 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
341 else if (strcmp (key
, "battery_background_id") == 0) {
342 #ifdef ENABLE_BATTERY
343 int id
= atoi (value
);
344 Area
*a
= g_slist_nth_data(list_back
, id
);
345 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
346 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
351 else if (strcmp (key
, "time1_format") == 0) {
352 if (strlen(value
) > 0) {
353 time1_format
= strdup (value
);
357 else if (strcmp (key
, "time2_format") == 0) {
358 if (strlen(value
) > 0)
359 time2_format
= strdup (value
);
361 else if (strcmp (key
, "time1_font") == 0) {
362 time1_font_desc
= pango_font_description_from_string (value
);
364 else if (strcmp (key
, "time2_font") == 0) {
365 time2_font_desc
= pango_font_description_from_string (value
);
367 else if (strcmp (key
, "clock_font_color") == 0) {
368 extract_values(value
, &value1
, &value2
, &value3
);
369 get_color (value1
, panel_config
.clock
.font
.color
);
370 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
371 else panel_config
.clock
.font
.alpha
= 0.5;
373 else if (strcmp (key
, "clock_padding") == 0) {
374 extract_values(value
, &value1
, &value2
, &value3
);
375 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
376 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
377 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
379 else if (strcmp (key
, "clock_background_id") == 0) {
380 int id
= atoi (value
);
381 Area
*a
= g_slist_nth_data(list_back
, id
);
382 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
383 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
385 else if (strcmp(key
, "clock_lclick_command") == 0) {
386 if (strlen(value
) > 0)
387 clock_lclick_command
= strdup(value
);
389 else if (strcmp(key
, "clock_rclick_command") == 0) {
390 if (strlen(value
) > 0)
391 clock_rclick_command
= strdup(value
);
395 else if (strcmp (key
, "taskbar_mode") == 0) {
396 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
397 else panel_mode
= SINGLE_DESKTOP
;
399 else if (strcmp (key
, "taskbar_padding") == 0) {
400 extract_values(value
, &value1
, &value2
, &value3
);
401 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
402 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
403 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
405 else if (strcmp (key
, "taskbar_background_id") == 0) {
406 int id
= atoi (value
);
407 Area
*a
= g_slist_nth_data(list_back
, id
);
408 memcpy(&panel_config
.g_taskbar
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
409 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
411 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
412 int id
= atoi (value
);
413 Area
*a
= g_slist_nth_data(list_back
, id
);
414 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
415 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
416 panel_config
.g_taskbar
.use_active
= 1;
420 else if (strcmp (key
, "task_text") == 0)
421 panel_config
.g_task
.text
= atoi (value
);
422 else if (strcmp (key
, "task_icon") == 0)
423 panel_config
.g_task
.icon
= atoi (value
);
424 else if (strcmp (key
, "task_centered") == 0)
425 panel_config
.g_task
.centered
= atoi (value
);
426 else if (strcmp (key
, "task_width") == 0) {
427 // old parameter : just for backward compatibility
428 panel_config
.g_task
.maximum_width
= atoi (value
);
429 panel_config
.g_task
.maximum_height
= 30;
431 else if (strcmp (key
, "task_maximum_size") == 0) {
432 extract_values(value
, &value1
, &value2
, &value3
);
433 panel_config
.g_task
.maximum_width
= atoi (value1
);
434 panel_config
.g_task
.maximum_height
= 30;
436 panel_config
.g_task
.maximum_height
= atoi (value2
);
438 else if (strcmp (key
, "task_padding") == 0) {
439 extract_values(value
, &value1
, &value2
, &value3
);
440 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
441 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
442 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
444 else if (strcmp (key
, "task_font") == 0) {
445 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
447 else if (strcmp (key
, "task_font_color") == 0) {
448 extract_values(value
, &value1
, &value2
, &value3
);
449 get_color (value1
, panel_config
.g_task
.font
.color
);
450 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
451 else panel_config
.g_task
.font
.alpha
= 0.1;
453 else if (strcmp (key
, "task_active_font_color") == 0) {
454 extract_values(value
, &value1
, &value2
, &value3
);
455 get_color (value1
, panel_config
.g_task
.font_active
.color
);
456 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
457 else panel_config
.g_task
.font_active
.alpha
= 0.1;
459 else if (strcmp (key
, "task_icon_asb") == 0) {
460 extract_values(value
, &value1
, &value2
, &value3
);
461 panel_config
.g_task
.alpha
= atoi(value1
);
462 panel_config
.g_task
.saturation
= atoi(value2
);
463 panel_config
.g_task
.brightness
= atoi(value3
);
465 else if (strcmp (key
, "task_active_icon_asb") == 0) {
466 extract_values(value
, &value1
, &value2
, &value3
);
467 panel_config
.g_task
.alpha_active
= atoi(value1
);
468 panel_config
.g_task
.saturation_active
= atoi(value2
);
469 panel_config
.g_task
.brightness_active
= atoi(value3
);
471 else if (strcmp (key
, "task_background_id") == 0) {
472 int id
= atoi (value
);
473 Area
*a
= g_slist_nth_data(list_back
, id
);
474 memcpy(&panel_config
.g_task
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
475 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
477 else if (strcmp (key
, "task_active_background_id") == 0) {
478 int id
= atoi (value
);
479 Area
*a
= g_slist_nth_data(list_back
, id
);
480 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
481 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
485 else if (strcmp (key
, "systray") == 0) {
486 systray_enabled
= atoi(value
);
487 // systray is latest option added. files without 'systray' are old.
490 else if (strcmp (key
, "systray_padding") == 0) {
493 extract_values(value
, &value1
, &value2
, &value3
);
494 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
495 if (value2
) systray
.area
.paddingy
= atoi (value2
);
496 if (value3
) systray
.area
.paddingx
= atoi (value3
);
498 else if (strcmp (key
, "systray_background_id") == 0) {
499 int id
= atoi (value
);
500 Area
*a
= g_slist_nth_data(list_back
, id
);
501 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
502 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
504 else if (strcmp(key
, "systray_sort") == 0) {
505 if (strcmp(value
, "descending") == 0)
507 else if (strcmp(value
, "ascending") == 0)
509 else if (strcmp(value
, "left2right") == 0)
511 else if (strcmp(value
, "right2left") == 0)
516 else if (strcmp (key
, "tooltip") == 0)
517 g_tooltip
.enabled
= atoi(value
);
518 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
519 double timeout
= atof(value
);
520 int sec
= (int)timeout
;
521 int usec
= (timeout
-sec
)*1e6
;
522 g_tooltip
.show_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
524 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
525 double timeout
= atof(value
);
526 int sec
= (int)timeout
;
527 int usec
= (timeout
-sec
)*1e6
;
528 g_tooltip
.hide_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
530 else if (strcmp (key
, "tooltip_padding") == 0) {
531 extract_values(value
, &value1
, &value2
, &value3
);
532 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
533 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
535 else if (strcmp (key
, "tooltip_background_id") == 0) {
536 int id
= atoi (value
);
537 Area
*a
= g_slist_nth_data(list_back
, id
);
538 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
539 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
541 else if (strcmp (key
, "tooltip_font_color") == 0) {
542 extract_values(value
, &value1
, &value2
, &value3
);
543 get_color(value1
, g_tooltip
.font_color
.color
);
544 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
545 else g_tooltip
.font_color
.alpha
= 0.1;
547 else if (strcmp (key
, "tooltip_font") == 0) {
548 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
552 else if (strcmp (key
, "mouse_middle") == 0)
553 get_action (value
, &mouse_middle
);
554 else if (strcmp (key
, "mouse_right") == 0)
555 get_action (value
, &mouse_right
);
556 else if (strcmp (key
, "mouse_scroll_up") == 0)
557 get_action (value
, &mouse_scroll_up
);
558 else if (strcmp (key
, "mouse_scroll_down") == 0)
559 get_action (value
, &mouse_scroll_down
);
562 /* Read tint-0.6 config for backward compatibility */
563 else if (strcmp (key
, "panel_mode") == 0) {
564 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
565 else panel_mode
= MULTI_DESKTOP
;
567 else if (strcmp (key
, "panel_rounded") == 0) {
568 Area
*a
= calloc(1, sizeof(Area
));
569 a
->pix
.border
.rounded
= atoi (value
);
570 list_back
= g_slist_append(list_back
, a
);
572 else if (strcmp (key
, "panel_border_width") == 0) {
573 Area
*a
= g_slist_last(list_back
)->data
;
574 a
->pix
.border
.width
= atoi (value
);
576 else if (strcmp (key
, "panel_background_color") == 0) {
577 Area
*a
= g_slist_last(list_back
)->data
;
578 extract_values(value
, &value1
, &value2
, &value3
);
579 get_color (value1
, a
->pix
.back
.color
);
580 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
581 else a
->pix
.back
.alpha
= 0.5;
583 else if (strcmp (key
, "panel_border_color") == 0) {
584 Area
*a
= g_slist_last(list_back
)->data
;
585 extract_values(value
, &value1
, &value2
, &value3
);
586 get_color (value1
, a
->pix
.border
.color
);
587 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
588 else a
->pix
.border
.alpha
= 0.5;
590 else if (strcmp (key
, "task_text_centered") == 0)
591 panel_config
.g_task
.centered
= atoi (value
);
592 else if (strcmp (key
, "task_margin") == 0) {
593 panel_config
.g_taskbar
.paddingxlr
= 0;
594 panel_config
.g_taskbar
.paddingx
= atoi (value
);
596 else if (strcmp (key
, "task_icon_size") == 0)
597 old_task_icon_size
= atoi (value
);
598 else if (strcmp (key
, "task_rounded") == 0) {
599 area_task
= calloc(1, sizeof(Area
));
600 area_task
->pix
.border
.rounded
= atoi (value
);
601 list_back
= g_slist_append(list_back
, area_task
);
603 area_task_active
= calloc(1, sizeof(Area
));
604 area_task_active
->pix
.border
.rounded
= atoi (value
);
605 list_back
= g_slist_append(list_back
, area_task_active
);
607 else if (strcmp (key
, "task_background_color") == 0) {
608 extract_values(value
, &value1
, &value2
, &value3
);
609 get_color (value1
, area_task
->pix
.back
.color
);
610 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
611 else area_task
->pix
.back
.alpha
= 0.5;
613 else if (strcmp (key
, "task_active_background_color") == 0) {
614 extract_values(value
, &value1
, &value2
, &value3
);
615 get_color (value1
, area_task_active
->pix
.back
.color
);
616 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
617 else area_task_active
->pix
.back
.alpha
= 0.5;
619 else if (strcmp (key
, "task_border_width") == 0) {
620 area_task
->pix
.border
.width
= atoi (value
);
621 area_task_active
->pix
.border
.width
= atoi (value
);
623 else if (strcmp (key
, "task_border_color") == 0) {
624 extract_values(value
, &value1
, &value2
, &value3
);
625 get_color (value1
, area_task
->pix
.border
.color
);
626 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
627 else area_task
->pix
.border
.alpha
= 0.5;
629 else if (strcmp (key
, "task_active_border_color") == 0) {
630 extract_values(value
, &value1
, &value2
, &value3
);
631 get_color (value1
, area_task_active
->pix
.border
.color
);
632 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
633 else area_task_active
->pix
.border
.alpha
= 0.5;
637 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
639 if (value1
) free (value1
);
640 if (value2
) free (value2
);
641 if (value3
) free (value3
);
647 const gchar
* const * system_dirs
;
651 // follow XDG specification
652 // check tint2rc in user directory
653 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
654 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
655 i
= config_read_file (path1
);
656 config_path
= strdup(path1
);
662 // copy tint2rc from system directory to user directory
664 system_dirs
= g_get_system_config_dirs();
665 for (i
= 0; system_dirs
[i
]; i
++) {
666 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
668 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
674 // copy file in user directory (path1)
675 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
676 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
679 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
680 copy_file(path2
, path1
);
683 i
= config_read_file (path1
);
684 config_path
= strdup(path1
);
692 int config_read_file (const char *path
)
698 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
700 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
701 if (parse_line(line
, &key
, &value
)) {
702 add_entry (key
, value
);
709 if (old_task_icon_size
) {
710 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.067997 seconds and 4 git commands to generate.