1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +00:00

Merge remote branch 'origin/master' into lua-config

Conflicts:
	src/conky.cc
	src/x11.cc
This commit is contained in:
Pavel Labath 2010-04-21 20:35:35 +02:00
commit 00e91d8c31
30 changed files with 791 additions and 388 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ patches/
doc/conky.1 doc/conky.1
README README
build* build*
doc/*.html

View File

@ -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(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(DEFAULTNETDEV "eth0" CACHE STRING "Default networkdevice")
set(CONFIG_FILE "$HOME/.conkyrc" CACHE STRING "Configfile of the user") 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(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(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") 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_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_MOC "Enable if you want MOC (music player) support" true)
option(BUILD_XMMS2 "Enable if you want XMMS2 (music player) support" false) option(BUILD_XMMS2 "Enable if you want XMMS2 (music player) support" false)

View File

@ -80,6 +80,19 @@ if(BUILD_NCURSES)
set(conky_libs ${conky_libs} ${NCURSES_LIB}) set(conky_libs ${conky_libs} ${NCURSES_LIB})
endif(BUILD_NCURSES) 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) if(BUILD_WLAN)
check_include_file(iwlib.h IWLIB_H -D_GNU_SOURCE) check_include_file(iwlib.h IWLIB_H -D_GNU_SOURCE)
if(NOT IWLIB_H) if(NOT IWLIB_H)

View File

@ -15,7 +15,6 @@
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@" #define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
#define DEFAULTNETDEV "@DEFAULTNETDEV@" #define DEFAULTNETDEV "@DEFAULTNETDEV@"
#define CONFIG_FILE "@CONFIG_FILE@" #define CONFIG_FILE "@CONFIG_FILE@"
#define MAX_SPECIALS_DEFAULT @MAX_SPECIALS_DEFAULT@
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@ #define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
#define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@ #define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@ #define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
@ -52,6 +51,8 @@
#cmakedefine BUILD_MPD 1 #cmakedefine BUILD_MPD 1
#cmakedefine BUILD_MYSQL 1
#cmakedefine BUILD_MOC 1 #cmakedefine BUILD_MOC 1
#cmakedefine BUILD_NVIDIA 0 #cmakedefine BUILD_NVIDIA 0

View File

@ -119,6 +119,15 @@
conky -s 'Your uptime is: $uptime' conky -s 'Your uptime is: $uptime'
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>-S | --stdin-config</option>
</command>
</term>
<listitem>Read configuration from stdin.
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>

View File

@ -453,16 +453,6 @@
many connections (if 0 or not set, default is 256) many connections (if 0 or not set, default is 256)
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>max_specials</option>
</command>
</term>
<listitem>Maximum number of special things, e.g. fonts,
offsets, aligns, etc. (default is 512)
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>
@ -534,6 +524,52 @@
<listitem>Port of MPD server <listitem>Port of MPD server
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>mysql_host</option>
</command>
</term>
<listitem>Host of MySQL server. Defaults to localhost
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>mysql_port</option>
</command>
</term>
<listitem>Port of MySQL server. Defaults to the default mysql port
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>mysql_user</option>
</command>
</term>
<listitem>MySQL user name to use when connecting to the server. Defaults to your username
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>mysql_password</option>
</command>
</term>
<listitem>Password of the MySQL user. Place it between "-chars. When this is not set there
is no password used
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>mysql_db</option>
</command>
</term>
<listitem>MySQL database to use. Defaults to mysql
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>

View File

@ -7,8 +7,8 @@
<option>(adapter)</option> <option>(adapter)</option>
</term> </term>
<listitem>ACPI ac adapter state. On linux, the adapter option specifies the <listitem>ACPI ac adapter state. On linux, the adapter option specifies the
subfolder of /sys/class/power_supply containing the state information (defaults subfolder of /sys/class/power_supply containing the state information (tries "AC"
to "AC"). Other systems ignore it. and "ADP1" if there is no argument given). Non-linux systems ignore it.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -675,8 +675,8 @@
</term> </term>
<listitem> <listitem>
Download data from URI using Curl at the Download data from URI using Curl at the
specified interval. The interval may be a floating specified interval. The interval may be a positive floating
point value greater than 0, otherwise defaults to 15 point value (0 is allowed), otherwise defaults to 15
minutes. Most useful when used in conjunction with Lua minutes. Most useful when used in conjunction with Lua
and the Lua API. This object is threaded, and once a and the Lua API. This object is threaded, and once a
thread is created it can't be explicitly destroyed. thread is created it can't be explicitly destroyed.
@ -811,6 +811,22 @@
particular graph value (try it and see). particular graph value (try it and see).
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>distribution</option>
</command>
</term>
<listitem>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.
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>
@ -2071,15 +2087,10 @@
<option>(device)</option> <option>(device)</option>
</term> </term>
<listitem>Prints the mixer value as reported by the OS. <listitem>Prints the mixer value as reported by the OS.
Default mixer is "vol", but you can specify one of the Default mixer is "Master", but you can specify one of the
following optional arguments: "vol", "bass", "treble", available ALSA Simple mixer controls.
"synth", "pcm", "speaker", "line", "mic", "cd", "mix", You can find the list of those available on your system
"pcm2", "rec", "igain", "ogain", "line1", "line2", "line3", using amixer.
"dig1", "dig2", "dig3", "phin", "phout", "video", "radio",
"monitor". Refer to the definition of SOUND_DEVICE_NAMES in
&lt;linux/soundcard.h&gt; (on Linux), &lt;soundcard.h&gt;
(on OpenBSD), or &lt;sys/soundcard.h&gt; to find the exact
options available on your system.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -2407,6 +2418,17 @@
<listitem>MPD's volume <listitem>MPD's volume
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>mysql</option>
</command>
<option>query</option>
</term>
<listitem>Shows the first field of the first row of the
result of the query.
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>
@ -2440,6 +2462,28 @@
<listitem>Hostname <listitem>Hostname
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>nodename_short</option>
</command>
</term>
<listitem>Short hostname (same as 'hostname -s' shell command).
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>no_update</option>
</command>
<option>text</option>
</term>
<listitem>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.
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>
@ -3031,7 +3075,19 @@
</term> </term>
<listitem>Connects to a tcp port on a host (default is <listitem>Connects to a tcp port on a host (default is
localhost), reads every char available at the moment and localhost), reads every char available at the moment and
shows them. shows them.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>read_udp</option>
</command>
<option>(host) port</option>
</term>
<listitem>Connects to a udp port on a host (default is
localhost), reads every char available at the moment and
shows them.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -3217,6 +3273,17 @@
<listitem>Stippled (dashed) horizontal line <listitem>Stippled (dashed) horizontal line
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>stock</option>
</command>
<option>symbol data</option>
</term>
<listitem>Displays the data of a stock symbol. The following data
is supported: adv(Average Daily Volume),ask,asksize,bid
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>

View File

@ -5,13 +5,13 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)" syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items ## 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 ## 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)\>" 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 ## 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 brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"

View File

@ -12,7 +12,7 @@ endif
syn region ConkyrcComment start=/^\s*#/ end=/$/ 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 syn keyword ConkyrcConstant
\ above \ above
@ -50,7 +50,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV
syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName 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 ConkyrcComment Comment
hi def link ConkyrcSetting Keyword hi def link ConkyrcSetting Keyword

View File

@ -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 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 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 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) 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}) set(optional_sources ${optional_sources} ${mpd})
endif(BUILD_MPD) endif(BUILD_MPD)
if(BUILD_MYSQL)
set(mysql mysql.cc)
set(optional_sources ${optional_sources} ${mysql})
endif(BUILD_MYSQL)
if(BUILD_MOC) if(BUILD_MOC)
set(moc moc.cc) set(moc moc.cc)
set(optional_sources ${optional_sources} ${moc}) set(optional_sources ${optional_sources} ${moc})

View File

@ -72,6 +72,7 @@ void ccurl_free_locations(ccurl_location_list &locations)
i != locations.end(); i++) { i != locations.end(); i++) {
free_and_zero((*i)->uri); free_and_zero((*i)->uri);
free_and_zero((*i)->result); free_and_zero((*i)->result);
(*i)->p_timed_thread.reset();
} }
locations.clear(); 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"); NORM_ERR("wrong number of arguments for $curl");
return; 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; obj->data.opaque = cd;
} }

View File

@ -30,6 +30,7 @@
#include "config.h" #include "config.h"
#include "conky.h" #include "conky.h"
#include "core.h"
#include "fs.h" #include "fs.h"
#include "logging.h" #include "logging.h"
#include "net_stat.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 #ifdef BUILD_X11
void scan_loadgraph_arg(struct text_object *obj, const char *arg) 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); 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 print_sysname(struct text_object *obj, char *p, int p_max_size)
{ {
(void)obj; (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])); 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) void print_to_bytes(struct text_object *obj, char *p, int p_max_size)
{ {
std::vector<char> buf(max_user_text); std::vector<char> buf(max_user_text);

View File

@ -34,6 +34,8 @@
#include "text_object.h" #include "text_object.h"
#include "setting.hh" #include "setting.hh"
char* readfile(const char* filename, int* total_read, char showerror);
void print_to_bytes(struct text_object *, char *, int); void print_to_bytes(struct text_object *, char *, int);
void add_update_callback(void (*func)(void)); 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 *); double get_battery_perct_bar(struct text_object *);
void get_battery_short_status(char *buf, unsigned int n, const char *bat); 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 scan_loadavg_arg(struct text_object *, const char *);
void print_loadavg(struct text_object *, char *, int); void print_loadavg(struct text_object *, char *, int);
#ifdef BUILD_X11 #ifdef BUILD_X11
@ -114,6 +120,7 @@ double swap_barval(struct text_object *);
void print_kernel(struct text_object *, char *, int); void print_kernel(struct text_object *, char *, int);
void print_machine(struct text_object *, char *, int); void print_machine(struct text_object *, char *, int);
void print_nodename(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_sysname(struct text_object *, char *, int);
void print_uptime(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); void print_updates(struct text_object *, char *, int);
int updatenr_iftest(struct text_object *); 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 */ #endif /* _COMMON_H */

