1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

Merge branch 'master' into imlib2

Conflicts:
	extras/nano/conky.nanorc
	extras/vim/syntax/conkyrc.vim
This commit is contained in:
Brenden Matthews 2009-05-17 22:11:40 -06:00
commit ddcc8ceb70
16 changed files with 622 additions and 101 deletions

View File

@ -309,10 +309,11 @@ Thomas Cort
Toni <bleach at users dot sourceforge dot net>
exec*/tail/head output evalution
Toni Spets hifi <spets at users dot sourceforge dot net>
Toni Spets hifi <toni.spets at iki dot fi>
OpenBSD support
Linux wifi code
RSS code (created with Mikko Sysikaski)
RSS code (created together with Mikko Sysikaski)
Lua scripting
Tris <asto at users dot sourceforge dot net>
Scroll step patch

View File

@ -1,3 +1,6 @@
2009-05-17
* Added support for the Lua programming language
2009-05-11
* Added arguments to hwmon for value precalculation

View File

@ -324,6 +324,24 @@ if test x$want_rss = xyes; then
AC_DEFINE(RSS, 1, [Define if you want rss support])
fi
dnl
dnl Lua
dnl
AC_ARG_ENABLE([lua],
AC_HELP_STRING([--enable-lua], [enable if you want Lua scripting support @<:@default=no@:>@]),
[want_lua="$enableval"], [want_lua=no])
#
AM_CONDITIONAL(BUILD_LUA, test x$want_lua = xyes)
if test x$want_lua = xyes; then
PKG_CHECK_MODULES(LUA, lua >= 5.1, [ ],[
PKG_CHECK_MODULES(LUA51, lua5.1 >= 5.1, [ ])
])
CFLAGS="$CFLAGS $LUA_CFLAGS $LUA51_CFLAGS"
LIBS="$LIBS $LUA_LIBS $LUA51_LIBS"
AC_DEFINE(HAVE_LUA, 1, [Define if you want Lua scripting support])
fi
dnl
dnl Wireless extensions
dnl
@ -789,6 +807,7 @@ $PACKAGE $VERSION configured successfully:
hddtemp: $want_hddtemp
portmon: $want_portmon
RSS: $want_rss
Lua: $want_lua
wireless: $want_wlan
IBM: $want_ibm
nvidia: $want_nvidia

View File

@ -520,6 +520,13 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>lua_load</option></command></term>
<listitem>
Loads the Lua scripts separated by spaces.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>TEXT</option></command></term>
<listitem>

View File

@ -16,7 +16,7 @@
<firstname>Brenden</firstname>
<surname>Matthews</surname>
</author>
<date>2009-05-01</date>
<date>2009-05-16</date>
</refentryinfo>
<refmeta>

View File

@ -2351,6 +2351,66 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua</option></command>
<option>function_name (function parameters)</option>
</term>
<listitem>
Executes a Lua function with given parameters, then prints the returned string. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua_parse</option></command>
<option>function_name (function parameters)</option>
</term>
<listitem>
Executes a Lua function with given parameters as per $lua, then parses and prints the result value as per the syntax for Conky's TEXT section. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua_read_parse</option></command>
<option>function_name (conky text)</option>
</term>
<listitem>
Executes a Lua function per $lua, except takes a 2nd argument which is first evaluated as per Conky's TEXT section and passed to the function first. The return value is then parsed and prints the result value as per the syntax for Conky's TEXT section. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua_bar</option></command>
<option>(height, width) function_name (function parameters)</option>
</term>
<listitem>
Executes a Lua function with given parameters and draws a bar. Expects result value to be an integer between 0 and 100. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua_graph</option></command>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) function_name (function parameters)</option>
</term>
<listitem>
Executes a Lua function with given parameters and draws a graph. Expects result value to be an integer between 0 and 100. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>lua_gauge</option></command>
<option>(height, width) function_name (function parameters)</option>
</term>
<listitem>
Executes a Lua function with given parameters and draws a gauge. Expects result value to be an integer between 0 and 100. See also 'lua_load' on how to load scripts.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>tab</option></command>

View File

