diff --git a/.gitignore b/.gitignore
index 888588cf..961d3bb7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ patches/
doc/conky.1
README
build*
+doc/*.html
diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake
index 0187d7f4..541f919c 100644
--- a/cmake/ConkyBuildOptions.cmake
+++ b/cmake/ConkyBuildOptions.cmake
@@ -54,7 +54,6 @@ set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide
set(PACKAGE_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib/conky" CACHE STRING "Package library path (where Lua bindings are installed" FORCE)
set(DEFAULTNETDEV "eth0" CACHE STRING "Default networkdevice")
set(CONFIG_FILE "$HOME/.conkyrc" CACHE STRING "Configfile of the user")
-set(MAX_SPECIALS_DEFAULT "512" CACHE STRING "Default maximum number of special things, e.g. fonts, offsets, aligns, etc.")
set(MAX_USER_TEXT_DEFAULT "16384" CACHE STRING "Default maximum size of config TEXT buffer, i.e. below TEXT line.")
set(DEFAULT_TEXT_BUFFER_SIZE "256" CACHE STRING "Default size used for temporary, static text buffers")
set(MAX_NET_INTERFACES "16" CACHE STRING "Maximum number of network devices")
@@ -127,6 +126,8 @@ option(BUILD_BMPX "Build BMPx (music player) support" false)
option(BUILD_MPD "Enable if you want MPD (music player) support" true)
+option(BUILD_MYSQL "Enable if you want MySQL support" true)
+
option(BUILD_MOC "Enable if you want MOC (music player) support" true)
option(BUILD_XMMS2 "Enable if you want XMMS2 (music player) support" false)
diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake
index e33284ad..1341e015 100644
--- a/cmake/ConkyPlatformChecks.cmake
+++ b/cmake/ConkyPlatformChecks.cmake
@@ -80,6 +80,19 @@ if(BUILD_NCURSES)
set(conky_libs ${conky_libs} ${NCURSES_LIB})
endif(BUILD_NCURSES)
+if(BUILD_MYSQL)
+ find_path(mysql_INCLUDE_PATH mysql.h ${INCLUDE_SEARCH_PATH} /usr/include/mysql /usr/local/include/mysql)
+ if(NOT mysql_INCLUDE_PATH)
+ message(FATAL_ERROR "Unable to find mysql.h")
+ endif(NOT mysql_INCLUDE_PATH)
+ set(conky_includes ${conky_includes} ${mysql_INCLUDE_PATH})
+ find_library(MYSQLCLIENT_LIB NAMES mysqlclient)
+ if(NOT MYSQLCLIENT_LIB)
+ message(FATAL_ERROR "Unable to find mysqlclient library")
+ endif(NOT MYSQLCLIENT_LIB)
+ set(conky_libs ${conky_libs} ${MYSQLCLIENT_LIB})
+endif(BUILD_MYSQL)
+
if(BUILD_WLAN)
check_include_file(iwlib.h IWLIB_H -D_GNU_SOURCE)
if(NOT IWLIB_H)
diff --git a/cmake/config.h.in b/cmake/config.h.in
index fad59201..3644a99d 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -15,7 +15,6 @@
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
#define DEFAULTNETDEV "@DEFAULTNETDEV@"
#define CONFIG_FILE "@CONFIG_FILE@"
-#define MAX_SPECIALS_DEFAULT @MAX_SPECIALS_DEFAULT@
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
#define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
@@ -52,6 +51,8 @@
#cmakedefine BUILD_MPD 1
+#cmakedefine BUILD_MYSQL 1
+
#cmakedefine BUILD_MOC 1
#cmakedefine BUILD_NVIDIA 0
diff --git a/doc/command_options.xml b/doc/command_options.xml
index e920e3c2..ad1b0e43 100644
--- a/doc/command_options.xml
+++ b/doc/command_options.xml
@@ -119,6 +119,15 @@
conky -s 'Your uptime is: $uptime'
+
+
+
+
+
+
+ Read configuration from stdin.
+
+
diff --git a/doc/config_settings.xml b/doc/config_settings.xml
index b5a5d973..efdd30ab 100644
--- a/doc/config_settings.xml
+++ b/doc/config_settings.xml
@@ -453,16 +453,6 @@
many connections (if 0 or not set, default is 256)
-
-
-
-
-
-
- Maximum number of special things, e.g. fonts,
- offsets, aligns, etc. (default is 512)
-
-
@@ -534,6 +524,52 @@
Port of MPD server
+
+
+
+
+
+
+ Host of MySQL server. Defaults to localhost
+
+
+
+
+
+
+
+
+ Port of MySQL server. Defaults to the default mysql port
+
+
+
+
+
+
+
+
+ MySQL user name to use when connecting to the server. Defaults to your username
+
+
+
+
+
+
+
+
+ Password of the MySQL user. Place it between "-chars. When this is not set there
+ is no password used
+
+
+
+
+
+
+
+
+ MySQL database to use. Defaults to mysql
+
+
diff --git a/doc/variables.xml b/doc/variables.xml
index 76bf77f6..96b8b4e6 100644
--- a/doc/variables.xml
+++ b/doc/variables.xml
@@ -7,8 +7,8 @@
ACPI ac adapter state. On linux, the adapter option specifies the
- subfolder of /sys/class/power_supply containing the state information (defaults
- to "AC"). Other systems ignore it.
+ subfolder of /sys/class/power_supply containing the state information (tries "AC"
+ and "ADP1" if there is no argument given). Non-linux systems ignore it.
@@ -675,8 +675,8 @@
Download data from URI using Curl at the
- specified interval. The interval may be a floating
- point value greater than 0, otherwise defaults to 15
+ specified interval. The interval may be a positive floating
+ point value (0 is allowed), otherwise defaults to 15
minutes. Most useful when used in conjunction with Lua
and the Lua API. This object is threaded, and once a
thread is created it can't be explicitly destroyed.
@@ -811,6 +811,22 @@
particular graph value (try it and see).
+
+
+
+
+
+
+ The name of the distribution. It could be that some
+ of the untested distributions will show up wrong or as "unknown",
+ if that's the case post a bug on sourceforge, make sure it
+ contains the name of your distribution, the contents of
+ /proc/version and if there is a file that only exists on your
+ distribution, also add the path of that file in the bug. If there
+ is no such file, please add another way which we can use to identify
+ your distribution.
+
+
@@ -2071,15 +2087,10 @@
Prints the mixer value as reported by the OS.
- Default mixer is "vol", but you can specify one of the
- following optional arguments: "vol", "bass", "treble",
- "synth", "pcm", "speaker", "line", "mic", "cd", "mix",
- "pcm2", "rec", "igain", "ogain", "line1", "line2", "line3",
- "dig1", "dig2", "dig3", "phin", "phout", "video", "radio",
- "monitor". Refer to the definition of SOUND_DEVICE_NAMES in
- <linux/soundcard.h> (on Linux), <soundcard.h>
- (on OpenBSD), or <sys/soundcard.h> to find the exact
- options available on your system.
+ Default mixer is "Master", but you can specify one of the
+ available ALSA Simple mixer controls.
+ You can find the list of those available on your system
+ using amixer.
@@ -2407,6 +2418,17 @@
MPD's volume
+
+
+
+
+
+
+
+ Shows the first field of the first row of the
+ result of the query.
+
+
@@ -2440,6 +2462,28 @@
Hostname
+
+
+
+
+
+
+ Short hostname (same as 'hostname -s' shell command).
+
+
+
+
+
+
+
+
+
+ Shows text and parses the vars in it, but doesn't
+ update them. Use this for things that do not change while conky
+ is running, like $machine, $conky_version,... By not updating
+ this you can save some resources.
+
+
@@ -3031,7 +3075,19 @@
Connects to a tcp port on a host (default is
localhost), reads every char available at the moment and
- shows them.
+ shows them.
+
+
+
+
+
+
+
+
+
+ Connects to a udp port on a host (default is
+ localhost), reads every char available at the moment and
+ shows them.
@@ -3217,6 +3273,17 @@
Stippled (dashed) horizontal line
+
+
+
+
+
+
+
+ Displays the data of a stock symbol. The following data
+ is supported: adv(Average Daily Volume),ask,asksize,bid
+
+
diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc
index 70e9f2b5..9ffca656 100644
--- a/extras/nano/conky.nanorc
+++ b/extras/nano/conky.nanorc
@@ -5,13 +5,13 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items
-color green "\<(alignment|append_file|background|border_inner_margin|border_outer_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|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_specials|max_text_width|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_ncurses|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|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
+color green "\<(alignment|append_file|background|border_inner_margin|border_outer_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|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|mysql_host|mysql_port|mysql_user|mysql_password|mysql_db|net_avg_samples|no_buffers|out_to_console|out_to_ncurses|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|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|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|middle_middle|undecorated|yes)\>"
## Variables
-color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|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|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|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|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|memwithbuffers|membar|memwithbuffersbar|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|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|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|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|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|distribution|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|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|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|memwithbuffers|membar|memwithbuffersbar|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|mysql|nameserver|new_mails|nodename|nodename_short|no_update|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|read_udp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|stock|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|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 "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim
index 0ab80c97..27f7c3f0 100644
--- a/extras/vim/syntax/conkyrc.vim
+++ b/extras/vim/syntax/conkyrc.vim
@@ -12,7 +12,7 @@ endif
syn region ConkyrcComment start=/^\s*#/ end=/$/
-syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_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 extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_specials max_text_width 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_ncurses 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 times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
+syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_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 extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval mysql_host mysql_port mysql_user mysql_password mysql_db net_avg_samples no_buffers out_to_console out_to_ncurses 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 times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
syn keyword ConkyrcConstant
\ above
@@ -50,7 +50,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 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 blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time 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 include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem memwithbuffers membar memwithbuffersbar 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 pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used pre_exec processes read_tcp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather 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 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 blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write distribution downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time 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 include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem memwithbuffers membar memwithbuffersbar 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 mysql nameserver new_mails nodename nodename_short no_update nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used pre_exec processes read_tcp read_udp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr stock swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather 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
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dd14714d..f78e9e8c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,7 +36,7 @@ endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc
diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.cc
- mboxscan.cc read_tcp.cc scroll.cc specials.cc tailhead.cc
+ mboxscan.cc read_tcpip.cc scroll.cc specials.cc tailhead.cc
temphelper.cc text_object.cc timeinfo.cc top.cc algebra.cc prioqueue.cc proc.cc
user.cc luamm.cc data-source.cc lua-config.cc setting.cc)
@@ -93,6 +93,11 @@ if(BUILD_MPD)
set(optional_sources ${optional_sources} ${mpd})
endif(BUILD_MPD)
+if(BUILD_MYSQL)
+ set(mysql mysql.cc)
+ set(optional_sources ${optional_sources} ${mysql})
+endif(BUILD_MYSQL)
+
if(BUILD_MOC)
set(moc moc.cc)
set(optional_sources ${optional_sources} ${moc})
diff --git a/src/ccurl_thread.cc b/src/ccurl_thread.cc
index 82401dde..8ed04e99 100644
--- a/src/ccurl_thread.cc
+++ b/src/ccurl_thread.cc
@@ -72,6 +72,7 @@ void ccurl_free_locations(ccurl_location_list &locations)
i != locations.end(); i++) {
free_and_zero((*i)->uri);
free_and_zero((*i)->result);
+ (*i)->p_timed_thread.reset();
}
locations.clear();
}
@@ -222,7 +223,10 @@ void curl_parse_arg(struct text_object *obj, const char *arg)
NORM_ERR("wrong number of arguments for $curl");
return;
}
- cd->interval = interval > 0 ? interval * 60 : 15*60;
+ if (argc == 1)
+ cd->interval = 15*60;
+ else
+ cd->interval = interval > 0 ? interval * 60 : update_interval;
obj->data.opaque = cd;
}
diff --git a/src/common.cc b/src/common.cc
index 98168526..0b584e18 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -30,6 +30,7 @@
#include "config.h"
#include "conky.h"
+#include "core.h"
#include "fs.h"
#include "logging.h"
#include "net_stat.h"
@@ -458,6 +459,25 @@ void print_loadavg(struct text_object *obj, char *p, int p_max_size)
}
}
+void scan_no_update(struct text_object *obj, const char *arg)
+{
+ struct text_object subroot;
+
+ obj->data.s = (char*) malloc(text_buffer_size);
+ parse_conky_vars(&subroot, arg, obj->data.s, text_buffer_size);
+ obj->data.s = (char*) realloc(obj->data.s, strlen(obj->data.s) + 1);
+ free_text_objects(&subroot);
+}
+
+void free_no_update(struct text_object *obj) {
+ free(obj->data.s);
+}
+
+void print_no_update(struct text_object *obj, char *p, int p_max_size)
+{
+ snprintf(p, p_max_size, "%s", obj->data.s);
+}
+
#ifdef BUILD_X11
void scan_loadgraph_arg(struct text_object *obj, const char *arg)
{
@@ -567,6 +587,18 @@ void print_nodename(struct text_object *obj, char *p, int p_max_size)
snprintf(p, p_max_size, "%s", info.uname_s.nodename);
}
+void print_nodename_short(struct text_object *obj, char *p, int p_max_size)
+{
+ (void)obj;
+ snprintf(p, p_max_size, "%s", info.uname_s.nodename);
+ for(int i=0; p[i] != 0; i++) {
+ if(p[i] == '.') {
+ p[i] = 0;
+ break;
+ }
+ }
+}
+
void print_sysname(struct text_object *obj, char *p, int p_max_size)
{
(void)obj;
@@ -787,6 +819,22 @@ void print_include(struct text_object *obj, char *p, int p_max_size)
snprintf(p, p_max_size, "%s", &(buf[0]));
}
+#ifdef BUILD_CURL
+void print_stock(struct text_object *obj, char *p, int p_max_size)
+{
+ if( ! obj->data.s) {
+ p[0] = 0;
+ return;
+ }
+ ccurl_process_info(p, p_max_size, obj->data.s, 0);
+}
+
+void free_stock(struct text_object *obj)
+{
+ free(obj->data.s);
+}
+#endif /* BUILD_CURL */
+
void print_to_bytes(struct text_object *obj, char *p, int p_max_size)
{
std::vector buf(max_user_text);
diff --git a/src/common.h b/src/common.h
index e75bcb3e..68cdca9f 100644
--- a/src/common.h
+++ b/src/common.h
@@ -34,6 +34,8 @@
#include "text_object.h"
#include "setting.hh"
+char* readfile(const char* filename, int* total_read, char showerror);
+
void print_to_bytes(struct text_object *, char *, int);
void add_update_callback(void (*func)(void));
@@ -87,6 +89,10 @@ int get_battery_perct(const char *bat);
double get_battery_perct_bar(struct text_object *);
void get_battery_short_status(char *buf, unsigned int n, const char *bat);
+void scan_no_update(struct text_object *, const char *);
+void print_no_update(struct text_object *, char *, int);
+void free_no_update(struct text_object *);
+
void scan_loadavg_arg(struct text_object *, const char *);
void print_loadavg(struct text_object *, char *, int);
#ifdef BUILD_X11
@@ -114,6 +120,7 @@ double swap_barval(struct text_object *);
void print_kernel(struct text_object *, char *, int);
void print_machine(struct text_object *, char *, int);
void print_nodename(struct text_object *, char *, int);
+void print_nodename_short(struct text_object *, char *, int);
void print_sysname(struct text_object *, char *, int);
void print_uptime(struct text_object *, char *, int);
@@ -156,4 +163,8 @@ void print_include(struct text_object *, char *, int);
void print_updates(struct text_object *, char *, int);
int updatenr_iftest(struct text_object *);
+#ifdef BUILD_CURL
+void print_stock(struct text_object *, char *, int);
+void free_stock(struct text_object *);
+#endif /* BUILD_CURL */
#endif /* _COMMON_H */
diff --git a/src/conky.cc b/src/conky.cc
index f486eed0..4644d65d 100644
--- a/src/conky.cc
+++ b/src/conky.cc
@@ -99,6 +99,9 @@
#include "template.h"
#include "timeinfo.h"
#include "top.h"
+#ifdef BUILD_MYSQL
+#include "mysql.h"
+#endif /* BUILD_MYSQL */
#include "lua-config.hh"
#include "setting.hh"
@@ -323,6 +326,8 @@ struct information info;
/* path to config file */
std::string current_config;
+bool stdinconfig = false;
+
/* set to 1 if you want all text to be in uppercase */
static conky::simple_config_setting stuff_in_uppercase("uppercase", false, true);
@@ -857,6 +862,7 @@ int get_string_width(const char *s)
static int get_string_width_special(char *s, int special_index)
{
char *p, *final;
+ special_t *current = specials;
int idx = 1;
int width = 0;
long i;
@@ -870,6 +876,11 @@ static int get_string_width_special(char *s, int special_index)
p = strndup(s, text_buffer_size);
final = p;
+ for(i = 0; i < special_index; i++)
+ current = current->next;
+ for(i = 0; i < idx; i++)
+ current = current->next;
+
while (*p) {
if (*p == SPECIAL_CHAR) {
/* shift everything over by 1 so that the special char
@@ -877,12 +888,13 @@ static int get_string_width_special(char *s, int special_index)
for (i = 0; i < (long)strlen(p); i++) {
*(p + i) = *(p + i + 1);
}
- if (specials[special_index + idx].type == GRAPH
- || specials[special_index + idx].type == GAUGE
- || specials[special_index + idx].type == BAR) {
- width += specials[special_index + idx].width;
+ if (current->type == GRAPH
+ || current->type == GAUGE
+ || current->type == BAR) {
+ width += current->width;
}
idx++;
+ current = current->next;
} else if (*p == SECRIT_MULTILINE_CHAR) {
*p = 0;
break;
@@ -966,10 +978,12 @@ static void update_text_area(void)
if (own_window.get(*state) && !fixed_pos) {
x += workarea[0];
y += workarea[1];
- text_start_x = window.border_inner_margin + window.border_outer_margin + window.border_width;
- text_start_y = window.border_inner_margin + window.border_outer_margin + window.border_width;
- window.x = x - window.border_inner_margin - window.border_outer_margin - window.border_width;
- window.y = y - window.border_inner_margin - window.border_outer_margin - window.border_width;
+
+ long border_total = window.border_inner_margin
+ + window.border_outer_margin + window.border_width;
+ text_start_x = text_start_y = border_total;
+ window.x = x - border_total;
+ window.y = y - border_total;
} else
#endif
{
@@ -1005,6 +1019,10 @@ static int text_size_updater(char *s, int special_index)
int lw;
int contain_SECRIT_MULTILINE_CHAR = 0;
char *p;
+ special_t *current = specials;
+
+ for(int i = 0; i < special_index; i++)
+ current = current->next;
if (not out_to_x.get(*state))
return 0;
@@ -1016,40 +1034,41 @@ static int text_size_updater(char *s, int special_index)
w += get_string_width(s);
*p = SPECIAL_CHAR;
- if (specials[special_index].type == BAR
- || specials[special_index].type == GAUGE
- || specials[special_index].type == GRAPH) {
- w += specials[special_index].width;
- if (specials[special_index].height > last_font_height) {
- last_font_height = specials[special_index].height;
+ if (current->type == BAR
+ || current->type == GAUGE
+ || current->type == GRAPH) {
+ w += current->width;
+ if (current->height > last_font_height) {
+ last_font_height = current->height;
last_font_height += font_height();
}
- } else if (specials[special_index].type == OFFSET) {
- if (specials[special_index].arg > 0) {
- w += specials[special_index].arg;
+ } else if (current->type == OFFSET) {
+ if (current->arg > 0) {
+ w += current->arg;
}
- } else if (specials[special_index].type == VOFFSET) {
- last_font_height += specials[special_index].arg;
- } else if (specials[special_index].type == GOTO) {
- if (specials[special_index].arg > cur_x) {
- w = (int) specials[special_index].arg;
+ } else if (current->type == VOFFSET) {
+ last_font_height += current->arg;
+ } else if (current->type == GOTO) {
+ if (current->arg > cur_x) {
+ w = (int) current->arg;
}
- } else if (specials[special_index].type == TAB) {
- int start = specials[special_index].arg;
- int step = specials[special_index].width;
+ } else if (current->type == TAB) {
+ int start = current->arg;
+ int step = current->width;
if (!step || step < 0) {
step = 10;
}
w += step - (cur_x - text_start_x - start) % step;
- } else if (specials[special_index].type == FONT) {
- selected_font = specials[special_index].font_added;
+ } else if (current->type == FONT) {
+ selected_font = current->font_added;
if (font_height() > last_font_height) {
last_font_height = font_height();
}
}
special_index++;
+ current = current->next;
s = p + 1;
} else if (*p == SECRIT_MULTILINE_CHAR) {
contain_SECRIT_MULTILINE_CHAR = 1;
@@ -1265,11 +1284,14 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
s = p + 1;
}
/* draw special */
- switch (specials[special_index].type) {
+ special_t *current = specials;
+ for(int i = 0; i < special_index; i++)
+ current = current->next;
+ switch (current->type) {
#ifdef BUILD_X11
case HORIZONTAL_LINE:
{
- int h = specials[special_index].height;
+ int h = current->height;
int mid = font_ascent() / 2;
w = text_start_x + text_width - cur_x;
@@ -1283,8 +1305,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
case STIPPLED_HR:
{
- int h = specials[special_index].height;
- char tmp_s = specials[special_index].arg;
+ int h = current->height;
+ char tmp_s = current->arg;
int mid = font_ascent() / 2;
char ss[2] = { tmp_s, tmp_s };
@@ -1305,15 +1327,15 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
&& maximum_width > 0) {
break;
}
- h = specials[special_index].height;
- bar_usage = specials[special_index].arg;
- scale = specials[special_index].scale;
+ h = current->height;
+ bar_usage = current->arg;
+ scale = current->scale;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) {
by -= h / 2 - 1;
}
- w = specials[special_index].width;
+ w = current->width;
if (w == 0) {
w = text_start_x + text_width - cur_x - 1;
}
@@ -1349,13 +1371,13 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
break;
}
- h = specials[special_index].height;
+ h = current->height;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) {
by -= h / 2 - 1;
}
- w = specials[special_index].width;
+ w = current->width;
if (w == 0) {
w = text_start_x + text_width - cur_x - 1;
}
@@ -1370,8 +1392,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
cur_x, by, w, h * 2, 0, 180*64);
#ifdef MATH
- usage = specials[special_index].arg;
- scale = specials[special_index].scale;
+ usage = current->arg;
+ scale = current->scale;
angle = M_PI * usage / scale;
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
py = (float)(by+(h))-(float)(h)*sin(angle);
@@ -1401,13 +1423,13 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
&& maximum_width > 0) {
break;
}
- h = specials[special_index].height;
+ h = current->height;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) {
by -= h / 2 - 1;
}
- w = specials[special_index].width;
+ w = current->width;
if (w == 0) {
w = text_start_x + text_width - cur_x - 1;
}
@@ -1423,37 +1445,37 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
XSetLineAttributes(display, window.gc, 1, LineSolid,
CapButt, JoinMiter);
- if (specials[special_index].last_colour != 0
- || specials[special_index].first_colour != 0) {
- tmpcolour = do_gradient(w - 1, specials[special_index].last_colour, specials[special_index].first_colour);
+ if (current->last_colour != 0
+ || current->first_colour != 0) {
+ tmpcolour = do_gradient(w - 1, current->last_colour, current->first_colour);
}
colour_idx = 0;
for (i = w - 2; i > -1; i--) {
- if (specials[special_index].last_colour != 0
- || specials[special_index].first_colour != 0) {
- if (specials[special_index].tempgrad) {
+ if (current->last_colour != 0
+ || current->first_colour != 0) {
+ if (current->tempgrad) {
#ifdef DEBUG_lol
assert(
- (int)((float)(w - 2) - specials[special_index].graph[j] *
- (w - 2) / (float)specials[special_index].scale)
+ (int)((float)(w - 2) - current->graph[j] *
+ (w - 2) / (float)current->scale)
< w - 1
);
assert(
- (int)((float)(w - 2) - specials[special_index].graph[j] *
- (w - 2) / (float)specials[special_index].scale)
+ (int)((float)(w - 2) - current->graph[j] *
+ (w - 2) / (float)current->scale)
> -1
);
- if (specials[special_index].graph[j] == specials[special_index].scale) {
+ if (current->graph[j] == current->scale) {
assert(
- (int)((float)(w - 2) - specials[special_index].graph[j] *
- (w - 2) / (float)specials[special_index].scale)
+ (int)((float)(w - 2) - current->graph[j] *
+ (w - 2) / (float)current->scale)
== 0
);
}
#endif /* DEBUG_lol */
XSetForeground(display, window.gc, tmpcolour[
- (int)((float)(w - 2) - specials[special_index].graph[j] *
- (w - 2) / (float)specials[special_index].scale)
+ (int)((float)(w - 2) - current->graph[j] *
+ (w - 2) / (float)current->scale)
]);
} else {
XSetForeground(display, window.gc, tmpcolour[colour_idx++]);
@@ -1462,10 +1484,10 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
/* this is mugfugly, but it works */
XDrawLine(display, window.drawable, window.gc,
cur_x + i + 1, by + h, cur_x + i + 1,
- round_to_int((double)by + h - specials[special_index].graph[j] *
- (h - 1) / specials[special_index].scale));
+ round_to_int((double)by + h - current->graph[j] *
+ (h - 1) / current->scale));
if ((w - i) / ((float) (w - 2) /
- (specials[special_index].graph_width)) > j
+ (current->graph_width)) > j
&& j < MAX_GRAPH_DEPTH - 3) {
j++;
}
@@ -1519,16 +1541,16 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
cur_y = tmp_y;
}
#ifdef MATH
- if (show_graph_scale.get(*state) && (specials[special_index].show_scale == 1)) {
+ if (show_graph_scale.get(*state) && (current->show_scale == 1)) {
int tmp_x = cur_x;
int tmp_y = cur_y;
char *tmp_str;
cur_x += font_ascent() / 2;
cur_y += font_h / 2;
tmp_str = (char *)
- calloc(log10(floor(specials[special_index].scale)) + 4,
+ calloc(log10(floor(current->scale)) + 4,
sizeof(char));
- sprintf(tmp_str, "%.1f", specials[special_index].scale);
+ sprintf(tmp_str, "%.1f", current->scale);
draw_string(tmp_str);
free(tmp_str);
cur_x = tmp_x;
@@ -1544,7 +1566,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
int old = font_ascent();
cur_y -= font_ascent();
- selected_font = specials[special_index].font_added;
+ selected_font = current->font_added;
set_font();
if (cur_y + font_ascent() < cur_y + old) {
cur_y += old;
@@ -1557,43 +1579,43 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
#endif /* BUILD_X11 */
case FG:
if (draw_mode == FG) {
- set_foreground_color(specials[special_index].arg);
+ set_foreground_color(current->arg);
}
break;
#ifdef BUILD_X11
case BG:
if (draw_mode == BG) {
- set_foreground_color(specials[special_index].arg);
+ set_foreground_color(current->arg);
}
break;
case OUTLINE:
if (draw_mode == OUTLINE) {
- set_foreground_color(specials[special_index].arg);
+ set_foreground_color(current->arg);
}
break;
case OFFSET:
- w += specials[special_index].arg;
+ w += current->arg;
last_special_needed = special_index;
break;
case VOFFSET:
- cur_y += specials[special_index].arg;
+ cur_y += current->arg;
break;
case GOTO:
- if (specials[special_index].arg >= 0) {
- cur_x = (int) specials[special_index].arg;
+ if (current->arg >= 0) {
+ cur_x = (int) current->arg;
}
last_special_needed = special_index;
break;
case TAB:
{
- int start = specials[special_index].arg;
- int step = specials[special_index].width;
+ int start = current->arg;
+ int step = current->width;
if (!step || step < 0) {
step = 10;
@@ -1612,13 +1634,13 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
/* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
"get_string_width(p) %i gap_x %i "
- "specials[special_index].arg %i window.border_inner_margin %i "
+ "current->arg %i window.border_inner_margin %i "
"window.border_width %i\n", pos_x, text_start_x, text_width,
cur_x, get_string_width_special(s), gap_x,
- specials[special_index].arg, window.border_inner_margin,
+ current->arg, window.border_inner_margin,
window.border_width); */
- if (pos_x > specials[special_index].arg && pos_x > cur_x) {
- cur_x = pos_x - specials[special_index].arg;
+ if (pos_x > current->arg && pos_x > cur_x) {
+ cur_x = pos_x - current->arg;
}
last_special_needed = special_index;
break;
@@ -1634,11 +1656,11 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
/* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
"get_string_width(p) %i gap_x %i "
- "specials[special_index].arg %i\n", pos_x, text_start_x,
+ "current->arg %i\n", pos_x, text_start_x,
text_width, cur_x, get_string_width(s), gap_x,
- specials[special_index].arg); */
- if (pos_x > specials[special_index].arg) {
- w = pos_x - specials[special_index].arg;
+ current->arg); */
+ if (pos_x > current->arg) {
+ w = pos_x - current->arg;
}
last_special_needed = special_index;
break;
@@ -1818,10 +1840,12 @@ static void clear_text(int exposures)
#endif
if (display && window.window) { // make sure these are !null
/* there is some extra space for borders and outlines */
- XClearArea(display, window.window, text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width,
- text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width,
- text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
- text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2, exposures ? True : 0);
+ long border_total = window.border_inner_margin
+ + window.border_outer_margin + window.border_width;
+
+ XClearArea(display, window.window, text_start_x - border_total,
+ text_start_y - border_total, text_width + 2*border_total,
+ text_height + 2*border_total, exposures ? True : 0);
}
}
#endif /* BUILD_X11 */
@@ -1938,16 +1962,21 @@ static void main_loop(void)
need_to_update = 0;
selected_font = 0;
update_text_area();
+
+#if defined(OWN_WINDOW) || defined(BUILD_XDBE)
+ long border_total = window.border_inner_margin
+ + window.border_outer_margin + window.border_width;
+#endif
#ifdef OWN_WINDOW
if (own_window.get(*state)) {
int changed = 0;
/* resize window if it isn't right size */
if (!fixed_size
- && (text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2 != window.width
- || text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2 != window.height)) {
- window.width = text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
- window.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
+ && (text_width + 2*border_total != window.width
+ || text_height + 2*border_total != window.height)) {
+ window.width = text_width + 2*border_total;
+ window.height = text_height + 2*border_total;
draw_stuff(); /* redraw everything in our newly sized window */
XResizeWindow(display, window.window, window.width,
window.height); /* resize window */
@@ -2017,10 +2046,10 @@ static void main_loop(void)
if (use_xdbe) {
XRectangle r;
- r.x = text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width;
- r.y = text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width;
- r.width = text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
- r.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
+ r.x = text_start_x - border_total;
+ r.y = text_start_y - border_total;
+ r.width = text_width + 2*border_total;
+ r.height = text_height + 2*border_total;
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
}
#endif
@@ -2176,10 +2205,12 @@ static void main_loop(void)
if (use_xdbe) {
XRectangle r;
- r.x = text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width;
- r.y = text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width;
- r.width = text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
- r.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2;
+ long border_total = window.border_inner_margin
+ + window.border_outer_margin + window.border_width;
+ r.x = text_start_x - border_total;
+ r.y = text_start_y - border_total;
+ r.width = text_width + 2*border_total;
+ r.height = text_height + 2*border_total;
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
}
#endif
@@ -2329,10 +2360,41 @@ static void reload_config(void)
initialisation(argc_copy, argv_copy);
}
+#ifdef BUILD_X11
+void clean_up_x11() {
+ if(window_created == 1) {
+ long border_total = window.border_inner_margin
+ + window.border_outer_margin + window.border_width;
+ XClearArea(display, window.window, text_start_x - border_total,
+ text_start_y - border_total, text_width + 2*border_total,
+ text_height + 2*border_total, 0);
+ }
+ destroy_window();
+ free_fonts();
+ if(x11_stuff.region) {
+ XDestroyRegion(x11_stuff.region);
+ x11_stuff.region = NULL;
+ }
+ if(display) {
+ XCloseDisplay(display);
+ display = NULL;
+ }
+ x_initialised = NO;
+}
+#endif
+
+void free_specials(special_t *current) {
+ if (current) {
+ free_specials(current->next);
+ if(current->type == GRAPH)
+ free(current->graph);
+ delete current;
+ current = NULL;
+ }
+}
+
void clean_up(void *memtofree1, void* memtofree2)
{
- int i;
-
free_update_callbacks();
#ifdef BUILD_NCURSES
@@ -2349,19 +2411,7 @@ void clean_up(void *memtofree1, void* memtofree2)
free_and_zero(info.cpu_usage);
#ifdef BUILD_X11
if (x_initialised == YES) {
- if(window_created == 1) {
- XClearArea(display, window.window, text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width,
- text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width,
- text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
- text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2, 0);
- }
- destroy_window();
- free_fonts();
- if(x11_stuff.region) {
- XDestroyRegion(x11_stuff.region);
- x11_stuff.region = NULL;
- }
- x_initialised = NO;
+ clean_up_x11();
}else{
free(fonts); //in set_default_configurations a font is set but not loaded
font_count = -1;
@@ -2406,14 +2456,7 @@ void clean_up(void *memtofree1, void* memtofree2)
xmlCleanupParser();
#endif /* BUILD_WEATHER_XOAP */
- if (specials) {
- for (i = 0; i < special_count; i++) {
- if (specials[i].type == GRAPH) {
- free(specials[i].graph);
- }
- }
- free_and_zero(specials);
- }
+ free_specials(specials);
clear_net_stats();
clear_diskio_stats();
@@ -2490,6 +2533,13 @@ static void set_default_configurations(void)
mpd_set_port("6600");
}
#endif /* BUILD_MPD */
+#ifdef BUILD_MYSQL
+ mysql_settings.host = NULL;
+ mysql_settings.port = 0;
+ mysql_settings.user = NULL;
+ mysql_settings.password = NULL;
+ mysql_settings.db = NULL;
+#endif /* BUILD_MYSQL */
#ifdef BUILD_XMMS2
info.xmms2.artist = NULL;
info.xmms2.album = NULL;
@@ -2565,16 +2615,12 @@ static bool append_works(const char *path)
}
#ifdef BUILD_X11
-static char **xargv = 0;
-static int xargc = 0;
-
static void X11_create_window(void)
{
if (out_to_x.get(*state)) {
init_window(text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
- xargv, xargc);
-
+ argv_copy, argc_copy);
setup_fonts();
load_fonts();
update_text_area(); /* to position text/window on screen */
@@ -2821,6 +2867,43 @@ char load_config_file(const char *f)
}
}
#endif /* BUILD_MPD */
+#ifdef BUILD_MYSQL
+ CONF("mysql_host") {
+ if (value) {
+ mysql_set_host(value);
+ } else {
+ CONF_ERR;
+ }
+ }
+ CONF("mysql_port") {
+ if (value) {
+ mysql_set_port(value);
+ } else {
+ CONF_ERR;
+ }
+ }
+ CONF("mysql_user") {
+ if (value) {
+ mysql_set_user(value);
+ } else {
+ CONF_ERR;
+ }
+ }
+ CONF("mysql_password") {
+ if (value) {
+ mysql_set_password(value);
+ } else {
+ CONF_ERR;
+ }
+ }
+ CONF("mysql_db") {
+ if (value) {
+ mysql_set_db(value);
+ } else {
+ CONF_ERR;
+ }
+ }
+#endif /* BUILD_MYSQL */
CONF("music_player_interval") {
if (value) {
info.music_player_interval = strtod(value, 0);
@@ -3068,13 +3151,6 @@ char load_config_file(const char *f)
CONF_ERR;
}
}
- CONF("max_specials") {
- if (value) {
- max_specials = atoi(value);
- } else {
- CONF_ERR;
- }
- }
CONF("max_user_text") {
if (value) {
max_user_text = atoi(value);
@@ -3281,6 +3357,7 @@ static void print_help(const char *prog_name) {
" -y Y y position\n"
#endif /* BUILD_X11 */
" -s, --for-scripts=TEXT render TEXT on stdout and exit, enclose TEXT by single quotes\n"
+ " -S, --stdin-config read configuration from stdin\n"
" -t, --text=TEXT text to render, remember single quotes, like -t '$uptime'\n"
" -u, --interval=SECS update interval\n"
" -i COUNT number of times to update "PACKAGE_NAME" (and quit)\n"
@@ -3299,7 +3376,7 @@ inline void reset_optind() {
}
/* : means that character before that takes an argument */
-static const char *getopt_string = "vVqdDs:t:u:i:hc:p:"
+static const char *getopt_string = "vVqdDSs:t:u:i:hc:p:"
#ifdef BUILD_X11
"x:y:w:a:f:X:"
#ifdef OWN_WINDOW
@@ -3337,6 +3414,7 @@ static const struct option longopts[] = {
{ "window-id", 1, NULL, 'w' },
#endif /* BUILD_X11 */
{ "for-scripts", 1, NULL, 's' },
+ { "stdin-config", 0, NULL, 'S' },
{ "text", 1, NULL, 't' },
{ "interval", 1, NULL, 'u' },
{ "pause", 1, NULL, 'p' },
@@ -3344,8 +3422,13 @@ static const struct option longopts[] = {
};
void set_current_config() {
- /* check if specified config file is valid */
- if (not current_config.empty()) {
+ /* set configfile to stdin if that's requested or check if specified config file is valid */
+ if(stdinconfig) {
+ char mystdin[32];
+#define CONKYSTDIN "/proc/%u/fd/0"
+ sprintf(mystdin, CONKYSTDIN, getpid());
+ current_config = mystdin;
+ } else if (not current_config.empty()) {
struct stat sb;
if (stat(current_config.c_str(), &sb) ||
(!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) {
@@ -3414,11 +3497,6 @@ void initialisation(int argc, char **argv) {
currentconffile = conftree_add(currentconffile, current_config.c_str());
}
- /* init specials array */
- if ((specials = (special_t*)calloc(sizeof(struct special_t), max_specials)) == 0) {
- NORM_ERR("failed to create specials array");
- }
-
#ifdef MAIL_FILE
if (current_mail_spool == NULL) {
char buf[256];
@@ -3558,8 +3636,6 @@ void initialisation(int argc, char **argv) {
memset(tmpstring2, 0, text_buffer_size);
#ifdef BUILD_X11
- xargc = argc;
- xargv = argv;
X11_create_window();
#endif /* BUILD_X11 */
#ifdef BUILD_LUA
@@ -3644,6 +3720,9 @@ int main(int argc, char **argv)
case 'c':
current_config = optarg;
break;
+ case 'S':
+ stdinconfig = true;
+ break;
case 'q':
if (!freopen("/dev/null", "w", stderr))
CRIT_ERR(0, 0, "could not open /dev/null as stderr!");
@@ -3743,7 +3822,13 @@ int main(int argc, char **argv)
#endif /* BUILD_WEATHER_XOAP */
#ifdef HAVE_SYS_INOTIFY_H
- inotify_fd = inotify_init1(IN_NONBLOCK);
+ inotify_fd = inotify_init();
+ if(inotify_fd != -1) {
+ int fl;
+
+ fl = fcntl(inotify_fd, F_GETFL);
+ fcntl(inotify_fd, F_SETFL, fl | O_NONBLOCK);
+ }
#endif /* HAVE_SYS_INOTIFY_H */
initialisation(argc, argv);
diff --git a/src/conky.h b/src/conky.h
index ab6ba640..485ea911 100644
--- a/src/conky.h
+++ b/src/conky.h
@@ -88,6 +88,10 @@ struct text_object;
#include "mpd.h"
#endif /* BUILD_MPD */
+#ifdef BUILD_MYSQL
+#include "mysql.h"
+#endif /* BUILD_MYSQL */
+
/* C++ headers */
#ifdef BUILD_CURL
#include "ccurl_thread.h"
diff --git a/src/core.cc b/src/core.cc
index 0c4a230a..3ab6b22e 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -42,6 +42,9 @@
#include "i8k.h"
#include "imlib2.h"
#include "proc.h"
+#ifdef BUILD_MYSQL
+#include "mysql.h"
+#endif
#ifdef BUILD_X11
#include "fonts.h"
#endif
@@ -64,7 +67,7 @@
#ifdef BUILD_NVIDIA
#include "nvidia.h"
#endif
-#include "read_tcp.h"
+#include "read_tcpip.h"
#include "scroll.h"
#include "specials.h"
#include "temphelper.h"
@@ -135,6 +138,31 @@ static struct text_object *create_plain_text(const char *s)
return obj;
}
+#ifdef BUILD_CURL
+void stock_parse_arg(struct text_object *obj, const char *arg)
+{
+ char stock[8];
+ char data[8];
+
+ obj->data.s = NULL;
+ if(sscanf(arg, "%7s %7s", stock, data) != 2) {
+ NORM_ERR("wrong number of arguments for $stock");
+ return;
+ }
+ if(!strcasecmp("ask", data)) strcpy(data, "a");
+ else if(!strcasecmp("adv", data)) strcpy(data, "a2");
+ else if(!strcasecmp("asksize", data)) strcpy(data, "a5");
+ else if(!strcasecmp("bid", data)) strcpy(data, "b");
+ else {
+ NORM_ERR("\"%s\" is not supported by $stock. Supported: adv,ask,asksize,bid", data);
+ return;
+ }
+#define MAX_FINYAH_URL_LENGTH 64
+ obj->data.s = (char*) malloc(MAX_FINYAH_URL_LENGTH);
+ snprintf(obj->data.s, MAX_FINYAH_URL_LENGTH, "http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=%s", stock, data);
+}
+#endif /* BUILD_CURL */
+
/* construct_text_object() creates a new text_object */
struct text_object *construct_text_object(char *s, const char *arg, long
line, void **ifblock_opaque, void *free_at_crash)
@@ -148,7 +176,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
#define __OBJ_HEAD(a, n) if (!strcmp(s, #a)) { \
add_update_callback(n);
#define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj)
-#define __OBJ_ARG(...) if (!arg) { CRIT_ERR(obj, free_at_crash, __VA_ARGS__); }
+#define __OBJ_ARG(...) if (!arg) { free(s); CRIT_ERR(obj, free_at_crash, __VA_ARGS__); }
/* defines to be used below */
#define OBJ(a, n) __OBJ_HEAD(a, n) {
@@ -183,9 +211,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long
NORM_ERR("acpiacadapter: arg is only used on linux");
#endif
}
- if(! obj->data.opaque)
- obj->data.opaque = strdup("AC");
-
obj->callbacks.print = &print_acpiacadapter;
obj->callbacks.free = &gen_free_opaque;
#endif /* !__OpenBSD__ */
@@ -212,9 +237,13 @@ struct text_object *construct_text_object(char *s, const char *arg, long
}
obj->callbacks.print = &print_freq_g;
END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)")
- parse_read_tcp_arg(obj, arg, free_at_crash);
+ parse_read_tcpip_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_read_tcp;
- obj->callbacks.free = &free_read_tcp;
+ obj->callbacks.free = &free_read_tcpip;
+ END OBJ_ARG(read_udp, 0, "read_udp: Needs \"(host) port\" as argument(s)")
+ parse_read_tcpip_arg(obj, arg, free_at_crash);
+ obj->callbacks.print = &print_read_udp;
+ obj->callbacks.free = &free_read_tcpip;
#if defined(__linux__)
END OBJ(voltage_mv, 0)
get_cpu_count();
@@ -318,11 +347,11 @@ struct text_object *construct_text_object(char *s, const char *arg, long
END OBJ(battery_bar, 0)
char bat[64];
if (arg) {
- arg = scan_bar(obj, arg, 100);
sscanf(arg, "%63s", bat);
} else {
strcpy(bat, "BAT0");
}
+ scan_bar(obj, bat, 100);
obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.barval = &get_battery_perct_bar;
obj->callbacks.free = &gen_free_opaque;
@@ -579,6 +608,16 @@ struct text_object *construct_text_object(char *s, const char *arg, long
obj->callbacks.print = &print_image_callback;
obj->callbacks.free = &gen_free_opaque;
#endif /* BUILD_IMLIB2 */
+#ifdef BUILD_MYSQL
+ END OBJ_ARG(mysql, 0, "mysql needs a query")
+ obj->data.s = strdup(arg);
+ obj->callbacks.print = &print_mysql;
+ obj->callbacks.free = &free_mysql;
+#endif /* BUILD_MYSQL */
+ END OBJ_ARG(no_update, 0, "no_update needs arguments")
+ scan_no_update(obj, arg);
+ obj->callbacks.print = &print_no_update;
+ obj->callbacks.free = &free_no_update;
END OBJ(exec, 0)
scan_exec_arg(obj, arg);
obj->parse = false;
@@ -905,6 +944,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long
obj->callbacks.print = &print_format_time;
END OBJ(nodename, 0)
obj->callbacks.print = &print_nodename;
+ END OBJ(nodename_short, 0)
+ obj->callbacks.print = &print_nodename_short;
END OBJ_ARG(cmdline_to_pid, 0, "cmdline_to_pid needs a command line as argument")
scan_cmdline_to_pid_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_cmdline_to_pid;
@@ -1038,6 +1079,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long
END OBJ(processes, &update_total_processes)
obj->callbacks.print = &print_processes;
#ifdef __linux__
+ END OBJ(distribution, 0)
+ obj->callbacks.print = &print_distribution;
END OBJ(running_processes, &update_top)
top_running = 1;
obj->callbacks.print = &print_running_processes;
@@ -1565,6 +1608,12 @@ struct text_object *construct_text_object(char *s, const char *arg, long
obj->sub = (text_object*)malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg);
obj->callbacks.print = &print_to_bytes;
+#ifdef BUILD_CURL
+ END OBJ_ARG(stock, 0, "stock needs arguments")
+ stock_parse_arg(obj, arg);
+ obj->callbacks.print = &print_stock;
+ obj->callbacks.free = &free_stock;
+#endif /* BUILD_CURL */
END OBJ(scroll, 0)
#ifdef BUILD_X11
/* allocate a follower to reset any color changes */
@@ -1630,7 +1679,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
END {
char *buf = (char *)malloc(text_buffer_size);
- NORM_ERR("unknown variable %s", s);
+ NORM_ERR("unknown variable '$%s'", s);
snprintf(buf, text_buffer_size, "${%s}", s);
obj_be_plain_text(obj, buf);
free(buf);
@@ -1819,7 +1868,7 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
strfold(p, 1);
} else if (*p == '#') {
char c;
- if (remove_comment(p, &c) && p > orig_p && c == '\n') {
+ if (remove_comment(p, &c) && p >= orig_p && c == '\n') {
/* if remove_comment removed a newline, we need to 'back up' with p */
p--;
}
diff --git a/src/fonts.h b/src/fonts.h
index b8c109bc..dc5e4b7d 100644
--- a/src/fonts.h
+++ b/src/fonts.h
@@ -1,4 +1,5 @@
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=cpp
*
* Conky, a system monitor, based on torsmo
*
diff --git a/src/linux.cc b/src/linux.cc
index 8327345e..39ee545d 100644
--- a/src/linux.cc
+++ b/src/linux.cc
@@ -1353,6 +1353,8 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
Update: it seems the folder name is hardware-dependent. We add an aditional adapter
argument, specifying the folder name.
+
+ Update: on some systems it's /sys/class/power_supply/ADP1 instead of /sys/class/power_supply/AC
*/
void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
@@ -1361,14 +1363,20 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const
char buf[256];
char buf2[256];
+ struct stat sb;
FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) {
return;
}
- snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
- fp = open_file(buf2, &rep);
+ if(adapter)
+ snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter);
+ else{
+ snprintf(buf2, sizeof(buf2), "%s/AC/uevent", SYSFS_AC_ADAPTER_DIR);
+ if(stat(buf2, &sb) == -1) snprintf(buf2, sizeof(buf2), "%s/ADP1/uevent", SYSFS_AC_ADAPTER_DIR);
+ }
+ if(stat(buf2, &sb) == 0) fp = open_file(buf2, &rep); else fp = 0;
if (fp) {
/* sysfs processing */
while (!feof(fp)) {
@@ -2363,3 +2371,39 @@ void update_diskio(void)
update_diskio_values(&stats, total_reads, total_writes);
fclose(fp);
}
+
+void print_distribution(struct text_object *obj, char *p, int p_max_size)
+{
+ (void)obj;
+ int i, bytes_read;
+ char* buf;
+ struct stat sb;
+
+ if(stat("/etc/arch-release", &sb) == 0) {
+ snprintf(p, p_max_size, "Arch Linux");
+ return;
+ }
+ snprintf(p, p_max_size, "Unknown");
+ buf = readfile("/proc/version", &bytes_read, 1);
+ if(buf) {
+ /* I am assuming the distribution name is the first string in /proc/version that:
+ - is preceded by a '('
+ - starts with a capital
+ - is followed by a space and a number
+ but i am not sure if this is always true... */
+ for(i=1; i= 'A' && buf[i] <= 'Z') break;
+ }
+ if(i < bytes_read) {
+ snprintf(p, p_max_size, "%s", &buf[i]);
+ for(i=1; p[i]; i++) {
+ if(p[i-1] == ' ' && p[i] >= '0' && p[i] <= '9') {
+ p[i-1] = 0;
+ break;
+ }
+ }
+ }
+ free(buf);
+ }
+}
+
diff --git a/src/linux.h b/src/linux.h
index ef3d1837..71697821 100644
--- a/src/linux.h
+++ b/src/linux.h
@@ -53,4 +53,6 @@ int get_entropy_poolsize(unsigned int *);
void update_stat(void);
+void print_distribution(struct text_object *, char *, int);
+
#endif /* _LINUX_H */
diff --git a/src/mixer.cc b/src/mixer.cc
index 42a27b2a..b8d09d09 100644
--- a/src/mixer.cc
+++ b/src/mixer.cc
@@ -38,9 +38,6 @@
#include
-#ifdef MIXER_IS_ALSA
-#include
-#else
#ifdef HAVE_LINUX_SOUNDCARD_H
#include
#else
@@ -50,173 +47,12 @@
#include
#endif /* __OpenBSD__ */
#endif /* HAVE_LINUX_SOUNDCARD_H */
-#endif /* MIXER_IS_ALSA */
#define MIXER_DEV "/dev/mixer"
-#ifdef MIXER_IS_ALSA
-#define MAX_MIXERS 8
-struct mixer_control {
- char name[64];
- snd_mixer_t *mixer;
- snd_mixer_selem_id_t *sid;
- snd_mixer_elem_t *elem;
- long vol_min, vol_max;
-};
-
-static struct mixer_control mixer_data[MAX_MIXERS];
-int num_mixers = 0;
-static char soundcard[64] = "default";
-#else
static int mixer_fd;
static const char *devs[] = SOUND_DEVICE_NAMES;
-#endif
-#ifdef MIXER_IS_ALSA
-static int parse_simple_id(const char *str, snd_mixer_selem_id_t *sid)
-{
- int c, size;
- char buf[128];
- char *ptr = buf;
-
- while (*str == ' ' || *str == '\t')
- str++;
- if (!(*str))
- return -EINVAL;
- size = 1; /* for '\0' */
- if (*str != '"' && *str != '\'') {
- while (*str && *str != ',') {
- if (size < (int)sizeof(buf)) {
- *ptr++ = *str;
- size++;
- }
- str++;
- }
- } else {
- c = *str++;
- while (*str && *str != c) {
- if (size < (int)sizeof(buf)) {
- *ptr++ = *str;
- size++;
- }
- str++;
- }
- if (*str == c)
- str++;
- }
- if (*str == '\0') {
- snd_mixer_selem_id_set_index(sid, 0);
- *ptr = 0;
- goto _set;
- }
- if (*str != ',')
- return -EINVAL;
- *ptr = 0; /* terminate the string */
- str++;
- if (!isdigit(*str))
- return -EINVAL;
- snd_mixer_selem_id_set_index(sid, atoi(str));
- _set:
- snd_mixer_selem_id_set_name(sid, buf);
- return 0;
-}
-
-int mixer_init (const char *name)
-{
- /* from amixer.c, replaced -EINVAL with -1 */
- int i, err;
- if (!name)
- name = "Master";
-
- for (i = 0; i < num_mixers; i++) {
- if (!strcasecmp (mixer_data[i].name, name)) {
- return i;
- }
- }
- if (i == MAX_MIXERS) {
- fprintf (stderr, "max mixers (%d) reached\n", MAX_MIXERS);
- return -1;
- };
-
- num_mixers++;
-#define data mixer_data[i]
-
- strncpy (mixer_data[i].name, name, 63);
- mixer_data[i].name[63] = '\0';
- snd_mixer_selem_id_alloca (&data.sid);
- data.mixer = NULL;
- if (parse_simple_id (name, data.sid) < 0) {
- fprintf (stderr, "Wrong mixer identifier: %s\n", name);
- return -1;
- }
- if ((err = snd_mixer_open (&data.mixer, 0)) < 0) {
- fprintf (stderr, "snd_mixer_open: %s\n", snd_strerror (err));
- return -1;
- }
- if ((err = snd_mixer_attach (data.mixer, soundcard)) < 0) {
- fprintf (stderr, "snd_mixer_attach: %s\n", snd_strerror (err));
- return -1;
- }
- if ((err = snd_mixer_selem_register (data.mixer, NULL, NULL)) < 0) {
- fprintf (stderr, "snd_mixer_selem_register: %s\n",
- snd_strerror (err));
- return -1;
- }
- if ((err = snd_mixer_load (data.mixer)) < 0) {
- fprintf (stderr, "snd_mixer_load: %s\n", snd_strerror (err));
- return -1;
- }
- if (!(data.elem = snd_mixer_find_selem (data.mixer, data.sid))) {
- fprintf (stderr, "snd_mixer_find_selem (\"%s\", %i)\n",
- snd_mixer_selem_id_get_name (data.sid),
- snd_mixer_selem_id_get_index (data.sid));
- return -1;
- }
- snd_mixer_selem_get_playback_volume_range(data.elem, &data.vol_min, &data.vol_max);
- return i;
-}
-static int mixer_get_avg (int i)
-{
- long 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)
-{
- /* stub */
- return mixer_get_avg (i);
-}
-static int mixer_get_right (int i)
-{
- /* stub */
- return mixer_get_avg (i);
-}
-int mixer_to_255(int i, int x)
-{
- return (x-data.vol_min)*255/(data.vol_max-data.vol_min);
-}
-int mixer_is_mute(int i)
-{
- snd_mixer_handle_events (data.mixer);
- if (snd_mixer_selem_has_playback_switch (data.elem)) {
- int val, err;
- if ((err = snd_mixer_selem_get_playback_switch(data.elem, 0, &val)) < 0)
- fprintf (stderr, "playback_switch: %s\n", snd_strerror (err));
- return !val;
- } else {
- return !mixer_get_avg(i);
- }
-}
-#undef data
-
-#else /* MIXER_IS_ALSA */
int mixer_init(const char *name)
{
unsigned int i;
@@ -282,7 +118,6 @@ int mixer_is_mute(int i)
}
#define mixer_to_255(i, x) x
-#endif /* MIXER_IS_ALSA */
void parse_mixer_arg(struct text_object *obj, const char *arg)
{
@@ -318,10 +153,10 @@ void scan_mixer_bar(struct text_object *obj, const char *arg)
if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
obj->data.i = mixer_init(buf1);
- scan_bar(obj, arg + n, 255);
+ scan_bar(obj, arg + n, 100);
} else {
obj->data.i = mixer_init(NULL);
- scan_bar(obj, arg, 255);
+ scan_bar(obj, arg, 100);
}
}
diff --git a/src/mpd.cc b/src/mpd.cc
index 338b9e41..0734b0cd 100644
--- a/src/mpd.cc
+++ b/src/mpd.cc
@@ -99,8 +99,6 @@ void init_mpd(void)
{
if (!(refcount++)) /* first client */
memset(&mpd_info, 0, sizeof(mpd_info));
-
- refcount++;
}
static void clear_mpd(void)
@@ -304,7 +302,7 @@ bool mpd_process(thread_handle &handle)
static void update_mpd_thread(thread_handle &handle)
{
- while (1) if (mpd_process(handle)) return;
+ while (mpd_process(handle)) ;
/* never reached */
}
diff --git a/src/mysql.cc b/src/mysql.cc
new file mode 100644
index 00000000..98100447
--- /dev/null
+++ b/src/mysql.cc
@@ -0,0 +1,112 @@
+/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=cpp
+ *
+ * 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) 2005-2010 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 .
+ *
+ */
+
+#include "conky.h"
+#include "logging.h"
+#include
+
+struct mysql_conn mysql_settings;
+
+void print_mysql(struct text_object *obj, char *p, int p_max_size) {
+ MYSQL *conn = mysql_init(NULL);
+
+ if(mysql_settings.db == NULL)
+ mysql_settings.db = strdup("mysql");
+ if(conn == NULL) {
+ NORM_ERR("Can't initialize MySQL");
+ mysql_library_end();
+ return;
+ }
+ if (!mysql_real_connect(conn, mysql_settings.host, mysql_settings.user, mysql_settings.password, mysql_settings.db, mysql_settings.port, NULL, 0)) {
+ NORM_ERR("MySQL: %s", mysql_error(conn));
+ mysql_close(conn);
+ mysql_library_end();
+ return;
+ }
+ if(mysql_query(conn, obj->data.s)) {
+ NORM_ERR("MySQL: %s", mysql_error(conn));
+ mysql_close(conn);
+ mysql_library_end();
+ return;
+ }
+ MYSQL_RES *res = mysql_use_result(conn);
+ if(res == NULL) {
+ NORM_ERR("MySQL: %s", mysql_error(conn));
+ mysql_close(conn);
+ mysql_library_end();
+ return;
+ }
+ MYSQL_ROW row = mysql_fetch_row(res);
+ if(row) {
+ snprintf(p, p_max_size, "%s", row[0]);
+ } else {
+ NORM_ERR("MySQL: '%s' returned no results", obj->data.s);
+ }
+ mysql_free_result(res);
+ mysql_close(conn);
+ mysql_library_end();
+}
+
+void free_mysql(struct text_object *obj) {
+ free(mysql_settings.host);
+ free(mysql_settings.user);
+ if(mysql_settings.password) free(mysql_settings.password);
+ free(mysql_settings.db);
+ free(obj->data.s);
+}
+
+void mysql_set_host(const char *host) {
+ free(mysql_settings.host);
+ mysql_settings.host = strdup(host);
+}
+
+void mysql_set_port(const char *port) {
+ mysql_settings.port = strtol(port, 0, 0);
+ if(mysql_settings.port < 1 || mysql_settings.port > 0xffff)
+ mysql_settings.port = 0;
+}
+
+void mysql_set_user(const char *user) {
+ free(mysql_settings.user);
+ mysql_settings.user = strdup(user);
+}
+
+void mysql_set_password(const char *password) {
+ free_and_zero(mysql_settings.password);
+ if(password && strlen(password) > 2 && password[0] == '"' && password[strlen(password)-1] == '"') {
+ mysql_settings.password = strdup(password+1);
+ mysql_settings.password[strlen(password)-2] = 0;
+ } else
+ mysql_settings.password = NULL;
+}
+
+void mysql_set_db(const char *db) {
+ free(mysql_settings.db);
+ mysql_settings.db = strdup(db);
+}
diff --git a/src/mysql.h b/src/mysql.h
new file mode 100644
index 00000000..14b06ed7
--- /dev/null
+++ b/src/mysql.h
@@ -0,0 +1,48 @@
+/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=cpp
+ *
+ * Conky, a system monitor, based on torsmo
+ *
+ * Please see COPYING for details
+ *
+ * Copyright (c) 2005-2010 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 .
+ *
+ */
+
+#ifndef MYSQL_H_
+#define MYSQL_H_
+
+struct mysql_conn {
+ char *host;
+ int port;
+ char *user;
+ char *password;
+ char *db;
+};
+
+extern struct mysql_conn mysql_settings;
+
+void mysql_set_host(const char *);
+void mysql_set_port(const char *);
+void mysql_set_user(const char *);
+void mysql_set_password(const char *);
+void mysql_set_db(const char *);
+
+void print_mysql(struct text_object *, char *, int);
+void free_mysql(struct text_object *);
+
+#endif /*MYSQL_H_*/
diff --git a/src/proc.cc b/src/proc.cc
index 27c7f24b..736a2c0e 100644
--- a/src/proc.cc
+++ b/src/proc.cc
@@ -37,7 +37,7 @@
#include
#include
-char* readfile(char* filename, int* total_read, char showerror) {
+char* readfile(const char* filename, int* total_read, char showerror) {
FILE* file;
char* buf = NULL;
int bytes_read;
diff --git a/src/read_tcp.cc b/src/read_tcpip.cc
similarity index 60%
rename from src/read_tcp.cc
rename to src/read_tcpip.cc
index 0577769d..39258f13 100644
--- a/src/read_tcp.cc
+++ b/src/read_tcpip.cc
@@ -37,17 +37,17 @@
#include
#include
-struct read_tcp_data {
+struct read_tcpip_data {
char *host;
unsigned int port;
};
-void parse_read_tcp_arg(struct text_object *obj, const char *arg, void *free_at_crash)
+void parse_read_tcpip_arg(struct text_object *obj, const char *arg, void *free_at_crash)
{
- struct read_tcp_data *rtd;
+ struct read_tcpip_data *rtd;
- rtd = (struct read_tcp_data *) malloc(sizeof(struct read_tcp_data));
- memset(rtd, 0, sizeof(struct read_tcp_data));
+ rtd = (struct read_tcpip_data *) malloc(sizeof(struct read_tcpip_data));
+ memset(rtd, 0, sizeof(struct read_tcpip_data));
rtd->host = (char *) malloc(text_buffer_size);
sscanf(arg, "%s", rtd->host);
@@ -57,54 +57,70 @@ void parse_read_tcp_arg(struct text_object *obj, const char *arg, void *free_at_
strcpy(rtd->host,"localhost");
}
if(rtd->port < 1 || rtd->port > 65535)
- CRIT_ERR(obj, free_at_crash, "read_tcp: Needs \"(host) port\" as argument(s)");
+ CRIT_ERR(obj, free_at_crash, "read_tcp and read_udp need a port from 1 to 65535 as argument");
rtd->port = htons(rtd->port);
obj->data.opaque = rtd;
}
-void print_read_tcp(struct text_object *obj, char *p, int p_max_size)
+void print_read_tcpip(struct text_object *obj, char *p, int p_max_size, int protocol)
{
int sock, received;
struct sockaddr_in addr;
struct hostent* he;
fd_set readfds;
struct timeval tv;
- struct read_tcp_data *rtd = (struct read_tcp_data *) obj->data.opaque;
+ struct read_tcpip_data *rtd = (struct read_tcpip_data *) obj->data.opaque;
if (!rtd)
return;
if (!(he = gethostbyname(rtd->host))) {
- NORM_ERR("read_tcp: Problem with resolving the hostname");
+ NORM_ERR("%s: Problem with resolving the hostname", protocol == IPPROTO_TCP ? "read_tcp" : "read_udp");
return;
}
- if ((sock = socket(he->h_addrtype, SOCK_STREAM, 0)) == -1) {
- NORM_ERR("read_tcp: Couldn't create a socket");
+ if ((sock = socket(he->h_addrtype, protocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, protocol)) == -1) {
+ NORM_ERR("%s: Couldn't create a socket", protocol == IPPROTO_TCP ? "read_tcp" : "read_udp");
return;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = rtd->port;
memcpy(&addr.sin_addr, he->h_addr, he->h_length);
- if (!connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))) {
- NORM_ERR("read_tcp: Couldn't create a connection");
+ if (connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)) != 0) {
+ if(protocol == IPPROTO_TCP) {
+ NORM_ERR("read_tcp: Couldn't create a connection");
+ } else {
+ NORM_ERR("read_udp: Couldn't listen"); //other error because udp is connectionless
+ }
return;
}
+ if(protocol == IPPROTO_UDP)
+ write(sock, NULL, 0); //when using udp send a zero-length packet to let the other end know of our existence
FD_ZERO(&readfds);
FD_SET(sock, &readfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
if(select(sock + 1, &readfds, NULL, NULL, &tv) > 0){
received = recv(sock, p, p_max_size, 0);
- p[received] = 0;
+ if(received != -1) p[received] = 0; else p[0] = 0;
}
close(sock);
}
-void free_read_tcp(struct text_object *obj)
+void print_read_tcp(struct text_object *obj, char *p, int p_max_size)
{
- struct read_tcp_data *rtd = (struct read_tcp_data *) obj->data.opaque;
+ print_read_tcpip(obj, p, p_max_size, IPPROTO_TCP);
+}
+
+void print_read_udp(struct text_object *obj, char *p, int p_max_size)
+{
+ print_read_tcpip(obj, p, p_max_size, IPPROTO_UDP);
+}
+
+void free_read_tcpip(struct text_object *obj)
+{
+ struct read_tcpip_data *rtd = (struct read_tcpip_data *) obj->data.opaque;
if (!rtd)
return;
diff --git a/src/read_tcp.h b/src/read_tcpip.h
similarity index 88%
rename from src/read_tcp.h
rename to src/read_tcpip.h
index fec3923d..44bcf932 100644
--- a/src/read_tcp.h
+++ b/src/read_tcpip.h
@@ -31,8 +31,9 @@
#ifndef _READ_TCP_H
#define _READ_TCP_H
-void parse_read_tcp_arg(struct text_object *, const char *, void *);
+void parse_read_tcpip_arg(struct text_object *, const char *, void *);
void print_read_tcp(struct text_object *, char *, int);
-void free_read_tcp(struct text_object *);
+void print_read_udp(struct text_object *, char *, int);
+void free_read_tcpip(struct text_object *);
#endif /* _READ_TCP_H */
diff --git a/src/specials.cc b/src/specials.cc
index d875ea18..67324451 100644
--- a/src/specials.cc
+++ b/src/specials.cc
@@ -40,11 +40,6 @@
#endif /* HAVE_SYS_PARAM_H */
#include
-/* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
-int max_specials = MAX_SPECIALS_DEFAULT;
-
-/* create specials array on heap instead of stack with introduction of
- * max_specials */
struct special_t *specials = NULL;
int special_count;
@@ -251,16 +246,32 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale)
* Printing various special text objects
*/
+struct special_t *new_special_t_node()
+{
+ special_t *newnode = new special_t;
+
+ newnode->graph = NULL;
+ newnode->next = NULL;
+ return newnode;
+}
+
struct special_t *new_special(char *buf, enum special_types t)
{
- if (special_count >= max_specials) {
- CRIT_ERR(NULL, NULL, "too many special things in text");
- }
+ special_t* current;
buf[0] = SPECIAL_CHAR;
buf[1] = '\0';
- specials[special_count].type = t;
- return &specials[special_count++];
+ if(!specials)
+ specials = new_special_t_node();
+ current = specials;
+ for(int i=0; i < special_count; i++) {
+ if(current->next == NULL)
+ current->next = new_special_t_node();
+ current = current->next;
+ }
+ current->type = t;
+ special_count++;
+ return current;
}
void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, double usage)
diff --git a/src/specials.h b/src/specials.h
index a3d9783f..38b8d6ad 100644
--- a/src/specials.h
+++ b/src/specials.h
@@ -73,6 +73,7 @@ struct special_t {
unsigned long last_colour;
short font_added;
char tempgrad;
+ struct special_t *next;
};
/* direct access to the registered specials (FIXME: bad encapsulation) */
@@ -91,9 +92,6 @@ extern int default_gauge_height;
/* forward declare to avoid mutual inclusion between specials.h and text_object.h */
struct text_object;
-/* max number of specials allowed (TODO: use linked list instead) */
-extern int max_specials;
-
/* scanning special arguments */
const char *scan_bar(struct text_object *, const char *, double);
const char *scan_gauge(struct text_object *, const char *, double);
diff --git a/src/tailhead.cc b/src/tailhead.cc
index 2ac6af67..931c3f25 100644
--- a/src/tailhead.cc
+++ b/src/tailhead.cc
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#define MAX_HEADTAIL_LINES 30
#define DEFAULT_MAX_HEADTAIL_USES 2
diff --git a/src/x11.cc b/src/x11.cc
index 0cb9cd05..07d58db5 100644
--- a/src/x11.cc
+++ b/src/x11.cc
@@ -466,6 +466,8 @@ void destroy_window(void)
void init_window(int w, int h, char **argv, int argc)
{
+ // these vars are unused if OWN_WINDOW is not defined
+ (void)own_window; (void)w; (void)h; (void)argv; (void)argc;
/* There seems to be some problems with setting transparent background
* (on fluxbox this time). It doesn't happen always and I don't know why it
* happens but I bet the bug is somewhere here. */