[i3] i3status patch to colorize ethernet output

  • From: Peter Johnson <tam@xxxxxxxxxxxxxx>
  • To: i3-discuss@xxxxxxxxxxxxx
  • Date: Sat, 13 Feb 2010 16:30:23 -0500

Hi --

Here's a patch to colorize the ethernet output for i3status. (Why are the
castings of printf() to void inconsistent? Which way is preferred?)

pete

diff -ruN i3status-2.0.orig/src/print_eth_info.c
i3status-2.0/src/print_eth_info.c
--- i3status-2.0.orig/src/print_eth_info.c 2009-10-27 15:33:42.000000000
-0400
+++ i3status-2.0/src/print_eth_info.c 2010-02-13 16:28:05.689011287 -0500
@@ -79,8 +79,12 @@
const char *ip_address = get_ip_addr(interface);

if (ip_address == NULL) {
+ printf("%s", color("#FF0000"));
printf("%s", format_down);
+ (void)printf("%s", endcolor());
return;
+ } else {
+ printf("%s", color("#00FF00"));
}

for (walk = format_up; *walk != '\0'; walk++) {
@@ -97,4 +101,6 @@
walk += strlen("speed");
}
}
+
+ (void)printf("%s", endcolor());
}

Other related posts:

  • » [i3] i3status patch to colorize ethernet output - Peter Johnson