@ -5,13 +5,13 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items
color green "\<(alias|alignment|append_file|background|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|gap_x|gap_y|if_up_strictness|imap|imlib_cache_size|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
color green "\<(alias|alignment|append_file|background|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|gap_x|gap_y|if_up_strictness|imap|imlib_cache_size|lua_load|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
## Configuration item constants
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>"
## Variables
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|adt746xcpu|adt746xfan|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|machine|mails|mboxscan|mem|membar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|platform|pop3_unseen|pop3_used|pre_exec|processes|replied_mails|rss|running_processes|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|time|top|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|utime|voffset|voltage_mv|voltage_v|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|adt746xcpu|adt746xfan|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|lua_read_parse|machine|mails|mboxscan|mem|membar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|platform|pop3_unseen|pop3_used|pre_exec|processes|replied_mails|rss|running_processes|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|time|top|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|utime|voffset|voltage_mv|voltage_v|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"

View File

@ -12,7 +12,7 @@ endif
syn region ConkyrcComment start=/^\s*#/ end=/$/
syn keyword ConkyrcSetting alias alignment append_file background border_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font gap_x gap_y if_up_strictness imap imlib_cache_size mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
syn keyword ConkyrcSetting alias alignment append_file background border_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font gap_x gap_y if_up_strictness imap imlib_cache_size lua_load mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
syn keyword ConkyrcConstant
\ above
@ -49,7 +49,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV
syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs adt746xcpu adt746xfan alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler kernel laptop_mode lines loadavg loadgraph machine mails mboxscan mem membar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery platform pop3_unseen pop3_used pre_exec processes replied_mails rss running_processes scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci time top top_mem top_time totaldown totalup trashed_mails tztime unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times utime voffset voltage_mv voltage_v wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs adt746xcpu adt746xfan alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse lua_read_parse machine mails mboxscan mem membar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery platform pop3_unseen pop3_used pre_exec processes replied_mails rss running_processes scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci time top top_mem top_time totaldown totalup trashed_mails tztime unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times utime voffset voltage_mv voltage_v wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
hi def link ConkyrcComment Comment
hi def link ConkyrcSetting Keyword

View File

@ -111,6 +111,10 @@ if BUILD_RSS
rss = rss.c prss.c prss.h
endif
if BUILD_LUA
lua = llua.c llua.h
endif
if BUILD_NVIDIA
nvidia = nvidia.c nvidia.h
endif
@ -149,6 +153,7 @@ conky_SOURCES = \
$(port_monitors) \
$(eve) \
$(rss) \
$(lua) \
$(solaris) \
timed_thread.c \
timed_thread.h \
@ -198,6 +203,7 @@ EXTRA_DIST = \
libtcp-portmon.c \
libtcp-portmon.h \
rss.h \
llua.h \
mail.h \
mixer.h \
moc.h \

View File

