1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-14 03:23:29 +00:00

Let lua_bar work in shell

This commit is contained in:
Nikolas Garofil 2009-06-03 17:58:00 +02:00
parent 09ac517343
commit 5388fc33f6
2 changed files with 22 additions and 13 deletions

View File

@ -886,8 +886,8 @@ static void free_text_objects(struct text_object *root, int internal)
case OBJ_lua: case OBJ_lua:
case OBJ_lua_parse: case OBJ_lua_parse:
case OBJ_lua_read_parse: case OBJ_lua_read_parse:
#ifdef X11
case OBJ_lua_bar: case OBJ_lua_bar:
#ifdef X11
case OBJ_lua_graph: case OBJ_lua_graph:
case OBJ_lua_gauge: case OBJ_lua_gauge:
#endif /* X11 */ #endif /* X11 */
@ -913,7 +913,7 @@ static void free_text_objects(struct text_object *root, int internal)
#ifdef X11 #ifdef X11
case OBJ_execigraph: case OBJ_execigraph:
case OBJ_execigauge: case OBJ_execigauge:
#endif #endif /* X11 */
free(data.execi.cmd); free(data.execi.cmd);
free(data.execi.buffer); free(data.execi.buffer);
break; break;
@ -940,12 +940,12 @@ static void free_text_objects(struct text_object *root, int internal)
if (data.hddtemp.temp) if (data.hddtemp.temp)
free(data.hddtemp.temp); free(data.hddtemp.temp);
break; break;
#endif #endif /* HDDTEMP */
case OBJ_entropy_avail: case OBJ_entropy_avail:
case OBJ_entropy_poolsize: case OBJ_entropy_poolsize:
#ifdef X11 #ifdef X11
case OBJ_entropy_bar: case OBJ_entropy_bar:
#endif #endif /* X11 */
break; break;
case OBJ_user_names: case OBJ_user_names:
if (info.users.names) { if (info.users.names) {
@ -976,11 +976,11 @@ static void free_text_objects(struct text_object *root, int internal)
free(data.ifblock.s); free(data.ifblock.s);
free(data.ifblock.str); free(data.ifblock.str);
break; break;
#endif #endif /* IBM */
#ifdef NVIDIA #ifdef NVIDIA
case OBJ_nvidia: case OBJ_nvidia:
break; break;
#endif #endif /* NVIDIA */
#ifdef MPD #ifdef MPD
case OBJ_mpd_title: case OBJ_mpd_title:
case OBJ_mpd_artist: case OBJ_mpd_artist:
@ -992,7 +992,7 @@ static void free_text_objects(struct text_object *root, int internal)
case OBJ_mpd_status: case OBJ_mpd_status:
#ifdef X11 #ifdef X11
case OBJ_mpd_bar: case OBJ_mpd_bar:
#endif #endif /* X11 */
case OBJ_mpd_elapsed: case OBJ_mpd_elapsed:
case OBJ_mpd_length: case OBJ_mpd_length:
case OBJ_mpd_track: case OBJ_mpd_track:
@ -1003,7 +1003,7 @@ static void free_text_objects(struct text_object *root, int internal)
case OBJ_if_mpd_playing: case OBJ_if_mpd_playing:
free_mpd(); free_mpd();
break; break;
#endif #endif /* MPD */
#ifdef MOC #ifdef MOC
case OBJ_moc_state: case OBJ_moc_state:
case OBJ_moc_file: case OBJ_moc_file:
@ -1018,7 +1018,7 @@ static void free_text_objects(struct text_object *root, int internal)
case OBJ_moc_rate: case OBJ_moc_rate:
free_moc(); free_moc();
break; break;
#endif #endif /* MOC */
case OBJ_scroll: case OBJ_scroll:
free(data.scroll.text); free(data.scroll.text);
free_text_objects(obj->sub, 1); free_text_objects(obj->sub, 1);
@ -2692,7 +2692,6 @@ static struct text_object *construct_text_object(const char *s,
} else { } else {
CRIT_ERR("lua_read_parse needs arguments: <function name> <string to pass>"); CRIT_ERR("lua_read_parse needs arguments: <function name> <string to pass>");
} }
#ifdef X11
END OBJ(lua_bar, 0) END OBJ(lua_bar, 0)
SIZE_DEFAULTS(bar); SIZE_DEFAULTS(bar);
if (arg) { if (arg) {
@ -2705,6 +2704,7 @@ static struct text_object *construct_text_object(const char *s,
} else { } else {
CRIT_ERR("lua_bar needs arguments: <height>,<width> <function name> [function parameters]"); CRIT_ERR("lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
} }
#ifdef X11
END OBJ(lua_graph, 0) END OBJ(lua_graph, 0)
SIZE_DEFAULTS(graph); SIZE_DEFAULTS(graph);
if (arg) { if (arg) {
@ -4449,13 +4449,22 @@ static void generate_text_internal(char *p, int p_max_size,
free_text_objects(&subroot, 1); free_text_objects(&subroot, 1);
free(tmp_info); free(tmp_info);
} }
#ifdef X11
OBJ(lua_bar) { OBJ(lua_bar) {
int per; int per;
if (llua_getinteger(obj->data.s, &per)) { if (llua_getinteger(obj->data.s, &per)) {
new_bar(p, obj->a, obj->b, (per/100.0 * 255)); #ifdef X11
if(output_methods & TO_X) {
new_bar(p, obj->a, obj->b, (per/100.0 * 255));
} else {
#endif /* X11 */
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size, per, obj->a);
#ifdef X11
}
#endif /* X11 */
} }
} }
#ifdef X11
OBJ(lua_graph) { OBJ(lua_graph) {
int per; int per;
if (llua_getinteger(obj->data.s, &per)) { if (llua_getinteger(obj->data.s, &per)) {

View File

@ -378,8 +378,8 @@ enum text_object_type {
OBJ_lua, OBJ_lua,
OBJ_lua_parse, OBJ_lua_parse,
OBJ_lua_read_parse, OBJ_lua_read_parse,
#ifdef X11
OBJ_lua_bar, OBJ_lua_bar,
#ifdef X11
OBJ_lua_graph, OBJ_lua_graph,
OBJ_lua_gauge, OBJ_lua_gauge,
#endif /* X11 */ #endif /* X11 */