From 5957aa3ed480b4b5e14890802b6b93336690abce Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Wed, 11 May 2022 13:26:31 +0200 Subject: [PATCH] Update statusbar --- .bin/{get-anki-reviews => sb-anki} | 0 .bin/{check-battery-level => sb-battery} | 0 .bin/sb-date | 3 +++ .bin/sb-internet | 7 +++++++ .bin/sb-pomo | 3 +++ .bin/sb-portfolio | 3 +++ .bin/sb-tasks | 14 ++++++++++++++ .suckless/dwmblocks/blocks.h | 24 +++++++++++++++--------- .suckless/dwmblocks/dwmblocks.c | 18 +++++++++++++----- 9 files changed, 58 insertions(+), 14 deletions(-) rename .bin/{get-anki-reviews => sb-anki} (100%) rename .bin/{check-battery-level => sb-battery} (100%) create mode 100755 .bin/sb-date create mode 100755 .bin/sb-internet create mode 100755 .bin/sb-pomo create mode 100755 .bin/sb-portfolio create mode 100755 .bin/sb-tasks diff --git a/.bin/get-anki-reviews b/.bin/sb-anki similarity index 100% rename from .bin/get-anki-reviews rename to .bin/sb-anki diff --git a/.bin/check-battery-level b/.bin/sb-battery similarity index 100% rename from .bin/check-battery-level rename to .bin/sb-battery diff --git a/.bin/sb-date b/.bin/sb-date new file mode 100755 index 0000000..d01bfcc --- /dev/null +++ b/.bin/sb-date @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo -n -e "Week $(date '+%V') - $(date '+%a %d %b %H:%M')" diff --git a/.bin/sb-internet b/.bin/sb-internet new file mode 100755 index 0000000..c375e38 --- /dev/null +++ b/.bin/sb-internet @@ -0,0 +1,7 @@ +#!/bin/sh + +if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then + wifiicon="$(awk '/^\s*w/ { print "WiFi", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +fi + +printf " %s%s%s |" "$wifiicon" "$(sed "s/down//;s/up/Ethernet/" /sys/class/net/e*/operstate 2>/dev/null)" diff --git a/.bin/sb-pomo b/.bin/sb-pomo new file mode 100755 index 0000000..2f65e0e --- /dev/null +++ b/.bin/sb-pomo @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cat /tmp/pomo diff --git a/.bin/sb-portfolio b/.bin/sb-portfolio new file mode 100755 index 0000000..1ffa7e2 --- /dev/null +++ b/.bin/sb-portfolio @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +"$HOME/dev/automation/portfolio-tracker/index.js" diff --git a/.bin/sb-tasks b/.bin/sb-tasks new file mode 100755 index 0000000..0ec0689 --- /dev/null +++ b/.bin/sb-tasks @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +num_done="$(task end.after:today status:completed count)" +num_pending="$(($(task count status:pending) + $num_done))" + +if [ "$num_done" -ge "$num_pending" ];then + color="\x01" +elif [ "$num_done" -ge "$((num_pending/2))" ]; then + color="\x03" +else + color="\x04" +fi + +echo -n -e "$color Tasks: $num_done/$num_pending \x01" diff --git a/.suckless/dwmblocks/blocks.h b/.suckless/dwmblocks/blocks.h index d142f2b..90bb7ba 100644 --- a/.suckless/dwmblocks/blocks.h +++ b/.suckless/dwmblocks/blocks.h @@ -1,14 +1,20 @@ //Modify this file to change what commands output to your statusbar, and recompile using the make command. static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ -/* {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, */ - {"", "cat /tmp/pomo", 1, 0}, - {"Week ", "date '+%V'", 60, 0}, - {"", "check-battery-level", 60, 0}, - {"", "date '+%a %d %b %I:%M%p'", 5, 0}, - {"", "task status:pending count", 20, 0} + /* + * Icon + * Command + * Update interval + * Update signal + */ + {"", "sb-date", 60, 0}, // Week, time, day + {"", "sb-pomo", 1, 0}, // Pomodoro timer + {"", "sb-tasks", 5, 0}, // Tasks done + {"", "sb-anki", 5, 0}, // Reviews done + {"", "sb-internet", 5, 0}, // Ethernet & WiFi status + {"", "sb-battery", 60, 0}, // Battery level + {"", "sb-portfolio", 600, 0} // Stocks }; //sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " | "; -static unsigned int delimLen = 5; +static char delim[] = " "; +static unsigned int delimLen = 0; diff --git a/.suckless/dwmblocks/dwmblocks.c b/.suckless/dwmblocks/dwmblocks.c index 9e6f30d..07c8064 100644 --- a/.suckless/dwmblocks/dwmblocks.c +++ b/.suckless/dwmblocks/dwmblocks.c @@ -70,11 +70,19 @@ void getcmd(const Block *block, char *output) pclose(cmdf); return; } - if (delim[0] != '\0') { - //only chop off newline if one is present at the end - i = output[i-1] == '\n' ? i-1 : i; - strncpy(output+i, delim, delimLen); - } + + /* + * Temporary workaround, I guess newlines caused replacement characters to be + * displayed. Removing this check and newlines from statusbar scripts does + * the trick for now. Might patch later. + */ + + /* if (delim[0] != '\0') { + * //only chop off newline if one is present at the end + * i = output[i-1] == '\n' ? i-1 : i; + * strncpy(output+i, delim, delimLen); + * } */ + else output[i++] = '\0'; pclose(cmdf);