Update statusbar

master
Hektor Misplon 2022-05-11 13:26:31 +02:00
parent a6876bb54e
commit 5957aa3ed4
9 changed files with 58 additions and 14 deletions

3
.bin/sb-date Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo -n -e "Week $(date '+%V') - $(date '+%a %d %b %H:%M')"

7
.bin/sb-internet Executable file
View File

@ -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)"

3
.bin/sb-pomo Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
cat /tmp/pomo

3
.bin/sb-portfolio Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
"$HOME/dev/automation/portfolio-tracker/index.js"

14
.bin/sb-tasks Executable file
View File

@ -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"

View File

@ -1,14 +1,20 @@
//Modify this file to change what commands output to your statusbar, and recompile using the make command. //Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = { static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /*
/* {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, */ * Icon
{"", "cat /tmp/pomo", 1, 0}, * Command
{"Week ", "date '+%V'", 60, 0}, * Update interval
{"", "check-battery-level", 60, 0}, * Update signal
{"", "date '+%a %d %b %I:%M%p'", 5, 0}, */
{"", "task status:pending count", 20, 0} {"", "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. //sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | "; static char delim[] = " ";
static unsigned int delimLen = 5; static unsigned int delimLen = 0;

View File

@ -70,11 +70,19 @@ void getcmd(const Block *block, char *output)
pclose(cmdf); pclose(cmdf);
return; return;
} }
if (delim[0] != '\0') {
//only chop off newline if one is present at the end /*
i = output[i-1] == '\n' ? i-1 : i; * Temporary workaround, I guess newlines caused replacement characters to be
strncpy(output+i, delim, delimLen); * 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 else
output[i++] = '\0'; output[i++] = '\0';
pclose(cmdf); pclose(cmdf);