[pacman-dev] [PATCH 1/1] make pacman even more candy-aware

Christian Hesse list at eworm.de
Wed Dec 7 12:19:59 UTC 2016


From: Christian Hesse <mail at eworm.de>

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 src/pacman/callback.c | 15 +++++++++++++--
 src/pacman/conf.c     |  3 +++
 src/pacman/conf.h     |  2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 7f72b84..9cdd9a4 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -112,8 +112,19 @@ static void fill_progress(const int bar_percent, const int disp_percent,
 	if(hashlen > 0) {
 		fputs(" [", stdout);
 		for(i = hashlen; i > 0; --i) {
-			/* if special progress bar enabled */
-			if(config->chomp) {
+			/* progress bar with pacman in unicode: [  ᗧ••ᗣ••] */
+			if(config->chomp_unicode) {
+				if(i > hashlen - hash) {
+					putchar(' ');
+				} else if(i == hashlen - hash) {
+					fputs("\033[1;33mᗧ\033[m", stdout);
+				} else if(i % 3 == 0) {
+					printf("\033[1;%dmᗣ\033[m", i % 5 + 31);
+				} else {
+					fputs("\033[0;37m•\033[m", stdout);
+				}
+			} /* progress bar with pacman in ascii: [--C  o  ] */
+			else if(config->chomp) {
 				if(i > hashlen - hash) {
 					putchar('-');
 				} else if(i == hashlen - hash) {
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index d8d64fb..430bb81 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -479,6 +479,9 @@ static int _parse_options(const char *key, char *value,
 		if(strcmp(key, "UseSyslog") == 0) {
 			config->usesyslog = 1;
 			pm_printf(ALPM_LOG_DEBUG, "config: usesyslog\n");
+		} else if(strcmp(key, "ILoveSweetCandy") == 0) {
+			config->chomp_unicode = 1;
+			pm_printf(ALPM_LOG_DEBUG, "config: chomp_unicode\n");
 		} else if(strcmp(key, "ILoveCandy") == 0) {
 			config->chomp = 1;
 			pm_printf(ALPM_LOG_DEBUG, "config: chomp\n");
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 945de7c..577f236 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -109,6 +109,8 @@ typedef struct __config_t {
 	/* conf file options */
 	/* I Love Candy! */
 	unsigned short chomp;
+	/* I Love Sweet Candy! */
+	unsigned short chomp_unicode;
 	/* format target pkg lists as table */
 	unsigned short verbosepkglists;
 	/* When downloading, display the amount downloaded, rate, ETA, and percent
-- 
2.10.2


More information about the pacman-dev mailing list