1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-30 05:59:07 +00:00

cosmetic fixup session

- kill trailing whitespace (grep -n ' $' src/*.{c,cc,h})
- eliminate space before tab (grep -n ' 	' src/*.{c,cc,h})
  (insert tab by pressing CTRL-v first)
- little indenting fixup in configure.ac.in (we indent using tabs, not
  spaces)

note: this should not change the actual code at all - if it does, feel
free to blame me personally ;)
This commit is contained in:
Phil Sutter 2009-12-28 21:21:28 +01:00
parent 7d92e46533
commit 6f587402d8
9 changed files with 127 additions and 128 deletions

View File

@ -655,7 +655,7 @@ AC_ARG_ENABLE([nvidia],
AC_HELP_STRING([--enable-nvidia], [enable if you want nvidia support @<:@default=no@:>@]),
[want_nvidia="$enableval"], [want_nvidia=no])
if test x$want_nvidia = xyes; then
if test "x$want_x11" != "xyes"; then
if test "x$want_x11" != "xyes"; then
# do nada
want_nvidia=no
else
@ -665,7 +665,7 @@ dnl AC_CHECK_LIB([XNVCtrl], [XNVCTRLCheckTargetData], [], [AC_MSG_ERROR([grr])])
dnl ## am I Stupid ??
dnl ## it won't find the lib for some reason!?
conky_LIBS="$conky_LIBS -lXNVCtrl"
AC_DEFINE(NVIDIA, 1, [Define if you want nvidia support])
AC_DEFINE(NVIDIA, 1, [Define if you want nvidia support])
fi
fi
AM_CONDITIONAL(BUILD_NVIDIA, test x$want_nvidia = xyes)

View File

@ -188,8 +188,8 @@ void print_apm_battery_time(struct text_object *obj, char *p, int p_max_size)
if (batt_time == -1) {
snprintf(p, p_max_size, "unknown");
} else
} else
#ifdef __OpenBSD__
{
h = batt_time / 60;

View File

@ -113,7 +113,7 @@ void to_real_path(char *dest, const char *source)
NORM_ERR("$HOME environment variable doesn't exist");
strncpy(dest, source, DEFAULT_TEXT_BUFFER_SIZE);
}
} else if (dest != source) { //see changelog 2009-06-29 if you doubt that this check is necessary
} else if (dest != source) { //see changelog 2009-06-29 if you doubt that this check is necessary
strncpy(dest, source, DEFAULT_TEXT_BUFFER_SIZE);
}
}

View File

@ -1,4 +1,4 @@
/* -*- 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=c
*/

View File

@ -20,7 +20,7 @@
* 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 "config.h"

View File

@ -585,11 +585,11 @@ void human_readable(long long num, char *buf, int size)
* adjusting the decimal part of the number. Sample output:
* 123MiB
* 23.4GiB
* 5.12B
* 5.12B
* so the point of alignment resides between number and unit. The
* upside of this is that there is minimal padding necessary, though
* there should be a way to make alignment take place at the decimal
* dot (then with fixed width decimal part).
* dot (then with fixed width decimal part).
*
* Note the repdigits below: when given a precision value, printf()
* rounds the float to it, not just cuts off the remaining digits. So
@ -2638,11 +2638,11 @@ static void set_default_configurations(void)
text_alignment = BOTTOM_LEFT;
info.x11.monitor.number = 1;
info.x11.monitor.current = 0;
info.x11.desktop.current = 1;
info.x11.desktop.current = 1;
info.x11.desktop.number = 1;
info.x11.desktop.nitems = 0;
info.x11.desktop.all_names = NULL;
info.x11.desktop.name = NULL;
info.x11.desktop.all_names = NULL;
info.x11.desktop.name = NULL;
#endif /* X11 */
free_templates();
@ -4280,7 +4280,7 @@ static void signal_handler(int sig)
{
/* signal handler is light as a feather, as it should be.
* we will poll g_signal_pending with each loop of conky
* and do any signal processing there, NOT here (except
* and do any signal processing there, NOT here (except
* SIGALRM because this is caused when conky is hanging) */
if(sig == SIGALRM) {
alarm_handler();

View File

@ -73,7 +73,7 @@ namespace {
/* comparison function for tcp connections */
bool operator==(const tcp_connection_t &a, const tcp_connection_t &b)
{
{
return a.local_port == b.local_port && a.remote_port == b.remote_port &&
! std::memcmp(&a.local_addr, &b.local_addr, sizeof(a.local_addr)) &&
! std::memcmp(&a.remote_addr.s6_addr, &b.remote_addr, sizeof(a.remote_addr));

View File

@ -1640,125 +1640,124 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
memset(last_battery_str[idx], 0, sizeof(last_battery_str[idx]));
memset(last_battery_time_str[idx], 0, sizeof(last_battery_time_str[idx]));
/* first try SYSFS if that fails try ACPI */
/* first try SYSFS if that fails try ACPI */
if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
}
if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
acpi_bat_fp[idx] = open_file(acpi_path, &rep1);
if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
acpi_bat_fp[idx] = open_file(acpi_path, &rep1);
}
if (sysfs_bat_fp[idx] != NULL) {
/* SYSFS */
int present_rate = -1;
int remaining_capacity = -1;
char charging_state[64];
char present[4];
if (sysfs_bat_fp[idx] != NULL) {
/* SYSFS */
int present_rate = -1;
int remaining_capacity = -1;
char charging_state[64];
char present[4];
strcpy(charging_state, "unknown");
strcpy(charging_state, "unknown");
while (!feof(sysfs_bat_fp[idx])) {
char buf[256];
if (fgets(buf, 256, sysfs_bat_fp[idx]) == NULL)
break;
while (!feof(sysfs_bat_fp[idx])) {
char buf[256];
if (fgets(buf, 256, sysfs_bat_fp[idx]) == NULL)
break;
/* let's just hope units are ok */
if (strncmp (buf, "POWER_SUPPLY_PRESENT=1", 22) == 0)
strcpy(present, "yes");
else if (strncmp (buf, "POWER_SUPPLY_PRESENT=0", 22) == 0)
strcpy(present, "no");
else if (strncmp (buf, "POWER_SUPPLY_STATUS=", 20) == 0)
sscanf(buf, "POWER_SUPPLY_STATUS=%63s", charging_state);
/* present_rate is not the same as the
current flowing now but it is the same value
which was used in the past. so we continue
the tradition! */
else if (strncmp(buf, "POWER_SUPPLY_CURRENT_NOW=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CURRENT_NOW=%d", &present_rate);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_ENERGY_FULL=%d", &acpi_last_full[idx]);
else if (strncmp(buf, "POWER_SUPPLY_CHARGE_NOW=", 24) == 0)
sscanf(buf, "POWER_SUPPLY_CHARGE_NOW=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_CHARGE_FULL=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CHARGE_FULL=%d", &acpi_last_full[idx]);
}
/* let's just hope units are ok */
if (strncmp (buf, "POWER_SUPPLY_PRESENT=1", 22) == 0)
strcpy(present, "yes");
else if (strncmp (buf, "POWER_SUPPLY_PRESENT=0", 22) == 0)
strcpy(present, "no");
else if (strncmp (buf, "POWER_SUPPLY_STATUS=", 20) == 0)
sscanf(buf, "POWER_SUPPLY_STATUS=%63s", charging_state);
/* present_rate is not the same as the current flowing now but it
* is the same value which was used in the past. so we continue the
* tradition! */
else if (strncmp(buf, "POWER_SUPPLY_CURRENT_NOW=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CURRENT_NOW=%d", &present_rate);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_ENERGY_FULL=%d", &acpi_last_full[idx]);
else if (strncmp(buf, "POWER_SUPPLY_CHARGE_NOW=", 24) == 0)
sscanf(buf, "POWER_SUPPLY_CHARGE_NOW=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_CHARGE_FULL=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CHARGE_FULL=%d", &acpi_last_full[idx]);
}
fclose(sysfs_bat_fp[idx]);
sysfs_bat_fp[idx] = NULL;
fclose(sysfs_bat_fp[idx]);
sysfs_bat_fp[idx] = NULL;
/* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
if (remaining_capacity > acpi_last_full[idx])
acpi_last_full[idx] = remaining_capacity; /* normalize to 100% */
/* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
if (remaining_capacity > acpi_last_full[idx])
acpi_last_full[idx] = remaining_capacity; /* normalize to 100% */
/* not present */
if (strcmp(present, "No") == 0) {
strncpy(last_battery_str[idx], "not present", 64);
}
/* charging */
else if (strcmp(charging_state, "Charging") == 0) {
if (acpi_last_full[idx] != 0 && present_rate > 0) {
/* e.g. charging 75% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %i%%",
(int) (((float) remaining_capacity / acpi_last_full[idx]) * 100 ));
/* e.g. 2h 37m */
format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
(long) (((float)(acpi_last_full[idx] - remaining_capacity) / present_rate) * 3600));
} else if (acpi_last_full[idx] != 0 && present_rate <= 0) {
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
/* not present */
if (strcmp(present, "No") == 0) {
strncpy(last_battery_str[idx], "not present", 64);
}
/* charging */
else if (strcmp(charging_state, "Charging") == 0) {
if (acpi_last_full[idx] != 0 && present_rate > 0) {
/* e.g. charging 75% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %i%%",
(int) (((float) remaining_capacity / acpi_last_full[idx]) * 100 ));
/* e.g. 2h 37m */
format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
(long) (((float)(acpi_last_full[idx] - remaining_capacity) / present_rate) * 3600));
} else if (acpi_last_full[idx] != 0 && present_rate <= 0) {
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
} else {
strncpy(last_battery_str[idx], "charging", sizeof(last_battery_str[idx])-1);
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
}
}
/* discharging */
else if (strncmp(charging_state, "Discharging", 64) == 0) {
if (present_rate > 0) {
/* e.g. discharging 35% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "discharging %i%%",
(int) (((float) remaining_capacity / acpi_last_full[idx]) * 100 ));
/* e.g. 1h 12m */
format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
(long) (((float) remaining_capacity / present_rate) * 3600));
} else if (present_rate == 0) { /* Thanks to Nexox for this one */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "full");
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
} else {
strncpy(last_battery_str[idx], "charging", sizeof(last_battery_str[idx])-1);
} else {
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1,
"discharging %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
}
}
/* discharging */
else if (strncmp(charging_state, "Discharging", 64) == 0) {
if (present_rate > 0) {
/* e.g. discharging 35% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "discharging %i%%",
(int) (((float) remaining_capacity / acpi_last_full[idx]) * 100 ));
/* e.g. 1h 12m */
format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
(long) (((float) remaining_capacity / present_rate) * 3600));
} else if (present_rate == 0) { /* Thanks to Nexox for this one */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "full");
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
} else {
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1,
"discharging %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
snprintf(last_battery_time_str[idx],
sizeof(last_battery_time_str[idx]) - 1, "unknown");
}
}
/* charged */
/* thanks to Lukas Zapletal <lzap@seznam.cz> */
}
}
/* charged */
/* thanks to Lukas Zapletal <lzap@seznam.cz> */
else if (strncmp(charging_state, "Charged", 64) == 0 || strncmp(charging_state, "Full", 64) == 0) {
/* Below happens with the second battery on my X40,
* when the second one is empty and the first one
* being charged. */
if (remaining_capacity == 0)
strcpy(last_battery_str[idx], "empty");
else
strcpy(last_battery_str[idx], "charged");
}
/* unknown, probably full / AC */
else {
if (acpi_last_full[idx] != 0
&& remaining_capacity != acpi_last_full[idx])
snprintf(last_battery_str[idx], 64, "unknown %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
else
strncpy(last_battery_str[idx], "AC", 64);
}
/* Below happens with the second battery on my X40,
* when the second one is empty and the first one
* being charged. */
if (remaining_capacity == 0)
strcpy(last_battery_str[idx], "empty");
else
strcpy(last_battery_str[idx], "charged");
}
/* unknown, probably full / AC */
else {
if (acpi_last_full[idx] != 0
&& remaining_capacity != acpi_last_full[idx])
snprintf(last_battery_str[idx], 64, "unknown %d%%",
(int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
else
strncpy(last_battery_str[idx], "AC", 64);
}
} else if (acpi_bat_fp[idx] != NULL) {
/* ACPI */
int present_rate = -1;

View File

@ -88,7 +88,7 @@ static void xmms_alloc(struct information *ptr)
void free_xmms2(struct text_object *obj)
{
(void)obj;
xfree(info.xmms2.artist);
xfree(info.xmms2.album);
xfree(info.xmms2.title);
@ -152,10 +152,10 @@ int handle_curent_id(xmmsv_t *value, void *p)
if (xmmsv_dict_get(infos, "artist", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
strncpy(ptr->xmms2.artist, charval, text_buffer_size - 1);
if (xmmsv_dict_get(infos, "title", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
if (xmmsv_dict_get(infos, "title", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
strncpy(ptr->xmms2.title, charval, text_buffer_size - 1);
if (xmmsv_dict_get(infos, "album", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
if (xmmsv_dict_get(infos, "album", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
strncpy(ptr->xmms2.album, charval, text_buffer_size - 1);
if (xmmsv_dict_get(infos, "genre", &dict_entry) && xmmsv_get_string(dict_entry, &charval))
@ -247,7 +247,7 @@ int handle_playback_state_change(xmmsv_t *value, void *p)
return TRUE;
}
int handle_playlist_loaded(xmmsv_t *value, void *p)
int handle_playlist_loaded(xmmsv_t *value, void *p)
{
struct information *ptr = p;
const char *c, *errbuf;
@ -305,21 +305,21 @@ void update_xmms2(void)
/* set callbacks */
xmmsc_disconnect_callback_set(xmms2_conn, connection_lost, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playback_current_id,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playback_current_id,
handle_curent_id, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_signal_playback_playtime,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_signal_playback_playtime,
handle_playtime, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playback_status,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playback_status,
handle_playback_state_change, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playlist_loaded,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_broadcast_playlist_loaded,
handle_playlist_loaded, current_info);
/* get playback status, current id and active playlist */
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playback_current_id,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playback_current_id,
handle_curent_id, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playback_status,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playback_status,
handle_playback_state_change, current_info);
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playlist_current_active,
XMMS_CALLBACK_SET(xmms2_conn, xmmsc_playlist_current_active,
handle_playlist_loaded, current_info);
/* everything seems to be ok */