Compare commits

..

No commits in common. "d58dfbb32237d688955ab7cddfe83ed391e48dc2" and "23e1d5732a8c9eb0d811a49cea151c066627edcb" have entirely different histories.

2 changed files with 18 additions and 24 deletions

View File

@ -1,16 +1,16 @@
#define CMDLENGTH 45
#define DELIMITER " "
#define CLICKABLE_BLOCKS
const Block blocks[] = {
/* script, refresh, signal */
BLOCK("~/scripts/blocks/net-rate.sh", 5, 23),
BLOCK("~/scripts/blocks/ram-free.sh", 5, 22),
BLOCK("~/scripts/blocks/cpu-use.sh", 5, 21),
BLOCK("~/scripts/blocks/cpu-temp.sh", 5, 20),
// TODO: Update volume in a hook rather than querying it every 2 seconds
BLOCK("~/scripts/blocks/volume.sh", 2, 19),
BLOCK("~/scripts/blocks/datetime.sh", 15, 18),
BLOCK("sb-mail", 1800, 17),
BLOCK("sb-music", 0, 18),
BLOCK("sb-disk", 1800, 19),
BLOCK("sb-memory", 10, 20),
BLOCK("sb-loadavg", 5, 21),
BLOCK("sb-mic", 0, 26),
BLOCK("sb-record", 0, 27),
BLOCK("sb-volume", 0, 22),
BLOCK("sb-battery", 5, 23),
BLOCK("sb-date", 1, 24)
};

20
main.c
View File

@ -41,7 +41,7 @@ static Window root;
static unsigned short statusContinue = 1;
static struct epoll_event event;
static int pipes[LEN(blocks)][2];
static int timer = 0, timerTick = 0, maxInterval = 1;
static int timer = 0, timerTick = 0, maxInterval = 0;
static int signalFD;
static int epollFD;
static int execLock = 0;
@ -115,15 +115,10 @@ void updateBlock(int i) {
// Trim UTF-8 string to desired length
int count = 0, j = 0;
while (buffer[j] != '\n' && count < CMDLENGTH) {
count++;
// Skip continuation bytes, if any.
char ch = buffer[j];
int skip = 1;
while ((ch & 0xc0) > 0x80)
ch <<= 1, skip++;
j += skip;
while (buffer[j] != '\n' && count <= CMDLENGTH) {
// Increment count for non-continuation bytes
if ((buffer[j++] & 0xc0) != 0x80)
count++;
}
// Cache last character and replace it with a trailing space
@ -131,8 +126,7 @@ void updateBlock(int i) {
buffer[j] = ' ';
// Trim trailing spaces
while (j >= 0 && buffer[j] == ' ')
j--;
while (j >= 0 && buffer[j] == ' ') j--;
buffer[j + 1] = 0;
// Clear the pipe
@ -245,7 +239,7 @@ void setupSignals() {
void statusLoop() {
// Update all blocks initially
raise(SIGALRM);
kill(0, SIGALRM);
struct epoll_event events[LEN(blocks) + 1];
while (statusContinue) {