From 2c8ef724e65a847ec8fd81623b59c39a6d8bfea1 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Fri, 12 Feb 2010 00:39:50 +0100 Subject: [PATCH 1/3] Make sure alignment is disabled when the windowtype is dock --- src/conky.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 071612aa..6e882dd3 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2943,9 +2943,9 @@ char load_config_file(const char *f) } CONF("alignment") { #ifdef OWN_WINDOW - if (window.type == TYPE_DOCK) - ; - else + if (window.type == TYPE_DOCK) { + NORM_ERR("alignment is disabled when own_window_type is dock"); + } else #endif /*OWN_WINDOW */ if (value) { int a = string_to_alignment(value); @@ -4029,6 +4029,11 @@ void initialisation(int argc, char **argv) { set_first_font(optarg); break; case 'a': +#ifdef OWN_WINDOW + if (window.type == TYPE_DOCK) { + NORM_ERR("alignment is disabled when own_window_type is dock"); + } else +#endif /*OWN_WINDOW */ text_alignment = string_to_alignment(optarg); break; From 0f399a18e8ebd64defbff622508883cd2263a283 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Fri, 12 Feb 2010 01:58:30 +0100 Subject: [PATCH 2/3] Warn at wrong alignment setting --- src/conky.cc | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 6e882dd3..85b8c3c3 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -297,7 +297,8 @@ static int text_width = 1, text_height = 1; /* initially 1 so no zero-sized wind /* alignments */ enum alignment { - TOP_LEFT = 1, + ALIGNMENT_ERROR, + TOP_LEFT, TOP_RIGHT, TOP_MIDDLE, BOTTOM_LEFT, @@ -2547,7 +2548,7 @@ static enum alignment string_to_alignment(const char *s) } else if (strcasecmp(s, "none") == EQUAL) { return NONE; } - return TOP_LEFT; + return ALIGNMENT_ERROR; } #endif /* BUILD_X11 */ @@ -2899,6 +2900,27 @@ static int do_config_step(int *line, FILE *fp, char *buf, char **name, char **va return 0; } +void setalignment(int* text_alignment, unsigned int windowtype, const char* value, const char *f, int line, bool conffile) { +#ifdef OWN_WINDOW + if (windowtype == TYPE_DOCK) { + NORM_ERR("alignment is disabled when own_window_type is dock"); + } else +#endif /*OWN_WINDOW */ + if (value) { + int a = string_to_alignment(value); + + if (a <= 0) { + if(conffile == true) { + CONF_ERR; + } else NORM_ERR("'%s' is not a alignment setting", value); + } else { + *text_alignment = a; + } + } else if(conffile == true) { + CONF_ERR; + } +} + char load_config_file(const char *f) { int line = 0; @@ -2942,22 +2964,7 @@ char load_config_file(const char *f) } } CONF("alignment") { -#ifdef OWN_WINDOW - if (window.type == TYPE_DOCK) { - NORM_ERR("alignment is disabled when own_window_type is dock"); - } else -#endif /*OWN_WINDOW */ - if (value) { - int a = string_to_alignment(value); - - if (a <= 0) { - CONF_ERR; - } else { - text_alignment = a; - } - } else { - CONF_ERR; - } + setalignment(&text_alignment, window.type, value, f, line, true); } CONF("background") { fork_to_background = string_to_bool(value); @@ -4029,12 +4036,7 @@ void initialisation(int argc, char **argv) { set_first_font(optarg); break; case 'a': -#ifdef OWN_WINDOW - if (window.type == TYPE_DOCK) { - NORM_ERR("alignment is disabled when own_window_type is dock"); - } else -#endif /*OWN_WINDOW */ - text_alignment = string_to_alignment(optarg); + setalignment(&text_alignment, window.type, optarg, NULL, 0, false); break; #ifdef OWN_WINDOW From 064c6f9e427713153bcf30031826a6847b934899 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Fri, 12 Feb 2010 17:03:25 +0100 Subject: [PATCH 3/3] Fix wrong mixer values on some systems (thanks hoffa) --- src/mixer.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mixer.cc b/src/mixer.cc index fd700deb..42a27b2a 100644 --- a/src/mixer.cc +++ b/src/mixer.cc @@ -177,11 +177,16 @@ int mixer_init (const char *name) } static int mixer_get_avg (int i) { - long val; + long val; - snd_mixer_handle_events (data.mixer); - snd_mixer_selem_get_playback_volume (data.elem, 0, &val); - return (int) val; + snd_mixer_handle_events (data.mixer); + snd_mixer_selem_get_playback_volume (data.elem, 0, &val); + if(data.vol_max != 100) { + float avgf = ((float)val / data.vol_max) * 100; + int avg = (int)avgf; + return (avgf - avg < 0.5) ? avg : avg + 1; + } + return (int) val; } static int mixer_get_left (int i) {