]>
Dogcows Code - chaz/tint2/blob - src/config.c
5a627040b6e761e84ea169bcc47edab5761fb89a
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
80 // panel's default value
81 if (panel_config
.g_task
.font_desc
) {
82 pango_font_description_free(panel_config
.g_task
.font_desc
);
84 memset(&panel_config
, 0, sizeof(Panel
));
85 panel_config
.g_task
.alpha
= 100;
86 panel_config
.g_task
.alpha_active
= 100;
89 // window manager's menu default value == false
93 // flush pango cache if possible
94 //pango_xft_shutdown_display(server.dsp, server.screen);
95 //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
96 //pango_fc_font_map_shutdown(font_map);
100 void cleanup_config()
102 // cleanup background list
104 for (l0
= list_back
; l0
; l0
= l0
->next
) {
107 g_slist_free(list_back
);
112 void extract_values (const char *value
, char **value1
, char **value2
, char **value3
)
116 if (*value1
) free (*value1
);
117 if (*value2
) free (*value2
);
118 if (*value3
) free (*value3
);
120 if ((b
= strchr (value
, ' '))) {
128 *value1
= strdup (value
);
132 if ((c
= strchr (b
, ' '))) {
140 *value2
= strdup (b
);
145 *value3
= strdup (c
);
151 void get_action (char *event
, int *action
)
153 if (strcmp (event
, "none") == 0)
155 else if (strcmp (event
, "close") == 0)
157 else if (strcmp (event
, "toggle") == 0)
159 else if (strcmp (event
, "iconify") == 0)
161 else if (strcmp (event
, "shade") == 0)
163 else if (strcmp (event
, "toggle_iconify") == 0)
164 *action
= TOGGLE_ICONIFY
;
165 else if (strcmp (event
, "maximize_restore") == 0)
166 *action
= MAXIMIZE_RESTORE
;
167 else if (strcmp (event
, "desktop_left") == 0)
168 *action
= DESKTOP_LEFT
;
169 else if (strcmp (event
, "desktop_right") == 0)
170 *action
= DESKTOP_RIGHT
;
174 void add_entry (char *key
, char *value
)
176 char *value1
=0, *value2
=0, *value3
=0;
178 /* Background and border */
179 if (strcmp (key
, "rounded") == 0) {
180 // 'rounded' is the first parameter => alloc a new background
181 Area
*a
= calloc(1, sizeof(Area
));
182 a
->pix
.border
.rounded
= atoi (value
);
183 list_back
= g_slist_append(list_back
, a
);
185 else if (strcmp (key
, "border_width") == 0) {
186 Area
*a
= g_slist_last(list_back
)->data
;
187 a
->pix
.border
.width
= atoi (value
);
189 else if (strcmp (key
, "background_color") == 0) {
190 Area
*a
= g_slist_last(list_back
)->data
;
191 extract_values(value
, &value1
, &value2
, &value3
);
192 get_color (value1
, a
->pix
.back
.color
);
193 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
194 else a
->pix
.back
.alpha
= 0.5;
196 else if (strcmp (key
, "border_color") == 0) {
197 Area
*a
= g_slist_last(list_back
)->data
;
198 extract_values(value
, &value1
, &value2
, &value3
);
199 get_color (value1
, a
->pix
.border
.color
);
200 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
201 else a
->pix
.border
.alpha
= 0.5;
205 else if (strcmp (key
, "panel_monitor") == 0) {
206 if (strcmp (value
, "all") == 0) panel_config
.monitor
= -1;
208 panel_config
.monitor
= atoi (value
);
209 if (panel_config
.monitor
> 0) panel_config
.monitor
-= 1;
211 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
212 // server.nb_monitor minimum value is 1 (see get_monitors())
213 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
214 panel_config
.monitor
= 0;
217 else if (strcmp (key
, "panel_size") == 0) {
218 extract_values(value
, &value1
, &value2
, &value3
);
221 if ((b
= strchr (value1
, '%'))) {
223 panel_config
.pourcentx
= 1;
225 panel_config
.area
.width
= atoi(value1
);
226 if (panel_config
.area
.width
== 0) {
228 panel_config
.area
.width
= 100;
229 panel_config
.pourcentx
= 1;
232 if ((b
= strchr (value2
, '%'))) {
234 panel_config
.pourcenty
= 1;
236 panel_config
.area
.height
= atoi(value2
);
239 else if (strcmp (key
, "panel_margin") == 0) {
240 extract_values(value
, &value1
, &value2
, &value3
);
241 panel_config
.marginx
= atoi (value1
);
242 if (value2
) panel_config
.marginy
= atoi (value2
);
244 else if (strcmp (key
, "panel_padding") == 0) {
245 extract_values(value
, &value1
, &value2
, &value3
);
246 panel_config
.area
.paddingxlr
= panel_config
.area
.paddingx
= atoi (value1
);
247 if (value2
) panel_config
.area
.paddingy
= atoi (value2
);
248 if (value3
) panel_config
.area
.paddingx
= atoi (value3
);
250 else if (strcmp (key
, "panel_position") == 0) {
251 extract_values(value
, &value1
, &value2
, &value3
);
252 if (strcmp (value1
, "top") == 0) panel_position
= TOP
;
254 if (strcmp (value1
, "bottom") == 0) panel_position
= BOTTOM
;
255 else panel_position
= CENTER
;
258 if (!value2
) panel_position
|= CENTER
;
260 if (strcmp (value2
, "left") == 0) panel_position
|= LEFT
;
262 if (strcmp (value2
, "right") == 0) panel_position
|= RIGHT
;
263 else panel_position
|= CENTER
;
266 if (!value3
) panel_horizontal
= 1;
268 if (strcmp (value3
, "vertical") == 0) panel_horizontal
= 0;
269 else panel_horizontal
= 1;
272 else if (strcmp (key
, "font_shadow") == 0)
273 panel_config
.g_task
.font_shadow
= atoi (value
);
274 else if (strcmp (key
, "panel_background_id") == 0) {
275 int id
= atoi (value
);
276 Area
*a
= g_slist_nth_data(list_back
, id
);
277 memcpy(&panel_config
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
278 memcpy(&panel_config
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
280 else if (strcmp (key
, "wm_menu") == 0)
281 wm_menu
= atoi (value
);
282 else if (strcmp (key
, "panel_dock") == 0)
283 panel_dock
= atoi (value
);
284 else if (strcmp (key
, "urgent_nb_of_blink") == 0)
285 max_tick_urgent
= (atoi (value
) * 2) + 1;
288 else if (strcmp (key
, "battery") == 0) {
289 #ifdef ENABLE_BATTERY
294 fprintf(stderr
, "tint2 is build without battery support\n");
297 else if (strcmp (key
, "battery_low_status") == 0) {
298 #ifdef ENABLE_BATTERY
299 battery_low_status
= atoi(value
);
300 if(battery_low_status
< 0 || battery_low_status
> 100)
301 battery_low_status
= 0;
304 else if (strcmp (key
, "battery_low_cmd") == 0) {
305 #ifdef ENABLE_BATTERY
306 if (strlen(value
) > 0)
307 battery_low_cmd
= strdup (value
);
310 else if (strcmp (key
, "bat1_font") == 0) {
311 #ifdef ENABLE_BATTERY
312 bat1_font_desc
= pango_font_description_from_string (value
);
315 else if (strcmp (key
, "bat2_font") == 0) {
316 #ifdef ENABLE_BATTERY
317 bat2_font_desc
= pango_font_description_from_string (value
);
320 else if (strcmp (key
, "battery_font_color") == 0) {
321 #ifdef ENABLE_BATTERY
322 extract_values(value
, &value1
, &value2
, &value3
);
323 get_color (value1
, panel_config
.battery
.font
.color
);
324 if (value2
) panel_config
.battery
.font
.alpha
= (atoi (value2
) / 100.0);
325 else panel_config
.battery
.font
.alpha
= 0.5;
328 else if (strcmp (key
, "battery_padding") == 0) {
329 #ifdef ENABLE_BATTERY
330 extract_values(value
, &value1
, &value2
, &value3
);
331 panel_config
.battery
.area
.paddingxlr
= panel_config
.battery
.area
.paddingx
= atoi (value1
);
332 if (value2
) panel_config
.battery
.area
.paddingy
= atoi (value2
);
333 if (value3
) panel_config
.battery
.area
.paddingx
= atoi (value3
);
336 else if (strcmp (key
, "battery_background_id") == 0) {
337 #ifdef ENABLE_BATTERY
338 int id
= atoi (value
);
339 Area
*a
= g_slist_nth_data(list_back
, id
);
340 memcpy(&panel_config
.battery
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
341 memcpy(&panel_config
.battery
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
346 else if (strcmp (key
, "time1_format") == 0) {
347 if (strlen(value
) > 0) {
348 time1_format
= strdup (value
);
352 else if (strcmp (key
, "time2_format") == 0) {
353 if (strlen(value
) > 0)
354 time2_format
= strdup (value
);
356 else if (strcmp (key
, "time1_font") == 0) {
357 time1_font_desc
= pango_font_description_from_string (value
);
359 else if (strcmp (key
, "time2_font") == 0) {
360 time2_font_desc
= pango_font_description_from_string (value
);
362 else if (strcmp (key
, "clock_font_color") == 0) {
363 extract_values(value
, &value1
, &value2
, &value3
);
364 get_color (value1
, panel_config
.clock
.font
.color
);
365 if (value2
) panel_config
.clock
.font
.alpha
= (atoi (value2
) / 100.0);
366 else panel_config
.clock
.font
.alpha
= 0.5;
368 else if (strcmp (key
, "clock_padding") == 0) {
369 extract_values(value
, &value1
, &value2
, &value3
);
370 panel_config
.clock
.area
.paddingxlr
= panel_config
.clock
.area
.paddingx
= atoi (value1
);
371 if (value2
) panel_config
.clock
.area
.paddingy
= atoi (value2
);
372 if (value3
) panel_config
.clock
.area
.paddingx
= atoi (value3
);
374 else if (strcmp (key
, "clock_background_id") == 0) {
375 int id
= atoi (value
);
376 Area
*a
= g_slist_nth_data(list_back
, id
);
377 memcpy(&panel_config
.clock
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
378 memcpy(&panel_config
.clock
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
380 else if (strcmp(key
, "clock_lclick_command") == 0) {
381 if (strlen(value
) > 0)
382 clock_lclick_command
= strdup(value
);
384 else if (strcmp(key
, "clock_rclick_command") == 0) {
385 if (strlen(value
) > 0)
386 clock_rclick_command
= strdup(value
);
390 else if (strcmp (key
, "taskbar_mode") == 0) {
391 if (strcmp (value
, "multi_desktop") == 0) panel_mode
= MULTI_DESKTOP
;
392 else panel_mode
= SINGLE_DESKTOP
;
394 else if (strcmp (key
, "taskbar_padding") == 0) {
395 extract_values(value
, &value1
, &value2
, &value3
);
396 panel_config
.g_taskbar
.paddingxlr
= panel_config
.g_taskbar
.paddingx
= atoi (value1
);
397 if (value2
) panel_config
.g_taskbar
.paddingy
= atoi (value2
);
398 if (value3
) panel_config
.g_taskbar
.paddingx
= atoi (value3
);
400 else if (strcmp (key
, "taskbar_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
.back
, &a
->pix
.back
, sizeof(Color
));
404 memcpy(&panel_config
.g_taskbar
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
406 else if (strcmp (key
, "taskbar_active_background_id") == 0) {
407 int id
= atoi (value
);
408 Area
*a
= g_slist_nth_data(list_back
, id
);
409 memcpy(&panel_config
.g_taskbar
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
410 memcpy(&panel_config
.g_taskbar
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
411 panel_config
.g_taskbar
.use_active
= 1;
415 else if (strcmp (key
, "task_text") == 0)
416 panel_config
.g_task
.text
= atoi (value
);
417 else if (strcmp (key
, "task_icon") == 0)
418 panel_config
.g_task
.icon
= atoi (value
);
419 else if (strcmp (key
, "task_centered") == 0)
420 panel_config
.g_task
.centered
= atoi (value
);
421 else if (strcmp (key
, "task_width") == 0) {
422 // old parameter : just for backward compatibility
423 panel_config
.g_task
.maximum_width
= atoi (value
);
424 panel_config
.g_task
.maximum_height
= 30;
426 else if (strcmp (key
, "task_maximum_size") == 0) {
427 extract_values(value
, &value1
, &value2
, &value3
);
428 panel_config
.g_task
.maximum_width
= atoi (value1
);
429 panel_config
.g_task
.maximum_height
= 30;
431 panel_config
.g_task
.maximum_height
= atoi (value2
);
433 else if (strcmp (key
, "task_padding") == 0) {
434 extract_values(value
, &value1
, &value2
, &value3
);
435 panel_config
.g_task
.area
.paddingxlr
= panel_config
.g_task
.area
.paddingx
= atoi (value1
);
436 if (value2
) panel_config
.g_task
.area
.paddingy
= atoi (value2
);
437 if (value3
) panel_config
.g_task
.area
.paddingx
= atoi (value3
);
439 else if (strcmp (key
, "task_font") == 0) {
440 panel_config
.g_task
.font_desc
= pango_font_description_from_string (value
);
442 else if (strcmp (key
, "task_font_color") == 0) {
443 extract_values(value
, &value1
, &value2
, &value3
);
444 get_color (value1
, panel_config
.g_task
.font
.color
);
445 if (value2
) panel_config
.g_task
.font
.alpha
= (atoi (value2
) / 100.0);
446 else panel_config
.g_task
.font
.alpha
= 0.1;
448 else if (strcmp (key
, "task_active_font_color") == 0) {
449 extract_values(value
, &value1
, &value2
, &value3
);
450 get_color (value1
, panel_config
.g_task
.font_active
.color
);
451 if (value2
) panel_config
.g_task
.font_active
.alpha
= (atoi (value2
) / 100.0);
452 else panel_config
.g_task
.font_active
.alpha
= 0.1;
454 else if (strcmp (key
, "task_icon_asb") == 0) {
455 extract_values(value
, &value1
, &value2
, &value3
);
456 panel_config
.g_task
.alpha
= atoi(value1
);
457 panel_config
.g_task
.saturation
= atoi(value2
);
458 panel_config
.g_task
.brightness
= atoi(value3
);
460 else if (strcmp (key
, "task_active_icon_asb") == 0) {
461 extract_values(value
, &value1
, &value2
, &value3
);
462 panel_config
.g_task
.alpha_active
= atoi(value1
);
463 panel_config
.g_task
.saturation_active
= atoi(value2
);
464 panel_config
.g_task
.brightness_active
= atoi(value3
);
466 else if (strcmp (key
, "task_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
.back
, &a
->pix
.back
, sizeof(Color
));
470 memcpy(&panel_config
.g_task
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
472 else if (strcmp (key
, "task_active_background_id") == 0) {
473 int id
= atoi (value
);
474 Area
*a
= g_slist_nth_data(list_back
, id
);
475 memcpy(&panel_config
.g_task
.area
.pix_active
.back
, &a
->pix
.back
, sizeof(Color
));
476 memcpy(&panel_config
.g_task
.area
.pix_active
.border
, &a
->pix
.border
, sizeof(Border
));
480 else if (strcmp (key
, "systray") == 0) {
484 else if (strcmp (key
, "systray_padding") == 0) {
485 extract_values(value
, &value1
, &value2
, &value3
);
486 systray
.area
.paddingxlr
= systray
.area
.paddingx
= atoi (value1
);
487 if (value2
) systray
.area
.paddingy
= atoi (value2
);
488 if (value3
) systray
.area
.paddingx
= atoi (value3
);
490 else if (strcmp (key
, "systray_background_id") == 0) {
491 int id
= atoi (value
);
492 Area
*a
= g_slist_nth_data(list_back
, id
);
493 memcpy(&systray
.area
.pix
.back
, &a
->pix
.back
, sizeof(Color
));
494 memcpy(&systray
.area
.pix
.border
, &a
->pix
.border
, sizeof(Border
));
496 else if (strcmp(key
, "systray_sort") == 0) {
497 if (strcmp(value
, "descending") == 0)
499 else if (strcmp(value
, "ascending") == 0)
501 else if (strcmp(value
, "left2right") == 0)
503 else if (strcmp(value
, "right2left") == 0)
508 else if (strcmp (key
, "tooltip") == 0)
509 g_tooltip
.enabled
= atoi(value
);
510 else if (strcmp (key
, "tooltip_show_timeout") == 0) {
511 double timeout
= atof(value
);
512 int sec
= (int)timeout
;
513 int usec
= (timeout
-sec
)*1e6
;
514 g_tooltip
.show_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
516 else if (strcmp (key
, "tooltip_hide_timeout") == 0) {
517 double timeout
= atof(value
);
518 int sec
= (int)timeout
;
519 int usec
= (timeout
-sec
)*1e6
;
520 g_tooltip
.hide_timeout
.it_value
= (struct timeval
){.tv_sec
=sec
, .tv_usec
=usec
};
522 else if (strcmp (key
, "tooltip_padding") == 0) {
523 extract_values(value
, &value1
, &value2
, &value3
);
524 if (value1
) g_tooltip
.paddingx
= atoi(value1
);
525 if (value2
) g_tooltip
.paddingy
= atoi(value2
);
527 else if (strcmp (key
, "tooltip_background_id") == 0) {
528 int id
= atoi (value
);
529 Area
*a
= g_slist_nth_data(list_back
, id
);
530 memcpy(&g_tooltip
.background_color
, &a
->pix
.back
, sizeof(Color
));
531 memcpy(&g_tooltip
.border
, &a
->pix
.border
, sizeof(Border
));
533 else if (strcmp (key
, "tooltip_font_color") == 0) {
534 extract_values(value
, &value1
, &value2
, &value3
);
535 get_color(value1
, g_tooltip
.font_color
.color
);
536 if (value2
) g_tooltip
.font_color
.alpha
= (atoi (value2
) / 100.0);
537 else g_tooltip
.font_color
.alpha
= 0.1;
539 else if (strcmp (key
, "tooltip_font") == 0) {
540 g_tooltip
.font_desc
= pango_font_description_from_string(value
);
544 else if (strcmp (key
, "mouse_middle") == 0)
545 get_action (value
, &mouse_middle
);
546 else if (strcmp (key
, "mouse_right") == 0)
547 get_action (value
, &mouse_right
);
548 else if (strcmp (key
, "mouse_scroll_up") == 0)
549 get_action (value
, &mouse_scroll_up
);
550 else if (strcmp (key
, "mouse_scroll_down") == 0)
551 get_action (value
, &mouse_scroll_down
);
554 /* Read tint-0.6 config for backward compatibility */
555 else if (strcmp (key
, "panel_mode") == 0) {
556 if (strcmp (value
, "single_desktop") == 0) panel_mode
= SINGLE_DESKTOP
;
557 else panel_mode
= MULTI_DESKTOP
;
559 else if (strcmp (key
, "panel_rounded") == 0) {
560 Area
*a
= calloc(1, sizeof(Area
));
561 a
->pix
.border
.rounded
= atoi (value
);
562 list_back
= g_slist_append(list_back
, a
);
564 else if (strcmp (key
, "panel_border_width") == 0) {
565 Area
*a
= g_slist_last(list_back
)->data
;
566 a
->pix
.border
.width
= atoi (value
);
568 else if (strcmp (key
, "panel_background_color") == 0) {
569 Area
*a
= g_slist_last(list_back
)->data
;
570 extract_values(value
, &value1
, &value2
, &value3
);
571 get_color (value1
, a
->pix
.back
.color
);
572 if (value2
) a
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
573 else a
->pix
.back
.alpha
= 0.5;
575 else if (strcmp (key
, "panel_border_color") == 0) {
576 Area
*a
= g_slist_last(list_back
)->data
;
577 extract_values(value
, &value1
, &value2
, &value3
);
578 get_color (value1
, a
->pix
.border
.color
);
579 if (value2
) a
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
580 else a
->pix
.border
.alpha
= 0.5;
582 else if (strcmp (key
, "task_text_centered") == 0)
583 panel_config
.g_task
.centered
= atoi (value
);
584 else if (strcmp (key
, "task_margin") == 0) {
585 panel_config
.g_taskbar
.paddingxlr
= 0;
586 panel_config
.g_taskbar
.paddingx
= atoi (value
);
588 else if (strcmp (key
, "task_icon_size") == 0)
589 old_task_icon_size
= atoi (value
);
590 else if (strcmp (key
, "task_rounded") == 0) {
591 area_task
= calloc(1, sizeof(Area
));
592 area_task
->pix
.border
.rounded
= atoi (value
);
593 list_back
= g_slist_append(list_back
, area_task
);
595 area_task_active
= calloc(1, sizeof(Area
));
596 area_task_active
->pix
.border
.rounded
= atoi (value
);
597 list_back
= g_slist_append(list_back
, area_task_active
);
599 else if (strcmp (key
, "task_background_color") == 0) {
600 extract_values(value
, &value1
, &value2
, &value3
);
601 get_color (value1
, area_task
->pix
.back
.color
);
602 if (value2
) area_task
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
603 else area_task
->pix
.back
.alpha
= 0.5;
605 else if (strcmp (key
, "task_active_background_color") == 0) {
606 extract_values(value
, &value1
, &value2
, &value3
);
607 get_color (value1
, area_task_active
->pix
.back
.color
);
608 if (value2
) area_task_active
->pix
.back
.alpha
= (atoi (value2
) / 100.0);
609 else area_task_active
->pix
.back
.alpha
= 0.5;
611 else if (strcmp (key
, "task_border_width") == 0) {
612 area_task
->pix
.border
.width
= atoi (value
);
613 area_task_active
->pix
.border
.width
= atoi (value
);
615 else if (strcmp (key
, "task_border_color") == 0) {
616 extract_values(value
, &value1
, &value2
, &value3
);
617 get_color (value1
, area_task
->pix
.border
.color
);
618 if (value2
) area_task
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
619 else area_task
->pix
.border
.alpha
= 0.5;
621 else if (strcmp (key
, "task_active_border_color") == 0) {
622 extract_values(value
, &value1
, &value2
, &value3
);
623 get_color (value1
, area_task_active
->pix
.border
.color
);
624 if (value2
) area_task_active
->pix
.border
.alpha
= (atoi (value2
) / 100.0);
625 else area_task_active
->pix
.border
.alpha
= 0.5;
629 fprintf(stderr
, "tint2 : invalid option \"%s\", correct your config file\n", key
);
631 if (value1
) free (value1
);
632 if (value2
) free (value2
);
633 if (value3
) free (value3
);
639 const gchar
* const * system_dirs
;
643 // follow XDG specification
644 // check tint2rc in user directory
645 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
646 if (g_file_test (path1
, G_FILE_TEST_EXISTS
)) {
647 i
= config_read_file (path1
);
648 config_path
= strdup(path1
);
654 // copy tint2rc from system directory to user directory
656 system_dirs
= g_get_system_config_dirs();
657 for (i
= 0; system_dirs
[i
]; i
++) {
658 path2
= g_build_filename(system_dirs
[i
], "tint2", "tint2rc", NULL
);
660 if (g_file_test(path2
, G_FILE_TEST_EXISTS
)) break;
666 // copy file in user directory (path1)
667 char *dir
= g_build_filename (g_get_user_config_dir(), "tint2", NULL
);
668 if (!g_file_test (dir
, G_FILE_TEST_IS_DIR
)) g_mkdir(dir
, 0777);
671 path1
= g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL
);
672 copy_file(path2
, path1
);
675 i
= config_read_file (path1
);
676 config_path
= strdup(path1
);
684 int config_read_file (const char *path
)
690 if ((fp
= fopen(path
, "r")) == NULL
) return 0;
692 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
693 if (parse_line(line
, &key
, &value
)) {
694 add_entry (key
, value
);
701 if (old_task_icon_size
) {
702 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.073638 seconds and 4 git commands to generate.