@ -196,6 +196,9 @@ static void print_version(void)
#ifdef RSS
" * RSS\n"
#endif /* RSS */
#ifdef HAVE_LUA
" * Lua\n"
#endif /* HAVE_LUA */
#ifdef HAVE_IWLIB
" * wireless\n"
#endif /* HAVE_IWLIB */
@ -631,8 +634,11 @@ static struct text_object *new_text_object_internal(void)
return obj;
}
/* free the list of text objects root points to */
static void free_text_objects(struct text_object *root)
/*
* Frees the list of text objects root points to. When internal = 1, it won't
* free global objects.
*/
static void free_text_objects(struct text_object *root, int internal)
{
struct text_object *obj;
@ -704,7 +710,7 @@ static void free_text_objects(struct text_object *root)
break;
case OBJ_if_empty:
case OBJ_if_match:
free_text_objects(obj->sub);
free_text_objects(obj->sub, 1);
free(obj->sub);
/* fall through */
case OBJ_if_existing:
@ -852,6 +858,18 @@ static void free_text_objects(struct text_object *root)
free(data.rss.action);
break;
#endif
#ifdef HAVE_LUA
case OBJ_lua:
case OBJ_lua_parse:
case OBJ_lua_read_parse:
#ifdef X11
case OBJ_lua_bar:
case OBJ_lua_graph:
case OBJ_lua_gauge:
#endif /* X11 */
free(data.s);
break;
#endif /* HAVE_LUA */
case OBJ_pre_exec:
break;
#ifndef __OpenBSD__
@ -885,10 +903,11 @@ static void free_text_objects(struct text_object *root)
case OBJ_top:
case OBJ_top_mem:
case OBJ_top_time:
if (info.first_process) {
if (info.first_process && !internal) {
free_all_processes();
info.first_process = NULL;
}
if (data.top.s) free(data.top.s);
break;
#ifdef HDDTEMP
case OBJ_hddtemp:
@ -978,14 +997,14 @@ static void free_text_objects(struct text_object *root)
#endif
case OBJ_scroll:
free(data.scroll.text);
free_text_objects(obj->sub);
free_text_objects(obj->sub, 1);
free(obj->sub);
break;
case OBJ_combine:
free(data.combine.left);
free(data.combine.seperation);
free(data.combine.right);
free_text_objects(obj->sub);
free_text_objects(obj->sub, 1);
free(obj->sub);
break;
#ifdef APCUPSD
@ -1053,6 +1072,74 @@ static const char *dev_name(const char *path)
#undef DEV_NAME
}
static int parse_top_args(const char *s, const char *arg, struct text_object *obj)
{
char buf[64];
int n;
if (obj->data.top.was_parsed) {
return 1;
}
obj->data.top.was_parsed = 1;
if (arg && !obj->data.top.s) {
obj->data.top.s = strndup(arg, text_buffer_size);
}
need_mask |= (1 << INFO_TOP);
if (s[3] == 0) {
obj->type = OBJ_top;
top_cpu = 1;
} else if (strcmp(&s[3], "_mem") == EQUAL) {
obj->type = OBJ_top_mem;
top_mem = 1;
} else if (strcmp(&s[3], "_time") == EQUAL) {
obj->type = OBJ_top_time;
top_time = 1;
} else {
ERR("Must be top, top_mem or top_time");
return 0;
}
if (!arg) {
ERR("top needs arguments");
return 0;
}
if (sscanf(arg, "%63s %i", buf, &n) == 2) {
if (strcmp(buf, "name") == EQUAL) {
obj->data.top.type = TOP_NAME;
} else if (strcmp(buf, "cpu") == EQUAL) {
obj->data.top.type = TOP_CPU;
} else if (strcmp(buf, "pid") == EQUAL) {
obj->data.top.type = TOP_PID;
} else if (strcmp(buf, "mem") == EQUAL) {
obj->data.top.type = TOP_MEM;
} else if (strcmp(buf, "time") == EQUAL) {
obj->data.top.type = TOP_TIME;
} else if (strcmp(buf, "mem_res") == EQUAL) {
obj->data.top.type = TOP_MEM_RES;
} else if (strcmp(buf, "mem_vsize") == EQUAL) {
obj->data.top.type = TOP_MEM_VSIZE;
} else {
ERR("invalid type arg for top");
ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize");
return 0;
}
if (n < 1 || n > 10) {
ERR("invalid num arg for top. Must be between 1 and 10.");
return 0;
} else {
obj->data.top.num = n - 1;
}
} else {
ERR("invalid argument count for top");
return 0;
}
return 1;
}
/* construct_text_object() creates a new text_object */
static struct text_object *construct_text_object(const char *s,
const char *arg, long line, char allow_threaded, void **ifblock_opaque)
@ -1765,58 +1852,7 @@ static struct text_object *construct_text_object(const char *s,
* avoid having almost-same code three times, we have this special
* handler. */
if (strncmp(s, "top", 3) == EQUAL) {
char buf[64];
int n;
need_mask |= (1 << INFO_TOP);
if (s[3] == 0) {
obj->type = OBJ_top;
top_cpu = 1;
} else if (strcmp(&s[3], "_mem") == EQUAL) {
obj->type = OBJ_top_mem;
top_mem = 1;
} else if (strcmp(&s[3], "_time") == EQUAL) {
obj->type = OBJ_top_time;
top_time = 1;
} else {
ERR("Must be top, top_mem or top_time");
return NULL;
}
if (!arg) {
ERR("top needs arguments");
return NULL;
}
if (sscanf(arg, "%63s %i", buf, &n) == 2) {
if (strcmp(buf, "name") == EQUAL) {
obj->data.top.type = TOP_NAME;
} else if (strcmp(buf, "cpu") == EQUAL) {
obj->data.top.type = TOP_CPU;
} else if (strcmp(buf, "pid") == EQUAL) {
obj->data.top.type = TOP_PID;
} else if (strcmp(buf, "mem") == EQUAL) {
obj->data.top.type = TOP_MEM;
} else if (strcmp(buf, "time") == EQUAL) {
obj->data.top.type = TOP_TIME;
} else if (strcmp(buf, "mem_res") == EQUAL) {
obj->data.top.type = TOP_MEM_RES;
} else if (strcmp(buf, "mem_vsize") == EQUAL) {
obj->data.top.type = TOP_MEM_VSIZE;
} else {
ERR("invalid type arg for top");
ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize");
return NULL;
}
if (n < 1 || n > 10) {
ERR("invalid num arg for top. Must be between 1 and 10.");
return NULL;
} else {
obj->data.top.num = n - 1;
}
} else {
ERR("invalid argument count for top");
if (!parse_top_args(s, arg, obj)) {
return NULL;
}
} else OBJ(addr, INFO_NET)
@ -1845,13 +1881,13 @@ static struct text_object *construct_text_object(const char *s,
}
END OBJ(lines, 0)
if (arg) {
obj->data.s = strdup(arg);
obj->data.s = strndup(arg, text_buffer_size);
}else{
CRIT_ERR("lines needs a argument");
}
END OBJ(words, 0)
if (arg) {
obj->data.s = strdup(arg);
obj->data.s = strndup(arg, text_buffer_size);
}else{
CRIT_ERR("words needs a argument");
}
@ -2571,6 +2607,62 @@ static struct text_object *construct_text_object(const char *s,
"[act_par] [spaces in front]");
}
#endif
#ifdef HAVE_LUA
END OBJ(lua, 0)
if (arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua needs arguments: <function name> [function parameters]");
}
END OBJ(lua_parse, 0)
if (arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua_parse needs arguments: <function name> [function parameters]");
}
END OBJ(lua_read_parse, 0)
if (arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua_read_parse needs arguments: <function name> <string to pass>");
}
#ifdef X11
END OBJ(lua_bar, 0)
if (arg) {
arg = scan_bar(arg, &obj->a, &obj->b);
if(arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
}
} else {
CRIT_ERR("lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
}
END OBJ(lua_graph, 0)
if (arg) {
arg = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e, &obj->showaslog);
if (arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua_graph needs arguments: <\"normal\"|\"log\"> <height>,<width> <gradient colour 1> <gradient colour 2> <scale> <function name> [function parameters]");
}
} else {
CRIT_ERR("lua_graph needs arguments: <\"normal\"|\"log\"> <height>,<width> <gradient colour 1> <gradient colour 2> <scale> <function name> [function parameters]");
}
END OBJ(lua_gauge, 0)
if (arg) {
arg = scan_gauge(arg, &obj->a, &obj->b);
if (arg) {
obj->data.s = strndup(arg, text_buffer_size);
} else {
CRIT_ERR("lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
}
} else {
CRIT_ERR("lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
}
#endif /* X11 */
#endif /* HAVE_LUA */
#ifdef HDDTEMP
END OBJ(hddtemp, 0)
if (scan_hddtemp(arg, &obj->data.hddtemp.dev,
@ -3090,7 +3182,7 @@ static int extract_variable_text_internal(struct text_object *retval, const char
static void extract_variable_text(const char *p)
{
free_text_objects(&global_root_object);
free_text_objects(&global_root_object, 0);
if (tmpstring1) {
free(tmpstring1);
tmpstring1 = 0;
@ -3738,8 +3830,8 @@ static void generate_text_internal(char *p, int p_max_size,
DBGP("evaluated '%s' to '%s'", obj->data.s, p);
parse_conky_vars(&subroot2, p, p, tmp_info);
free_text_objects(&subroot);
free_text_objects(&subroot2);
free_text_objects(&subroot, 1);
free_text_objects(&subroot2, 1);
free(tmp_info);
}
OBJ(exec) {
@ -3756,7 +3848,7 @@ static void generate_text_internal(char *p, int p_max_size,
memcpy(tmp_info, cur, sizeof(struct information));
parse_conky_vars(&subroot, p, p, tmp_info);
free_text_objects(&subroot);
free_text_objects(&subroot, 1);
free(tmp_info);
}
#ifdef X11
@ -3774,26 +3866,29 @@ static void generate_text_internal(char *p, int p_max_size,
#endif
OBJ(execbar) {
double barnum;
#ifndef X11
int i;
#endif
read_exec(obj->data.s, p, text_buffer_size);
barnum = get_barnum(p);
if (barnum >= 0.0) {
#ifdef X11
barnum /= 100;
new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
#else
barnum = round_to_int( ( barnum * obj->a ) / 100);
for(i=0; i<barnum; i++) {
*(p+i)='#';
if(output_methods & TO_X) {
barnum /= 100;
new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
}else{
#endif
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
barnum = round_to_int( ( barnum * obj->a ) / 100);
for(i=0; i<barnum; i++) {
*(p+i)='#';
}
for(; i < obj->a; i++) {
*(p+i)='_';
}
*(p+i)=0;
#ifdef X11
}
for(; i < obj->a; i++) {
*(p+i)='_';
}
*(p+i)=0;
#endif
}
}
@ -3898,7 +3993,7 @@ static void generate_text_internal(char *p, int p_max_size,
parse_conky_vars(&subroot, obj->data.execi.buffer, p, tmp_info);
obj->data.execi.last_update = current_update_time;
}
free_text_objects(&subroot);
free_text_objects(&subroot, 1);
free(tmp_info);
}
OBJ(texeci) {
@ -4145,6 +4240,75 @@ static void generate_text_internal(char *p, int p_max_size,
}
}
#endif
#ifdef HAVE_LUA
OBJ(lua) {
char *str = llua_getstring(obj->data.s);
if (str) {
snprintf(p, p_max_size, "%s", str);
free(str);
}
}
OBJ(lua_parse) {
char *str = llua_getstring(obj->data.s);
if (str) {
struct information *tmp_info;
struct text_object subroot;
tmp_info = malloc(sizeof(struct information));
memcpy(tmp_info, cur, sizeof(struct information));
parse_conky_vars(&subroot, str, p, tmp_info);
free_text_objects(&subroot, 1);
free(tmp_info);
free(str);
}
}
OBJ(lua_read_parse) {
struct information *tmp_info;
struct text_object subroot, subroot2;
char func[64];
char *text, *str;
sscanf(obj->data.s, "%64s", func);
text = obj->data.s + strlen(func) + 1;
tmp_info = malloc(sizeof(struct information));
memcpy(tmp_info, cur, sizeof(struct information));
parse_conky_vars(&subroot, text, p, tmp_info);
DBGP("evaluated '%s' to '%s'", text, p);
str = llua_getstring_read(func, p);
if (str) {
parse_conky_vars(&subroot2, str, p, tmp_info);
DBGP("evaluated '%s' to '%s'", str, p);
free(str);
free_text_objects(&subroot2, 1);
}
free_text_objects(&subroot, 1);
free(tmp_info);
}
#ifdef X11
OBJ(lua_bar) {
int per;
if (llua_getinteger(obj->data.s, &per)) {
new_bar(p, obj->a, obj->b, (per/100.0 * 255));
}
}
OBJ(lua_graph) {
int per;
if (llua_getinteger(obj->data.s, &per)) {
new_graph(p, obj->a, obj->b, obj->c, obj->d,
(per/100.0 * 255), 100, 1, obj->showaslog);
}
}
OBJ(lua_gauge) {
int per;
if (llua_getinteger(obj->data.s, &per)) {
new_gauge(p, obj->a, obj->b, (per/100.0 * 255));
}
}
#endif /* X11 */
#endif /* HAVE_LUA */
#ifdef HDDTEMP
OBJ(hddtemp) {
char *endptr, unit;
@ -4866,35 +5030,38 @@ static void generate_text_internal(char *p, int p_max_size,
* times, we have this special handler. */
break;
case OBJ_top:
parse_top_args("top", obj->data.top.s, obj);
if (!needed) needed = cur->cpu;
case OBJ_top_mem:
parse_top_args("top_mem", obj->data.top.s, obj);
if (!needed) needed = cur->memu;
case OBJ_top_time:
parse_top_args("top_time", obj->data.top.s, obj);
if (!needed) needed = cur->time;
{
if (needed[obj->data.top.num]) {
char *timeval;
switch (obj->data.top.type) {
case TOP_NAME:
snprintf(p, top_name_width + 1, "%-*s", top_name_width,
needed[obj->data.top.num]->name);
needed[obj->data.top.num]->name);
break;
case TOP_CPU:
snprintf(p, 7, "%6.2f",
needed[obj->data.top.num]->amount);
needed[obj->data.top.num]->amount);
break;
case TOP_PID:
snprintf(p, 6, "%5i",
needed[obj->data.top.num]->pid);
needed[obj->data.top.num]->pid);
break;
case TOP_MEM:
snprintf(p, 7, "%6.2f",
needed[obj->data.top.num]->totalmem);
needed[obj->data.top.num]->totalmem);
break;
case TOP_TIME:
timeval = format_time(
needed[obj->data.top.num]->total_cpu_time, 9);
needed[obj->data.top.num]->total_cpu_time, 9);
snprintf(p, 10, "%9s", timeval);
free(timeval);
break;
@ -5805,7 +5972,7 @@ static void draw_line(char *s)
XDrawLine(display, window.drawable, window.gc,
cur_x + (w/2.), by+(h), (int)(px), (int)(py));
#endif
#endif /* MATH */
if (h > cur_y_add
&& h > font_h) {
@ -6598,6 +6765,10 @@ static void reload_config(void)
tcp_portmon_clear();
#endif
#ifdef HAVE_LUA
llua_close();
#endif /* HAVE_LUA */
if (current_config) {
clear_fs_stats();
load_config_file(current_config);
@ -6673,7 +6844,7 @@ static void clean_up(void)
#endif /* X11 */
free_text_objects(&global_root_object);
free_text_objects(&global_root_object, 0);
if (tmpstring1) {
free(tmpstring1);
tmpstring1 = 0;
@ -6700,6 +6871,9 @@ static void clean_up(void)
#ifdef RSS
free_rss_info();
#endif
#ifdef HAVE_LUA
llua_close();
#endif /* HAVE_LUA */
if (specials) {
unsigned int i;
@ -7670,6 +7844,20 @@ static void load_config_file(const char *f)
CONF_ERR;
}
}
#ifdef HAVE_LUA
CONF("lua_load") {
llua_init();
if(value) {
char *ptr = strtok(value, " ");
while(ptr) {
llua_load(ptr);
ptr = strtok(NULL, " ");
}
} else {
CONF_ERR;
}
}
#endif /* HAVE_LUA */
CONF("color0"){}
CONF("color1"){}

View File

@ -43,6 +43,7 @@
#define FALSE 0
#define TRUE 1
#define DEFAULT_BAR_WIDTH_NO_X 10
#if !defined(__GNUC__)
# define __attribute__(x) /* nothing */
@ -90,6 +91,10 @@ char *strndup(const char *s, size_t n);
#include "rss.h"
#endif
#ifdef HAVE_LUA
#include "llua.h"
#endif
#ifdef TCP_PORT_MONITOR
#include "tcp-portmon.h"
#endif

View File

@ -65,8 +65,6 @@
#define SHORTSTAT_TEMPL "%*s %llu %llu %llu"
#define LONGSTAT_TEMPL "%*s %llu %llu %llu "
static int show_nice_processes;
/* This flag tells the linux routines to use the /proc system where possible,
* even if other api's are available, e.g. sysinfo() or getloadavg().
* the reason for this is to allow for /proc-based distributed monitoring.
@ -2081,7 +2079,6 @@ void get_powerbook_batt_info(char *buffer, size_t n, int i)
void update_top(void)
{
show_nice_processes = 1;
process_find_top(info.cpu, info.memu, info.time);
info.first_process = get_first_process();
}

182
src/llua.c Normal file
View File

@ -0,0 +1,182 @@
/* Conky, a system monitor, based on torsmo
*
* Any original torsmo code is licensed under the BSD license
*
* All code written since the fork of torsmo is licensed under the GPL
*
* Please see COPYING for details
*
* Copyright (c) 2009 Toni Spets
* Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "conky.h"
#include "logging.h"
lua_State *lua_L = NULL;
void llua_init(void)
{
if(lua_L) return;
lua_L = lua_open();
luaL_openlibs(lua_L);
}
void llua_load(const char *script)
{
int error;
if(!lua_L) return;
error = luaL_dofile(lua_L, script);
if (error) {
ERR("llua_load: %s", lua_tostring(lua_L, -1));
lua_pop(lua_L, 1);
}
}
/*
llua_do_call does a flexible call to any Lua function
string: <function> [par1] [par2...]
retc: the number of return values expected
*/
char *llua_do_call(const char *string, int retc)
{
static char func[64];
int argc = 0;
char *tmp = strdup(string);
char *ptr = strtok(tmp, " ");
/* proceed only if the function name is present */
if(!ptr) {
free(tmp);
return NULL;
}
/* call only conky_ prefixed functions */
snprintf(func, 64, "conky_%s", ptr);
/* push the function name to stack */
lua_getglobal(lua_L, func);
/* parse all function parameters from args and push them to the stack */
ptr = strtok(NULL, " ");
while(ptr) {
lua_pushstring(lua_L, ptr);
ptr = strtok(NULL, " ");
argc++;
}
free(tmp);
if(lua_pcall(lua_L, argc, retc, 0) != 0) {
ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1));
lua_pop(lua_L, -1);
return NULL;
}
return func;
}
/*
* same as llua_do_call() except passes everything after func as one arg.
*/
char *llua_do_read_call(const char *function, const char *arg, int retc)
{
static char func[64];
snprintf(func, 64, "conky_%s", function);
/* push the function name to stack */
lua_getglobal(lua_L, func);
/* push function parameter to the stack */
lua_pushstring(lua_L, arg);
if (lua_pcall(lua_L, 1, retc, 0) != 0) {
ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1));
lua_pop(lua_L, -1);
return NULL;
}
return func;
}
char *llua_getstring(const char *args)
{
char *func;
char *ret = NULL;
if(!lua_L) return NULL;
func = llua_do_call(args, 1);
if(func) {
if(!lua_isstring(lua_L, -1)) {
ERR("llua_getstring: function %s didn't return a string, result discarded", func);
} else {
ret = strdup(lua_tostring(lua_L, -1));
lua_pop(lua_L, 1);
}
}
return ret;
}
char *llua_getstring_read(const char *function, const char *arg)
{
char *func;
char *ret = NULL;
if(!lua_L) return NULL;
func = llua_do_read_call(function, arg, 1);
if (func) {
if(!lua_isstring(lua_L, -1)) {
ERR("llua_getstring_read: function %s didn't return a string, result discarded", func);
} else {
ret = strdup(lua_tostring(lua_L, -1));
lua_pop(lua_L, 1);
}
}
return ret;
}
int llua_getinteger(const char *args, int *per)
{
char *func;
if(!lua_L) return 0;
func = llua_do_call(args, 1);
if(func) {
if(!lua_isnumber(lua_L, -1)) {
ERR("llua_getinteger: function %s didn't return an integer, result discarded", func);
} else {
*per = lua_tointeger(lua_L, -1);
lua_pop(lua_L, 1);
return 1;
}
}
return 0;
}
void llua_close(void)
{
if(!lua_L) return;
lua_close(lua_L);
lua_L = NULL;
}

42
src/llua.h Normal file
View File

@ -0,0 +1,42 @@
/* Conky, a system monitor, based on torsmo
*
* Any original torsmo code is licensed under the BSD license
*
* All code written since the fork of torsmo is licensed under the GPL
*
* Please see COPYING for details
*
* Copyright (c) 2009 Toni Spets
* Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LUA_H_
#define LUA_H_
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
void llua_init(void);
void llua_load(const char *script);
char *llua_getstring(const char *args);
char *llua_getstring_read(const char *function, const char *arg);
int llua_getinteger(const char *args, int *per);
void llua_close(void);
#endif /* LUA_H_*/

View File

@ -42,12 +42,10 @@ struct special_t *specials = NULL;
unsigned int special_count;
#ifdef X11
int default_bar_width = 0, default_bar_height = 6;
#ifdef X11
int default_graph_width = 0, default_graph_height = 25;
int default_gauge_width = 50, default_gauge_height = 25;
#else
int default_bar_width = 10, default_bar_height = 1;
int default_gauge_width = 40, default_gauge_height = 25;
#endif
/*
@ -66,8 +64,9 @@ const char *scan_gauge(const char *args, int *w, int *h)
int n = 0;
if (sscanf(args, "%d,%d %n", h, w, &n) <= 1) {
sscanf(args, "%d %n", h, &n);
*w = *h; /*square gauge*/
if (sscanf(args, "%d %n", h, &n) == 2) {
*w = *h; /*square gauge*/
}
}
args += n;
}

View File

@ -380,6 +380,16 @@ enum text_object_type {
#ifdef RSS
OBJ_rss,
#endif
#ifdef HAVE_LUA
OBJ_lua,
OBJ_lua_parse,
OBJ_lua_read_parse,
#ifdef X11
OBJ_lua_bar,
OBJ_lua_graph,
OBJ_lua_gauge,
#endif /* X11 */
#endif /* HAVE_LUA */
#ifdef TCP_PORT_MONITOR
OBJ_tcp_portmon,
#endif
@ -473,6 +483,8 @@ struct text_object {
struct {
int num;
int type;
int was_parsed;
char *s;
} top;
struct {