View File

@ -99,6 +99,9 @@
#include "template.h" #include "template.h"
#include "timeinfo.h" #include "timeinfo.h"
#include "top.h" #include "top.h"
#ifdef BUILD_MYSQL
#include "mysql.h"
#endif /* BUILD_MYSQL */
#include "lua-config.hh" #include "lua-config.hh"
#include "setting.hh" #include "setting.hh"
@ -323,6 +326,8 @@ struct information info;
/* path to config file */ /* path to config file */
std::string current_config; std::string current_config;
bool stdinconfig = false;
/* set to 1 if you want all text to be in uppercase */ /* set to 1 if you want all text to be in uppercase */
static conky::simple_config_setting<bool> stuff_in_uppercase("uppercase", false, true); static conky::simple_config_setting<bool> 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) static int get_string_width_special(char *s, int special_index)
{ {
char *p, *final; char *p, *final;
special_t *current = specials;
int idx = 1; int idx = 1;
int width = 0; int width = 0;
long i; long i;
@ -870,6 +876,11 @@ static int get_string_width_special(char *s, int special_index)
p = strndup(s, text_buffer_size); p = strndup(s, text_buffer_size);
final = p; final = p;
for(i = 0; i < special_index; i++)
current = current->next;
for(i = 0; i < idx; i++)
current = current->next;
while (*p) { while (*p) {
if (*p == SPECIAL_CHAR) { if (*p == SPECIAL_CHAR) {
/* shift everything over by 1 so that the 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++) { for (i = 0; i < (long)strlen(p); i++) {
*(p + i) = *(p + i + 1); *(p + i) = *(p + i + 1);
} }
if (specials[special_index + idx].type == GRAPH if (current->type == GRAPH
|| specials[special_index + idx].type == GAUGE || current->type == GAUGE
|| specials[special_index + idx].type == BAR) { || current->type == BAR) {
width += specials[special_index + idx].width; width += current->width;
} }
idx++; idx++;
current = current->next;
} else if (*p == SECRIT_MULTILINE_CHAR) { } else if (*p == SECRIT_MULTILINE_CHAR) {
*p = 0; *p = 0;
break; break;
@ -966,10 +978,12 @@ static void update_text_area(void)
if (own_window.get(*state) && !fixed_pos) { if (own_window.get(*state) && !fixed_pos) {
x += workarea[0]; x += workarea[0];
y += workarea[1]; 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; long border_total = window.border_inner_margin
window.x = x - window.border_inner_margin - window.border_outer_margin - window.border_width; + window.border_outer_margin + window.border_width;
window.y = y - 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 } else
#endif #endif
{ {
@ -1005,6 +1019,10 @@ static int text_size_updater(char *s, int special_index)
int lw; int lw;
int contain_SECRIT_MULTILINE_CHAR = 0; int contain_SECRIT_MULTILINE_CHAR = 0;
char *p; char *p;
special_t *current = specials;
for(int i = 0; i < special_index; i++)
current = current->next;
if (not out_to_x.get(*state)) if (not out_to_x.get(*state))
return 0; return 0;
@ -1016,40 +1034,41 @@ static int text_size_updater(char *s, int special_index)
w += get_string_width(s); w += get_string_width(s);
*p = SPECIAL_CHAR; *p = SPECIAL_CHAR;
if (specials[special_index].type == BAR if (current->type == BAR
|| specials[special_index].type == GAUGE || current->type == GAUGE
|| specials[special_index].type == GRAPH) { || current->type == GRAPH) {
w += specials[special_index].width; w += current->width;
if (specials[special_index].height > last_font_height) { if (current->height > last_font_height) {
last_font_height = specials[special_index].height; last_font_height = current->height;
last_font_height += font_height(); last_font_height += font_height();
} }
} else if (specials[special_index].type == OFFSET) { } else if (current->type == OFFSET) {
if (specials[special_index].arg > 0) { if (current->arg > 0) {
w += specials[special_index].arg; w += current->arg;
} }
} else if (specials[special_index].type == VOFFSET) { } else if (current->type == VOFFSET) {
last_font_height += specials[special_index].arg; last_font_height += current->arg;
} else if (specials[special_index].type == GOTO) { } else if (current->type == GOTO) {
if (specials[special_index].arg > cur_x) { if (current->arg > cur_x) {
w = (int) specials[special_index].arg; w = (int) current->arg;
} }
} else if (specials[special_index].type == TAB) { } else if (current->type == TAB) {
int start = specials[special_index].arg; int start = current->arg;
int step = specials[special_index].width; int step = current->width;
if (!step || step < 0) { if (!step || step < 0) {
step = 10; step = 10;
} }
w += step - (cur_x - text_start_x - start) % step; w += step - (cur_x - text_start_x - start) % step;
} else if (specials[special_index].type == FONT) { } else if (current->type == FONT) {
selected_font = specials[special_index].font_added; selected_font = current->font_added;
if (font_height() > last_font_height) { if (font_height() > last_font_height) {
last_font_height = font_height(); last_font_height = font_height();
} }
} }
special_index++; special_index++;
current = current->next;
s = p + 1; s = p + 1;
} else if (*p == SECRIT_MULTILINE_CHAR) { } else if (*p == SECRIT_MULTILINE_CHAR) {
contain_SECRIT_MULTILINE_CHAR = 1; 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; s = p + 1;
} }
/* draw special */ /* 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 #ifdef BUILD_X11
case HORIZONTAL_LINE: case HORIZONTAL_LINE:
{ {
int h = specials[special_index].height; int h = current->height;
int mid = font_ascent() / 2; int mid = font_ascent() / 2;
w = text_start_x + text_width - cur_x; 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: case STIPPLED_HR:
{ {
int h = specials[special_index].height; int h = current->height;
char tmp_s = specials[special_index].arg; char tmp_s = current->arg;
int mid = font_ascent() / 2; int mid = font_ascent() / 2;
char ss[2] = { tmp_s, tmp_s }; 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) { && maximum_width > 0) {
break; break;
} }
h = specials[special_index].height; h = current->height;
bar_usage = specials[special_index].arg; bar_usage = current->arg;
scale = specials[special_index].scale; scale = current->scale;
by = cur_y - (font_ascent() / 2) - 1; by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) { if (h < font_h) {
by -= h / 2 - 1; by -= h / 2 - 1;
} }
w = specials[special_index].width; w = current->width;
if (w == 0) { if (w == 0) {
w = text_start_x + text_width - cur_x - 1; 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; break;
} }
h = specials[special_index].height; h = current->height;
by = cur_y - (font_ascent() / 2) - 1; by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) { if (h < font_h) {
by -= h / 2 - 1; by -= h / 2 - 1;
} }
w = specials[special_index].width; w = current->width;
if (w == 0) { if (w == 0) {
w = text_start_x + text_width - cur_x - 1; 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); cur_x, by, w, h * 2, 0, 180*64);
#ifdef MATH #ifdef MATH
usage = specials[special_index].arg; usage = current->arg;
scale = specials[special_index].scale; scale = current->scale;
angle = M_PI * usage / scale; angle = M_PI * usage / scale;
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle); px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
py = (float)(by+(h))-(float)(h)*sin(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) { && maximum_width > 0) {
break; break;
} }
h = specials[special_index].height; h = current->height;
by = cur_y - (font_ascent() / 2) - 1; by = cur_y - (font_ascent() / 2) - 1;
if (h < font_h) { if (h < font_h) {
by -= h / 2 - 1; by -= h / 2 - 1;
} }
w = specials[special_index].width; w = current->width;
if (w == 0) { if (w == 0) {
w = text_start_x + text_width - cur_x - 1; 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, XSetLineAttributes(display, window.gc, 1, LineSolid,
CapButt, JoinMiter); CapButt, JoinMiter);
if (specials[special_index].last_colour != 0 if (current->last_colour != 0
|| specials[special_index].first_colour != 0) { || current->first_colour != 0) {
tmpcolour = do_gradient(w - 1, specials[special_index].last_colour, specials[special_index].first_colour); tmpcolour = do_gradient(w - 1, current->last_colour, current->first_colour);
} }
colour_idx = 0; colour_idx = 0;
for (i = w - 2; i > -1; i--) { for (i = w - 2; i > -1; i--) {
if (specials[special_index].last_colour != 0 if (current->last_colour != 0
|| specials[special_index].first_colour != 0) { || current->first_colour != 0) {
if (specials[special_index].tempgrad) { if (current->tempgrad) {
#ifdef DEBUG_lol #ifdef DEBUG_lol
assert( assert(
(int)((float)(w - 2) - specials[special_index].graph[j] * (int)((float)(w - 2) - current->graph[j] *
(w - 2) / (float)specials[special_index].scale) (w - 2) / (float)current->scale)
< w - 1 < w - 1
); );
assert( assert(
(int)((float)(w - 2) - specials[special_index].graph[j] * (int)((float)(w - 2) - current->graph[j] *
(w - 2) / (float)specials[special_index].scale) (w - 2) / (float)current->scale)
> -1 > -1
); );
if (specials[special_index].graph[j] == specials[special_index].scale) { if (current->graph[j] == current->scale) {
assert( assert(
(int)((float)(w - 2) - specials[special_index].graph[j] * (int)((float)(w - 2) - current->graph[j] *
(w - 2) / (float)specials[special_index].scale) (w - 2) / (float)current->scale)
== 0 == 0
); );
} }
#endif /* DEBUG_lol */ #endif /* DEBUG_lol */
XSetForeground(display, window.gc, tmpcolour[ XSetForeground(display, window.gc, tmpcolour[
(int)((float)(w - 2) - specials[special_index].graph[j] * (int)((float)(w - 2) - current->graph[j] *
(w - 2) / (float)specials[special_index].scale) (w - 2) / (float)current->scale)
]); ]);
} else { } else {
XSetForeground(display, window.gc, tmpcolour[colour_idx++]); 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 */ /* this is mugfugly, but it works */
XDrawLine(display, window.drawable, window.gc, XDrawLine(display, window.drawable, window.gc,
cur_x + i + 1, by + h, cur_x + i + 1, cur_x + i + 1, by + h, cur_x + i + 1,
round_to_int((double)by + h - specials[special_index].graph[j] * round_to_int((double)by + h - current->graph[j] *
(h - 1) / specials[special_index].scale)); (h - 1) / current->scale));
if ((w - i) / ((float) (w - 2) / if ((w - i) / ((float) (w - 2) /
(specials[special_index].graph_width)) > j (current->graph_width)) > j
&& j < MAX_GRAPH_DEPTH - 3) { && j < MAX_GRAPH_DEPTH - 3) {
j++; j++;
} }
@ -1519,16 +1541,16 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
cur_y = tmp_y; cur_y = tmp_y;
} }
#ifdef MATH #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_x = cur_x;
int tmp_y = cur_y; int tmp_y = cur_y;
char *tmp_str; char *tmp_str;
cur_x += font_ascent() / 2; cur_x += font_ascent() / 2;
cur_y += font_h / 2; cur_y += font_h / 2;
tmp_str = (char *) tmp_str = (char *)
calloc(log10(floor(specials[special_index].scale)) + 4, calloc(log10(floor(current->scale)) + 4,
sizeof(char)); sizeof(char));
sprintf(tmp_str, "%.1f", specials[special_index].scale); sprintf(tmp_str, "%.1f", current->scale);
draw_string(tmp_str); draw_string(tmp_str);
free(tmp_str); free(tmp_str);
cur_x = tmp_x; 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(); int old = font_ascent();
cur_y -= font_ascent(); cur_y -= font_ascent();
selected_font = specials[special_index].font_added; selected_font = current->font_added;
set_font(); set_font();
if (cur_y + font_ascent() < cur_y + old) { if (cur_y + font_ascent() < cur_y + old) {
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 */ #endif /* BUILD_X11 */
case FG: case FG:
if (draw_mode == FG) { if (draw_mode == FG) {
set_foreground_color(specials[special_index].arg); set_foreground_color(current->arg);
} }
break; break;
#ifdef BUILD_X11 #ifdef BUILD_X11
case BG: case BG:
if (draw_mode == BG) { if (draw_mode == BG) {
set_foreground_color(specials[special_index].arg); set_foreground_color(current->arg);
} }
break; break;
case OUTLINE: case OUTLINE:
if (draw_mode == OUTLINE) { if (draw_mode == OUTLINE) {
set_foreground_color(specials[special_index].arg); set_foreground_color(current->arg);
} }
break; break;
case OFFSET: case OFFSET:
w += specials[special_index].arg; w += current->arg;
last_special_needed = special_index; last_special_needed = special_index;
break; break;
case VOFFSET: case VOFFSET:
cur_y += specials[special_index].arg; cur_y += current->arg;
break; break;
case GOTO: case GOTO:
if (specials[special_index].arg >= 0) { if (current->arg >= 0) {
cur_x = (int) specials[special_index].arg; cur_x = (int) current->arg;
} }
last_special_needed = special_index; last_special_needed = special_index;
break; break;
case TAB: case TAB:
{ {
int start = specials[special_index].arg; int start = current->arg;
int step = specials[special_index].width; int step = current->width;
if (!step || step < 0) { if (!step || step < 0) {
step = 10; 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 " /* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
"get_string_width(p) %i gap_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, "window.border_width %i\n", pos_x, text_start_x, text_width,
cur_x, get_string_width_special(s), gap_x, 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); */ window.border_width); */
if (pos_x > specials[special_index].arg && pos_x > cur_x) { if (pos_x > current->arg && pos_x > cur_x) {
cur_x = pos_x - specials[special_index].arg; cur_x = pos_x - current->arg;
} }
last_special_needed = special_index; last_special_needed = special_index;
break; 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 " /* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
"get_string_width(p) %i gap_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, text_width, cur_x, get_string_width(s), gap_x,
specials[special_index].arg); */ current->arg); */
if (pos_x > specials[special_index].arg) { if (pos_x > current->arg) {
w = pos_x - specials[special_index].arg; w = pos_x - current->arg;
} }
last_special_needed = special_index; last_special_needed = special_index;
break; break;
@ -1818,10 +1840,12 @@ static void clear_text(int exposures)
#endif #endif
if (display && window.window) { // make sure these are !null if (display && window.window) { // make sure these are !null
/* there is some extra space for borders and outlines */ /* 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, long border_total = window.border_inner_margin
text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width, + 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); 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 */ #endif /* BUILD_X11 */
@ -1938,16 +1962,21 @@ static void main_loop(void)
need_to_update = 0; need_to_update = 0;
selected_font = 0; selected_font = 0;
update_text_area(); 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 #ifdef OWN_WINDOW
if (own_window.get(*state)) { if (own_window.get(*state)) {
int changed = 0; int changed = 0;
/* resize window if it isn't right size */ /* resize window if it isn't right size */
if (!fixed_size if (!fixed_size
&& (text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2 != window.width && (text_width + 2*border_total != window.width
|| text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2 != window.height)) { || text_height + 2*border_total != window.height)) {
window.width = text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2; window.width = text_width + 2*border_total;
window.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2; window.height = text_height + 2*border_total;
draw_stuff(); /* redraw everything in our newly sized window */ draw_stuff(); /* redraw everything in our newly sized window */
XResizeWindow(display, window.window, window.width, XResizeWindow(display, window.window, window.width,
window.height); /* resize window */ window.height); /* resize window */
@ -2017,10 +2046,10 @@ static void main_loop(void)
if (use_xdbe) { if (use_xdbe) {
XRectangle r; XRectangle r;
r.x = text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width; r.x = text_start_x - border_total;
r.y = text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width; r.y = text_start_y - border_total;
r.width = text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2; r.width = text_width + 2*border_total;
r.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2; r.height = text_height + 2*border_total;
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region); XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
} }
#endif #endif
@ -2176,10 +2205,12 @@ static void main_loop(void)
if (use_xdbe) { if (use_xdbe) {
XRectangle r; XRectangle r;
r.x = text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width; long border_total = window.border_inner_margin
r.y = text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width; + 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.x = text_start_x - border_total;
r.height = text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2; 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); XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
} }
#endif #endif
@ -2329,10 +2360,41 @@ static void reload_config(void)
initialisation(argc_copy, argv_copy); 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) void clean_up(void *memtofree1, void* memtofree2)
{ {
int i;
free_update_callbacks(); free_update_callbacks();
#ifdef BUILD_NCURSES #ifdef BUILD_NCURSES
@ -2349,19 +2411,7 @@ void clean_up(void *memtofree1, void* memtofree2)
free_and_zero(info.cpu_usage); free_and_zero(info.cpu_usage);
#ifdef BUILD_X11 #ifdef BUILD_X11
if (x_initialised == YES) { if (x_initialised == YES) {
if(window_created == 1) { clean_up_x11();
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;
}else{ }else{
free(fonts); //in set_default_configurations a font is set but not loaded free(fonts); //in set_default_configurations a font is set but not loaded
font_count = -1; font_count = -1;
@ -2406,14 +2456,7 @@ void clean_up(void *memtofree1, void* memtofree2)
xmlCleanupParser(); xmlCleanupParser();
#endif /* BUILD_WEATHER_XOAP */ #endif /* BUILD_WEATHER_XOAP */
if (specials) { free_specials(specials);
for (i = 0; i < special_count; i++) {
if (specials[i].type == GRAPH) {
free(specials[i].graph);
}
}
free_and_zero(specials);
}
clear_net_stats(); clear_net_stats();
clear_diskio_stats(); clear_diskio_stats();
@ -2490,6 +2533,13 @@ static void set_default_configurations(void)
mpd_set_port("6600"); mpd_set_port("6600");
} }
#endif /* BUILD_MPD */ #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 #ifdef BUILD_XMMS2
info.xmms2.artist = NULL; info.xmms2.artist = NULL;
info.xmms2.album = NULL; info.xmms2.album = NULL;
@ -2565,16 +2615,12 @@ static bool append_works(const char *path)
} }
#ifdef BUILD_X11 #ifdef BUILD_X11
static char **xargv = 0;
static int xargc = 0;
static void X11_create_window(void) static void X11_create_window(void)
{ {
if (out_to_x.get(*state)) { if (out_to_x.get(*state)) {
init_window(text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2, 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, text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
xargv, xargc); argv_copy, argc_copy);
setup_fonts(); setup_fonts();
load_fonts(); load_fonts();
update_text_area(); /* to position text/window on screen */ update_text_area(); /* to position text/window on screen */
@ -2821,6 +2867,43 @@ char load_config_file(const char *f)
} }
} }
#endif /* BUILD_MPD */ #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") { CONF("music_player_interval") {
if (value) { if (value) {
info.music_player_interval = strtod(value, 0); info.music_player_interval = strtod(value, 0);
@ -3068,13 +3151,6 @@ char load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
CONF("max_specials") {
if (value) {
max_specials = atoi(value);
} else {
CONF_ERR;
}
}
CONF("max_user_text") { CONF("max_user_text") {
if (value) { if (value) {
max_user_text = atoi(value); max_user_text = atoi(value);
@ -3281,6 +3357,7 @@ static void print_help(const char *prog_name) {
" -y Y y position\n" " -y Y y position\n"
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
" -s, --for-scripts=TEXT render TEXT on stdout and exit, enclose TEXT by single quotes\n" " -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" " -t, --text=TEXT text to render, remember single quotes, like -t '$uptime'\n"
" -u, --interval=SECS update interval\n" " -u, --interval=SECS update interval\n"
" -i COUNT number of times to update "PACKAGE_NAME" (and quit)\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 */ /* : 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 #ifdef BUILD_X11
"x:y:w:a:f:X:" "x:y:w:a:f:X:"
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
@ -3337,6 +3414,7 @@ static const struct option longopts[] = {
{ "window-id", 1, NULL, 'w' }, { "window-id", 1, NULL, 'w' },
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
{ "for-scripts", 1, NULL, 's' }, { "for-scripts", 1, NULL, 's' },
{ "stdin-config", 0, NULL, 'S' },
{ "text", 1, NULL, 't' }, { "text", 1, NULL, 't' },
{ "interval", 1, NULL, 'u' }, { "interval", 1, NULL, 'u' },
{ "pause", 1, NULL, 'p' }, { "pause", 1, NULL, 'p' },
@ -3344,8 +3422,13 @@ static const struct option longopts[] = {
}; };
void set_current_config() { void set_current_config() {
/* check if specified config file is valid */ /* set configfile to stdin if that's requested or check if specified config file is valid */
if (not current_config.empty()) { 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; struct stat sb;
if (stat(current_config.c_str(), &sb) || if (stat(current_config.c_str(), &sb) ||
(!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) { (!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()); 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 #ifdef MAIL_FILE
if (current_mail_spool == NULL) { if (current_mail_spool == NULL) {
char buf[256]; char buf[256];
@ -3558,8 +3636,6 @@ void initialisation(int argc, char **argv) {
memset(tmpstring2, 0, text_buffer_size); memset(tmpstring2, 0, text_buffer_size);
#ifdef BUILD_X11 #ifdef BUILD_X11
xargc = argc;
xargv = argv;
X11_create_window(); X11_create_window();
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
#ifdef BUILD_LUA #ifdef BUILD_LUA
@ -3644,6 +3720,9 @@ int main(int argc, char **argv)
case 'c': case 'c':
current_config = optarg; current_config = optarg;
break; break;
case 'S':
stdinconfig = true;
break;
case 'q': case 'q':
if (!freopen("/dev/null", "w", stderr)) if (!freopen("/dev/null", "w", stderr))
CRIT_ERR(0, 0, "could not open /dev/null as 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 */ #endif /* BUILD_WEATHER_XOAP */
#ifdef HAVE_SYS_INOTIFY_H #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 */ #endif /* HAVE_SYS_INOTIFY_H */
initialisation(argc, argv); initialisation(argc, argv);

View File

@ -88,6 +88,10 @@ struct text_object;
#include "mpd.h" #include "mpd.h"
#endif /* BUILD_MPD */ #endif /* BUILD_MPD */
#ifdef BUILD_MYSQL
#include "mysql.h"
#endif /* BUILD_MYSQL */
/* C++ headers */ /* C++ headers */
#ifdef BUILD_CURL #ifdef BUILD_CURL
#include "ccurl_thread.h" #include "ccurl_thread.h"

View File

@ -42,6 +42,9 @@
#include "i8k.h" #include "i8k.h"
#include "imlib2.h" #include "imlib2.h"
#include "proc.h" #include "proc.h"
#ifdef BUILD_MYSQL
#include "mysql.h"
#endif
#ifdef BUILD_X11 #ifdef BUILD_X11
#include "fonts.h" #include "fonts.h"
#endif #endif
@ -64,7 +67,7 @@
#ifdef BUILD_NVIDIA #ifdef BUILD_NVIDIA
#include "nvidia.h" #include "nvidia.h"
#endif #endif
#include "read_tcp.h" #include "read_tcpip.h"
#include "scroll.h" #include "scroll.h"
#include "specials.h" #include "specials.h"
#include "temphelper.h" #include "temphelper.h"
@ -135,6 +138,31 @@ static struct text_object *create_plain_text(const char *s)
return obj; 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 */ /* construct_text_object() creates a new text_object */
struct text_object *construct_text_object(char *s, const char *arg, long struct text_object *construct_text_object(char *s, const char *arg, long
line, void **ifblock_opaque, void *free_at_crash) 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)) { \ #define __OBJ_HEAD(a, n) if (!strcmp(s, #a)) { \
add_update_callback(n); add_update_callback(n);
#define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj) #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 */ /* defines to be used below */
#define OBJ(a, n) __OBJ_HEAD(a, n) { #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"); NORM_ERR("acpiacadapter: arg is only used on linux");
#endif #endif
} }
if(! obj->data.opaque)
obj->data.opaque = strdup("AC");
obj->callbacks.print = &print_acpiacadapter; obj->callbacks.print = &print_acpiacadapter;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
@ -212,9 +237,13 @@ struct text_object *construct_text_object(char *s, const char *arg, long
} }
obj->callbacks.print = &print_freq_g; obj->callbacks.print = &print_freq_g;
END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)") 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.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__) #if defined(__linux__)
END OBJ(voltage_mv, 0) END OBJ(voltage_mv, 0)
get_cpu_count(); get_cpu_count();
@ -318,11 +347,11 @@ struct text_object *construct_text_object(char *s, const char *arg, long
END OBJ(battery_bar, 0) END OBJ(battery_bar, 0)
char bat[64]; char bat[64];
if (arg) { if (arg) {
arg = scan_bar(obj, arg, 100);
sscanf(arg, "%63s", bat); sscanf(arg, "%63s", bat);
} else { } else {
strcpy(bat, "BAT0"); strcpy(bat, "BAT0");
} }
scan_bar(obj, bat, 100);
obj->data.s = strndup(bat, text_buffer_size); obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.barval = &get_battery_perct_bar; obj->callbacks.barval = &get_battery_perct_bar;
obj->callbacks.free = &gen_free_opaque; 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.print = &print_image_callback;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
#endif /* BUILD_IMLIB2 */ #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) END OBJ(exec, 0)
scan_exec_arg(obj, arg); scan_exec_arg(obj, arg);
obj->parse = false; 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; obj->callbacks.print = &print_format_time;
END OBJ(nodename, 0) END OBJ(nodename, 0)
obj->callbacks.print = &print_nodename; 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") 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); scan_cmdline_to_pid_arg(obj, arg, free_at_crash);
obj->callbacks.print = &print_cmdline_to_pid; 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) END OBJ(processes, &update_total_processes)
obj->callbacks.print = &print_processes; obj->callbacks.print = &print_processes;
#ifdef __linux__ #ifdef __linux__
END OBJ(distribution, 0)
obj->callbacks.print = &print_distribution;
END OBJ(running_processes, &update_top) END OBJ(running_processes, &update_top)
top_running = 1; top_running = 1;
obj->callbacks.print = &print_running_processes; 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)); obj->sub = (text_object*)malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg); extract_variable_text_internal(obj->sub, arg);
obj->callbacks.print = &print_to_bytes; 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) END OBJ(scroll, 0)
#ifdef BUILD_X11 #ifdef BUILD_X11
/* allocate a follower to reset any color changes */ /* 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 { END {
char *buf = (char *)malloc(text_buffer_size); 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); snprintf(buf, text_buffer_size, "${%s}", s);
obj_be_plain_text(obj, buf); obj_be_plain_text(obj, buf);
free(buf); free(buf);
@ -1819,7 +1868,7 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
strfold(p, 1); strfold(p, 1);
} else if (*p == '#') { } else if (*p == '#') {
char c; 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 */ /* if remove_comment removed a newline, we need to 'back up' with p */
p--; p--;
} }

View File

@ -1,4 +1,5 @@
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- /* -*- 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 * Conky, a system monitor, based on torsmo
* *

View File

@ -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 Update: it seems the folder name is hardware-dependent. We add an aditional adapter
argument, specifying the folder name. 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) 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 buf[256];
char buf2[256]; char buf2[256];
struct stat sb;
FILE *fp; FILE *fp;
if (!p_client_buffer || client_buffer_size <= 0) { if (!p_client_buffer || client_buffer_size <= 0) {
return; return;
} }
snprintf(buf2, sizeof(buf2), "%s/%s/uevent", SYSFS_AC_ADAPTER_DIR, adapter); if(adapter)
fp = open_file(buf2, &rep); 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) { if (fp) {
/* sysfs processing */ /* sysfs processing */
while (!feof(fp)) { while (!feof(fp)) {
@ -2363,3 +2371,39 @@ void update_diskio(void)
update_diskio_values(&stats, total_reads, total_writes); update_diskio_values(&stats, total_reads, total_writes);
fclose(fp); 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<bytes_read; i++) {
if(buf[i-1] == '(' && buf[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);
}
}

View File

@ -53,4 +53,6 @@ int get_entropy_poolsize(unsigned int *);
void update_stat(void); void update_stat(void);
void print_distribution(struct text_object *, char *, int);
#endif /* _LINUX_H */ #endif /* _LINUX_H */

View File

@ -38,9 +38,6 @@
#include <ctype.h> #include <ctype.h>
#ifdef MIXER_IS_ALSA
#include <alsa/asoundlib.h>
#else
#ifdef HAVE_LINUX_SOUNDCARD_H #ifdef HAVE_LINUX_SOUNDCARD_H
#include <linux/soundcard.h> #include <linux/soundcard.h>
#else #else
@ -50,173 +47,12 @@
#include <sys/soundcard.h> #include <sys/soundcard.h>
#endif /* __OpenBSD__ */ #endif /* __OpenBSD__ */
#endif /* HAVE_LINUX_SOUNDCARD_H */ #endif /* HAVE_LINUX_SOUNDCARD_H */
#endif /* MIXER_IS_ALSA */
#define MIXER_DEV "/dev/mixer" #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 int mixer_fd;
static const char *devs[] = SOUND_DEVICE_NAMES; 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) int mixer_init(const char *name)
{ {
unsigned int i; unsigned int i;
@ -282,7 +118,6 @@ int mixer_is_mute(int i)
} }
#define mixer_to_255(i, x) x #define mixer_to_255(i, x) x
#endif /* MIXER_IS_ALSA */
void parse_mixer_arg(struct text_object *obj, const char *arg) 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) { if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
obj->data.i = mixer_init(buf1); obj->data.i = mixer_init(buf1);
scan_bar(obj, arg + n, 255); scan_bar(obj, arg + n, 100);
} else { } else {
obj->data.i = mixer_init(NULL); obj->data.i = mixer_init(NULL);
scan_bar(obj, arg, 255); scan_bar(obj, arg, 100);
} }
} }

View File

@ -99,8 +99,6 @@ void init_mpd(void)
{ {
if (!(refcount++)) /* first client */ if (!(refcount++)) /* first client */
memset(&mpd_info, 0, sizeof(mpd_info)); memset(&mpd_info, 0, sizeof(mpd_info));
refcount++;
} }
static void clear_mpd(void) static void clear_mpd(void)
@ -304,7 +302,7 @@ bool mpd_process(thread_handle &handle)
static void update_mpd_thread(thread_handle &handle) static void update_mpd_thread(thread_handle &handle)
{ {
while (1) if (mpd_process(handle)) return; while (mpd_process(handle)) ;
/* never reached */ /* never reached */
} }

112
src/mysql.cc Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
#include "conky.h"
#include "logging.h"
#include <mysql.h>
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);
}

48
src/mysql.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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_*/

View File

@ -37,7 +37,7 @@
#include <dirent.h> #include <dirent.h>
#include <memory> #include <memory>
char* readfile(char* filename, int* total_read, char showerror) { char* readfile(const char* filename, int* total_read, char showerror) {
FILE* file; FILE* file;
char* buf = NULL; char* buf = NULL;
int bytes_read; int bytes_read;

View File

@ -37,17 +37,17 @@
#include <unistd.h> #include <unistd.h>
#include <netinet/in.h> #include <netinet/in.h>
struct read_tcp_data { struct read_tcpip_data {
char *host; char *host;
unsigned int port; 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)); rtd = (struct read_tcpip_data *) malloc(sizeof(struct read_tcpip_data));
memset(rtd, 0, sizeof(struct read_tcp_data)); memset(rtd, 0, sizeof(struct read_tcpip_data));
rtd->host = (char *) malloc(text_buffer_size); rtd->host = (char *) malloc(text_buffer_size);
sscanf(arg, "%s", rtd->host); 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"); strcpy(rtd->host,"localhost");
} }
if(rtd->port < 1 || rtd->port > 65535) 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); rtd->port = htons(rtd->port);
obj->data.opaque = rtd; 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; int sock, received;
struct sockaddr_in addr; struct sockaddr_in addr;
struct hostent* he; struct hostent* he;
fd_set readfds; fd_set readfds;
struct timeval tv; 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) if (!rtd)
return; return;
if (!(he = gethostbyname(rtd->host))) { 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; return;
} }
if ((sock = socket(he->h_addrtype, SOCK_STREAM, 0)) == -1) { if ((sock = socket(he->h_addrtype, protocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, protocol)) == -1) {
NORM_ERR("read_tcp: Couldn't create a socket"); NORM_ERR("%s: Couldn't create a socket", protocol == IPPROTO_TCP ? "read_tcp" : "read_udp");
return; return;
} }
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = rtd->port; addr.sin_port = rtd->port;
memcpy(&addr.sin_addr, he->h_addr, he->h_length); memcpy(&addr.sin_addr, he->h_addr, he->h_length);
if (!connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))) { if (connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)) != 0) {
NORM_ERR("read_tcp: Couldn't create a connection"); 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; 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_ZERO(&readfds);
FD_SET(sock, &readfds); FD_SET(sock, &readfds);
tv.tv_sec = 1; tv.tv_sec = 1;
tv.tv_usec = 0; tv.tv_usec = 0;
if(select(sock + 1, &readfds, NULL, NULL, &tv) > 0){ if(select(sock + 1, &readfds, NULL, NULL, &tv) > 0){
received = recv(sock, p, p_max_size, 0); received = recv(sock, p, p_max_size, 0);
p[received] = 0; if(received != -1) p[received] = 0; else p[0] = 0;
} }
close(sock); 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) if (!rtd)
return; return;

View File

@ -31,8 +31,9 @@
#ifndef _READ_TCP_H #ifndef _READ_TCP_H
#define _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 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 */ #endif /* _READ_TCP_H */

View File

@ -40,11 +40,6 @@
#endif /* HAVE_SYS_PARAM_H */ #endif /* HAVE_SYS_PARAM_H */
#include <algorithm> #include <algorithm>
/* 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; struct special_t *specials = NULL;
int special_count; int special_count;
@ -251,16 +246,32 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale)
* Printing various special text objects * 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) struct special_t *new_special(char *buf, enum special_types t)
{ {
if (special_count >= max_specials) { special_t* current;
CRIT_ERR(NULL, NULL, "too many special things in text");
}
buf[0] = SPECIAL_CHAR; buf[0] = SPECIAL_CHAR;
buf[1] = '\0'; buf[1] = '\0';
specials[special_count].type = t; if(!specials)
return &specials[special_count++]; 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) void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, double usage)

View File

@ -73,6 +73,7 @@ struct special_t {
unsigned long last_colour; unsigned long last_colour;
short font_added; short font_added;
char tempgrad; char tempgrad;
struct special_t *next;
}; };
/* direct access to the registered specials (FIXME: bad encapsulation) */ /* 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 */ /* forward declare to avoid mutual inclusion between specials.h and text_object.h */
struct text_object; struct text_object;
/* max number of specials allowed (TODO: use linked list instead) */
extern int max_specials;
/* scanning special arguments */ /* scanning special arguments */
const char *scan_bar(struct text_object *, const char *, double); const char *scan_bar(struct text_object *, const char *, double);
const char *scan_gauge(struct text_object *, const char *, double); const char *scan_gauge(struct text_object *, const char *, double);

View File

@ -38,6 +38,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <memory>
#define MAX_HEADTAIL_LINES 30 #define MAX_HEADTAIL_LINES 30
#define DEFAULT_MAX_HEADTAIL_USES 2 #define DEFAULT_MAX_HEADTAIL_USES 2

View File

@ -466,6 +466,8 @@ void destroy_window(void)
void init_window(int w, int h, char **argv, int argc) 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 /* 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 * (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. */ * happens but I bet the bug is somewhere here. */