diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index b9b3a759..ff3e6dd2 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -177,3 +177,5 @@ option(BUILD_ICONV "Enable iconv support" false) option(BUILD_CMUS "Enable support for cmus music player" false) option(BUILD_JOURNAL "Enable support for reading from the systemd journal" false) + +option(BUILD_PULSEAUDIO "Enable support for Pulseaudio's default sink and source" false) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index f19ac24c..8e24284f 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -366,6 +366,12 @@ if(BUILD_JOURNAL) set(conky_includes ${conky_includes} ${SYSTEMD_INCLUDE_PATH}) endif(BUILD_JOURNAL) +if(BUILD_PULSEAUDIO) + pkg_check_modules(PULSEAUDIO REQUIRED libpulse) + set(conky_libs ${conky_libs} ${PULSEAUDIO_LIBRARIES}) + set(conky_includes ${conky_includes} ${PULSEAUDIO_INCLUDE_DIRS}) +endif(BUILD_PULSEAUDIO) + # Common libraries if(WANT_GLIB) pkg_check_modules(GLIB REQUIRED glib-2.0) diff --git a/cmake/config.h.in b/cmake/config.h.in index 72dc5836..0b4a5683 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -103,6 +103,8 @@ #cmakedefine BUILD_IRC 1 +#cmakedefine BUILD_PULSEAUDIO 1 + #cmakedefine BUILD_IPV6 1 #cmakedefine BUILD_HTTP 1 diff --git a/doc/variables.xml b/doc/variables.xml index d6078865..a2b5d528 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -1880,6 +1880,16 @@ between $if_mpd_playing and the matching $endif + + + + + + + If Pulseaudio's default sink is muted, display everything + between $if_pa_sink_muted and the corresponding $else or $endif. + + @@ -2830,6 +2840,51 @@ Change outline color + + + + + + + Pulseaudio's default sink volume percentage. + + + + + + + + + Pulseaudio's default sink volume bar. + + + + + + + + + Pulseaudio's default sink description. + + + + + + + + + Pulseaudio's default card name. + + + + + + + + + Pulseaudio's default card active profile. + + diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index 8daaa0df..b17bf29a 100644 --- a/extras/nano/conky.nanorc +++ b/extras/nano/conky.nanorc @@ -11,7 +11,7 @@ color green "\<(alignment|append_file|background|border_inner_margin|border_oute color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>" ## Variables -color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|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|ical|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|irc|journal|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|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_ping|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|ical|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_pa_sink_muted|if_xmms2_connected|image|imap_messages|imap_unseen|ioscheduler|irc|journal|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|pa_sink_volume|pa_sink_volumebar|pa_sink_description|pa_card_name pa_card_active_profile|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|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_ping|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>" color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?" color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index b3923e7e..93ec4cd0 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -50,7 +50,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName -syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write 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 ical iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler irc journal 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 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_ping 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 ical iconv_start iconv_stop if_pa_sink_muted if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen ioscheduler irc journal 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 pa_sink_volume pa_sink_volumebar pa_sink_description pa_card_name pa_card_active_profile 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 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_ping tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url hi def link ConkyrcComment Comment hi def link ConkyrcSetting Keyword diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22ea021a..aacb5140 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -198,6 +198,11 @@ if(BUILD_NCURSES) set(optional_sources ${optional_sources} nc.cc) endif(BUILD_NCURSES) +if(BUILD_PULSEAUDIO) + set(pulseaudio pulseaudio.cc) + set(optional_sources ${optional_sources} ${pulseaudio}) +endif(BUILD_PULSEAUDIO) + add_executable(conky ${conky_sources} ${optional_sources}) target_link_libraries(conky ${conky_libs}) diff --git a/src/conky.cc b/src/conky.cc index fa6d253a..d1dbad8b 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -322,6 +322,9 @@ static void print_version(void) #ifdef BUILD_I18N << _(" * Internationalization support\n") #endif +#ifdef BUILD_PULSEAUDIO + << _(" * PulseAudio\n") +#endif /* BUIL_PULSEAUDIO */ #ifdef DEBUG << _(" * Debugging extensions\n") #endif diff --git a/src/core.cc b/src/core.cc index d179a307..4a312898 100644 --- a/src/core.cc +++ b/src/core.cc @@ -102,6 +102,9 @@ #ifdef BUILD_JOURNAL #include "journal.h" #endif +#ifdef BUILD_PULSEAUDIO +#include "pulseaudio.h" +#endif /* check for OS and include appropriate headers */ #if defined(__linux__) @@ -307,12 +310,12 @@ struct text_object *construct_text_object(char *s, const char *arg, if(arg) { #ifdef __linux__ if(strpbrk(arg, "/.") != NULL) { - /* + /* * a bit of paranoia. screen out funky paths * i hope no device will have a '.' in its name */ NORM_ERR("acpiacadapter: arg must not contain '/' or '.'"); - } else + } else obj->data.opaque = strdup(arg); #else NORM_ERR("acpiacadapter: arg is only used on linux"); @@ -1875,6 +1878,33 @@ struct text_object *construct_text_object(char *s, const char *arg, obj->callbacks.print = &print_journal; obj->callbacks.free = &free_journal; #endif /* BUILD_JOURNAL */ +#ifdef BUILD_PULSEAUDIO + END OBJ_IF(if_pa_sink_muted, 0) + obj->callbacks.iftest = &puau_muted; + obj->callbacks.free = &free_pulseaudio; + init_pulseaudio(obj); + END OBJ(pa_sink_description, 0) + obj->callbacks.print = &print_puau_sink_description; + obj->callbacks.free = &free_pulseaudio; + init_pulseaudio(obj); + END OBJ(pa_sink_volume, 0) + obj->callbacks.percentage = &puau_vol; + obj->callbacks.free = &free_pulseaudio; + init_pulseaudio(obj); + END OBJ(pa_sink_volumebar, 0) + scan_bar(obj, arg, 1); + init_pulseaudio(obj); + obj->callbacks.barval = &puau_volumebarval; + obj->callbacks.free = &free_pulseaudio; + END OBJ(pa_card_active_profile, 0) + obj->callbacks.print = &print_puau_card_active_profile; + obj->callbacks.free = &free_pulseaudio; + init_pulseaudio(obj); + END OBJ(pa_card_name, 0) + obj->callbacks.print = &print_puau_card_name; + obj->callbacks.free = &free_pulseaudio; + init_pulseaudio(obj); +#endif /* BUILD_PULSEAUDIO */ END { char *buf = (char *)malloc(text_buffer_size.get(*state)); @@ -2121,4 +2151,3 @@ void free_text_objects(struct text_object *root) } } } - diff --git a/src/pulseaudio.cc b/src/pulseaudio.cc new file mode 100644 index 00000000..c654014f --- /dev/null +++ b/src/pulseaudio.cc @@ -0,0 +1,295 @@ +/* -*- 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) 2004, Hannu Saransaari and Lauri Hakkarainen +* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al. +* (see AUTHORS) +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +*/ + +#include "common.h" +#include "config.h" +#include "conky.h" +#include "core.h" +#include "logging.h" +#include "pulseaudio.h" +#include "specials.h" +#include "text_object.h" +#include +#include + +struct pulseaudio_default_results get_result_copy(); + + +const struct pulseaudio_default_results pulseaudio_result0 = + { std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 }; +pulseaudio_c *pulseaudio = NULL; + +void pa_sink_info_callback(pa_context *c, const pa_sink_info *i, int eol, void *data) { + if (i != NULL && data) { + struct pulseaudio_default_results *pdr = (struct pulseaudio_default_results *)data; + pdr->sink_description.assign(i->description); + pdr->sink_mute = i->mute; + pdr->sink_card = i->card; + pdr->sink_index = i->index; + pdr->sink_volume = round_to_int(100.0f * (float)pa_cvolume_avg(&(i->volume)) / (float)PA_VOLUME_NORM); + pa_threaded_mainloop_signal(pulseaudio->mainloop, 0); + } + (void)c; + ++eol; +} + +void pa_server_info_callback(pa_context *c, const pa_server_info *i, void *userdata) { + if (i != NULL) { + struct pulseaudio_default_results *pdr = (struct pulseaudio_default_results *)userdata; + pdr->sink_name.assign(i->default_sink_name); + pa_threaded_mainloop_signal(pulseaudio->mainloop, 0); + } + (void)c; +} + +void pa_server_sink_info_callback(pa_context *c, const pa_server_info *i, void *userdata) { + if (i != NULL) { + struct pulseaudio_default_results *pdr = (struct pulseaudio_default_results *)userdata; + pdr->sink_name.assign(i->default_sink_name); + if(pdr->sink_name.empty()) return; + pa_operation *op; + if (!(op = pa_context_get_sink_info_by_name(c, pdr->sink_name.c_str(), pa_sink_info_callback, pdr))) { + NORM_ERR("pa_context_get_sink_info_by_index() failed"); + return; + } + pa_operation_unref(op); + } + (void)c; +} + +void pa_card_info_callback(pa_context *c, const pa_card_info *card, + int eol, void *userdata) { + if (card) { + struct pulseaudio_default_results *pdr = (struct pulseaudio_default_results *)userdata; + pdr->card_name.assign(card->name); + pdr->card_index = card->index; + pdr->card_active_profile_description.assign(card->active_profile->description); + pa_threaded_mainloop_signal(pulseaudio->mainloop, 0); + } + (void)c; + eol++; +} + +void context_state_cb(pa_context *c, void *userdata) { + pulseaudio_c *puau_int = static_cast( userdata); + switch (pa_context_get_state(c)) { + case PA_CONTEXT_UNCONNECTED: + case PA_CONTEXT_CONNECTING: + case PA_CONTEXT_AUTHORIZING: + case PA_CONTEXT_SETTING_NAME: + break; + + case PA_CONTEXT_READY: { + puau_int->cstate = PULSE_CONTEXT_READY; + break; + } + case PA_CONTEXT_FAILED: + case PA_CONTEXT_TERMINATED: { + puau_int->cstate = PULSE_CONTEXT_FINISHED; + break; + } + default: + return; + } +} + +#define PULSEAUDIO_OP(command, error_msg) \ + if (!(op = command)) { \ + NORM_ERR(error_msg); \ + return; \ + } \ + pa_operation_unref(op); + + +void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index, void *userdata) { + struct pulseaudio_default_results *res = (struct pulseaudio_default_results *)userdata; + + switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { + case PA_SUBSCRIPTION_EVENT_SINK: { + if(res->sink_name.empty()) return; + pa_operation *op; + PULSEAUDIO_OP(pa_context_get_sink_info_by_name(c, res->sink_name.c_str(), + pa_sink_info_callback, res), + "pa_context_get_sink_info_by_name failed"); + } break; + + case PA_SUBSCRIPTION_EVENT_CARD: + if (index == res->card_index && res->card_index != (uint32_t)-1) { + pa_operation *op; + PULSEAUDIO_OP(pa_context_get_card_info_by_index(c, + index, pa_card_info_callback, res), + "pa_context_get_card_info_by_index() failed") + } + break; + + case PA_SUBSCRIPTION_EVENT_SERVER: { + pa_operation *op; + PULSEAUDIO_OP(pa_context_get_server_info(c, + pa_server_sink_info_callback, res), + "pa_context_get_server_info() failed"); + } break; + } +} + +#define PULSEAUDIO_WAIT(COMMAND) \ + op = COMMAND; \ + while (pa_operation_get_state(op) == PA_OPERATION_RUNNING) { \ + pa_threaded_mainloop_wait(pulseaudio->mainloop); \ + } \ + pa_operation_unref(op); + + +void init_pulseaudio(struct text_object *obj) { + // already initialized + (void)obj; + if(pulseaudio != NULL && pulseaudio->cstate == PULSE_CONTEXT_READY) { + pulseaudio->ninits++; + obj->data.opaque = (void *)pulseaudio; + return ; + } + pulseaudio = new pulseaudio_c(); + obj->data.opaque = (void *)pulseaudio; + pulseaudio->ninits++; + + // Create a mainloop API and connection to the default server + pulseaudio->mainloop = pa_threaded_mainloop_new(); + if (!pulseaudio->mainloop) + NORM_ERR("Cannot create pulseaudio mainloop"); + + pulseaudio->mainloop_api = pa_threaded_mainloop_get_api(pulseaudio->mainloop); + + if (!pulseaudio->mainloop_api) + NORM_ERR("Cannot get mainloop api"); + + pulseaudio->context = pa_context_new(pulseaudio->mainloop_api, "Conky Infos"); + + // This function defines a callback so the server will tell us its state. + pa_context_set_state_callback(pulseaudio->context, + context_state_cb, pulseaudio); + + // This function connects to the pulse server + if (pa_context_connect(pulseaudio->context, NULL, (pa_context_flags_t)0, NULL) < 0) { + CRIT_ERR(NULL, NULL, "Cannot connect to pulseaudio"); + return; + } + pa_threaded_mainloop_start(pulseaudio->mainloop); + + while (pulseaudio->cstate != PULSE_CONTEXT_READY) { + usleep(200); + } + + //Initial parameters update + + pa_operation *op; + PULSEAUDIO_WAIT(pa_context_get_server_info(pulseaudio->context, + pa_server_info_callback, &pulseaudio->result)); + + if (pulseaudio->result.sink_name.empty()) + return; + + PULSEAUDIO_WAIT(pa_context_get_sink_info_by_name(pulseaudio->context, pulseaudio->result.sink_name.c_str(), + pa_sink_info_callback, &pulseaudio->result)); + + if (pulseaudio->result.sink_name.empty() || pulseaudio->result.sink_card==(uint32_t)-1){ + NORM_ERR("Incorrect pulseaudio sink information."); + return; + } + PULSEAUDIO_WAIT(pa_context_get_card_info_by_index(pulseaudio->context, pulseaudio->result.sink_card, + pa_card_info_callback, &pulseaudio->result)); + + // get notification when something changes in PA + pa_context_set_subscribe_callback(pulseaudio->context, subscribe_cb, &pulseaudio->result); + + if (!(op = pa_context_subscribe(pulseaudio->context, (pa_subscription_mask_t)(PA_SUBSCRIPTION_MASK_SINK | + PA_SUBSCRIPTION_MASK_SERVER | + PA_SUBSCRIPTION_MASK_CARD), + NULL, NULL))) { + NORM_ERR("pa_context_subscribe() failed"); + return; + } + pa_operation_unref(op); + +} + +void free_pulseaudio(struct text_object *obj) { + pulseaudio_c *puau_int = static_cast( obj->data.opaque); + + if(!puau_int) return; + + if(--puau_int->ninits > 0) { + obj->data.opaque=NULL; + return; + } + + puau_int->cstate = PULSE_CONTEXT_FINISHED; + + if (puau_int->context) { + pa_context_set_state_callback(puau_int->context, NULL, NULL); + pa_context_disconnect(puau_int->context); + pa_context_unref(puau_int->context); + } + if (puau_int->mainloop) { + pa_threaded_mainloop_stop(puau_int->mainloop); + pa_threaded_mainloop_free(puau_int->mainloop); + } + delete puau_int; + puau_int = NULL; +} + +struct pulseaudio_default_results get_pulseaudio(struct text_object *obj) { + pulseaudio_c *puau_int = static_cast( obj->data.opaque); + if(puau_int && puau_int->cstate == PULSE_CONTEXT_READY) + return puau_int->result; + return pulseaudio_result0; +} + +uint8_t puau_vol(struct text_object *obj) { + return get_pulseaudio(obj).sink_volume; +} + +int puau_muted(struct text_object *obj) { + return get_pulseaudio(obj).sink_mute; +} + +void print_puau_sink_description(struct text_object *obj, char *p, int p_max_size) { + snprintf(p, p_max_size, "%s", get_pulseaudio(obj).sink_description.c_str()); +} + +void print_puau_card_active_profile(struct text_object *obj, char *p, int p_max_size) { + snprintf(p, p_max_size, "%s", get_pulseaudio(obj).card_active_profile_description.c_str()); +} + +void print_puau_card_name(struct text_object *obj, char *p, int p_max_size) { + snprintf(p, p_max_size, "%s", get_pulseaudio(obj).card_name.c_str()); +} + +double puau_volumebarval(struct text_object *obj) { + return get_pulseaudio(obj).sink_volume / 100.0f; +} diff --git a/src/pulseaudio.h b/src/pulseaudio.h new file mode 100644 index 00000000..59faf872 --- /dev/null +++ b/src/pulseaudio.h @@ -0,0 +1,83 @@ +/* -*- 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) 2004, Hannu Saransaari and Lauri Hakkarainen +* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al. +* (see AUTHORS) +* All rights reserved. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +*/ + +#ifndef _PULSEAUDIO_H +#define _PULSEAUDIO_H + +#include "text_object.h" +#include + +void init_pulseaudio(struct text_object *obj); +void free_pulseaudio(struct text_object *obj); +uint8_t puau_vol(struct text_object *); // preserve pa_* for libpulse +void print_puau_sink_description(struct text_object *obj, char *p, int p_max_size); +void print_puau_card_name(struct text_object *obj, char *p, int p_max_size); +void print_puau_card_active_profile(struct text_object *obj, char *p, int p_max_size); +double puau_volumebarval(struct text_object *obj); +int puau_muted(struct text_object *obj); + +struct pulseaudio_default_results { + // default sink + std::string sink_name; + std::string sink_description; + uint32_t sink_card; + int sink_mute; + uint32_t sink_index; + unsigned int sink_volume; // percentage + + // default card + std::string card_active_profile_description; + std::string card_name; + uint32_t card_index; +}; + +enum pulseaudio_state { + PULSE_CONTEXT_INITIALIZING, + PULSE_CONTEXT_READY, + PULSE_CONTEXT_FINISHED +}; + +class pulseaudio_c { + public: + pa_threaded_mainloop *mainloop; + pa_mainloop_api *mainloop_api; + pa_context *context; + volatile enum pulseaudio_state cstate; + int ninits; + struct pulseaudio_default_results result; + pulseaudio_c():mainloop(NULL), + mainloop_api(NULL), + context(NULL), + cstate(PULSE_CONTEXT_INITIALIZING), + ninits(0), + result({ std::string(), std::string(), 0, 0, 0, 0, std::string(), std::string(), 0 }){}; +}; + +#endif /* _PULSEAUDIO_H */