mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
Merge remote branch 'origin/master' into lua-config
This commit is contained in:
commit
851e8b8ef0
45
src/conky.cc
45
src/conky.cc
@ -300,7 +300,8 @@ static int text_width = 1, text_height = 1; /* initially 1 so no zero-sized wind
|
|||||||
|
|
||||||
/* alignments */
|
/* alignments */
|
||||||
enum alignment {
|
enum alignment {
|
||||||
TOP_LEFT = 1,
|
ALIGNMENT_ERROR,
|
||||||
|
TOP_LEFT,
|
||||||
TOP_RIGHT,
|
TOP_RIGHT,
|
||||||
TOP_MIDDLE,
|
TOP_MIDDLE,
|
||||||
BOTTOM_LEFT,
|
BOTTOM_LEFT,
|
||||||
@ -2550,7 +2551,7 @@ static enum alignment string_to_alignment(const char *s)
|
|||||||
} else if (strcasecmp(s, "none") == EQUAL) {
|
} else if (strcasecmp(s, "none") == EQUAL) {
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
return TOP_LEFT;
|
return ALIGNMENT_ERROR;
|
||||||
}
|
}
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
|
|
||||||
@ -2902,6 +2903,27 @@ static int do_config_step(int *line, FILE *fp, char *buf, char **name, char **va
|
|||||||
return 0;
|
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)
|
char load_config_file(const char *f)
|
||||||
{
|
{
|
||||||
int line = 0;
|
int line = 0;
|
||||||
@ -2945,22 +2967,7 @@ char load_config_file(const char *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CONF("alignment") {
|
CONF("alignment") {
|
||||||
#ifdef OWN_WINDOW
|
setalignment(&text_alignment, window.type, value, f, line, true);
|
||||||
if (window.type == TYPE_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CONF("background") {
|
CONF("background") {
|
||||||
fork_to_background = string_to_bool(value);
|
fork_to_background = string_to_bool(value);
|
||||||
@ -4035,7 +4042,7 @@ void initialisation(int argc, char **argv) {
|
|||||||
set_first_font(optarg);
|
set_first_font(optarg);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
text_alignment = string_to_alignment(optarg);
|
setalignment(&text_alignment, window.type, optarg, NULL, 0, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
|
13
src/mixer.cc
13
src/mixer.cc
@ -177,11 +177,16 @@ int mixer_init (const char *name)
|
|||||||
}
|
}
|
||||||
static int mixer_get_avg (int i)
|
static int mixer_get_avg (int i)
|
||||||
{
|
{
|
||||||
long val;
|
long val;
|
||||||
|
|
||||||
snd_mixer_handle_events (data.mixer);
|
snd_mixer_handle_events (data.mixer);
|
||||||
snd_mixer_selem_get_playback_volume (data.elem, 0, &val);
|
snd_mixer_selem_get_playback_volume (data.elem, 0, &val);
|
||||||
return (int) 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)
|
static int mixer_get_left (int i)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user