Compare commits
5 Commits
23e1d5732a
...
d58dfbb322
Author | SHA1 | Date | |
---|---|---|---|
|
d58dfbb322 | ||
|
7f799a9b49 | ||
|
65bfd0eef5 | ||
|
6cdd6f7ff2 | ||
|
09e72e590d |
22
config.h
22
config.h
@ -1,16 +1,16 @@
|
|||||||
#define CMDLENGTH 45
|
#define CMDLENGTH 45
|
||||||
#define DELIMITER " "
|
#define DELIMITER " "
|
||||||
#define CLICKABLE_BLOCKS
|
|
||||||
|
|
||||||
const Block blocks[] = {
|
const Block blocks[] = {
|
||||||
BLOCK("sb-mail", 1800, 17),
|
/* script, refresh, signal */
|
||||||
BLOCK("sb-music", 0, 18),
|
|
||||||
BLOCK("sb-disk", 1800, 19),
|
BLOCK("~/scripts/blocks/net-rate.sh", 5, 23),
|
||||||
BLOCK("sb-memory", 10, 20),
|
BLOCK("~/scripts/blocks/ram-free.sh", 5, 22),
|
||||||
BLOCK("sb-loadavg", 5, 21),
|
BLOCK("~/scripts/blocks/cpu-use.sh", 5, 21),
|
||||||
BLOCK("sb-mic", 0, 26),
|
BLOCK("~/scripts/blocks/cpu-temp.sh", 5, 20),
|
||||||
BLOCK("sb-record", 0, 27),
|
|
||||||
BLOCK("sb-volume", 0, 22),
|
// TODO: Update volume in a hook rather than querying it every 2 seconds
|
||||||
BLOCK("sb-battery", 5, 23),
|
BLOCK("~/scripts/blocks/volume.sh", 2, 19),
|
||||||
BLOCK("sb-date", 1, 24)
|
|
||||||
|
BLOCK("~/scripts/blocks/datetime.sh", 15, 18),
|
||||||
};
|
};
|
||||||
|
20
main.c
20
main.c
@ -41,7 +41,7 @@ static Window root;
|
|||||||
static unsigned short statusContinue = 1;
|
static unsigned short statusContinue = 1;
|
||||||
static struct epoll_event event;
|
static struct epoll_event event;
|
||||||
static int pipes[LEN(blocks)][2];
|
static int pipes[LEN(blocks)][2];
|
||||||
static int timer = 0, timerTick = 0, maxInterval = 0;
|
static int timer = 0, timerTick = 0, maxInterval = 1;
|
||||||
static int signalFD;
|
static int signalFD;
|
||||||
static int epollFD;
|
static int epollFD;
|
||||||
static int execLock = 0;
|
static int execLock = 0;
|
||||||
@ -115,10 +115,15 @@ void updateBlock(int i) {
|
|||||||
|
|
||||||
// Trim UTF-8 string to desired length
|
// Trim UTF-8 string to desired length
|
||||||
int count = 0, j = 0;
|
int count = 0, j = 0;
|
||||||
while (buffer[j] != '\n' && count <= CMDLENGTH) {
|
while (buffer[j] != '\n' && count < CMDLENGTH) {
|
||||||
// Increment count for non-continuation bytes
|
count++;
|
||||||
if ((buffer[j++] & 0xc0) != 0x80)
|
|
||||||
count++;
|
// Skip continuation bytes, if any.
|
||||||
|
char ch = buffer[j];
|
||||||
|
int skip = 1;
|
||||||
|
while ((ch & 0xc0) > 0x80)
|
||||||
|
ch <<= 1, skip++;
|
||||||
|
j += skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache last character and replace it with a trailing space
|
// Cache last character and replace it with a trailing space
|
||||||
@ -126,7 +131,8 @@ void updateBlock(int i) {
|
|||||||
buffer[j] = ' ';
|
buffer[j] = ' ';
|
||||||
|
|
||||||
// Trim trailing spaces
|
// Trim trailing spaces
|
||||||
while (j >= 0 && buffer[j] == ' ') j--;
|
while (j >= 0 && buffer[j] == ' ')
|
||||||
|
j--;
|
||||||
buffer[j + 1] = 0;
|
buffer[j + 1] = 0;
|
||||||
|
|
||||||
// Clear the pipe
|
// Clear the pipe
|
||||||
@ -239,7 +245,7 @@ void setupSignals() {
|
|||||||
|
|
||||||
void statusLoop() {
|
void statusLoop() {
|
||||||
// Update all blocks initially
|
// Update all blocks initially
|
||||||
kill(0, SIGALRM);
|
raise(SIGALRM);
|
||||||
|
|
||||||
struct epoll_event events[LEN(blocks) + 1];
|
struct epoll_event events[LEN(blocks) + 1];
|
||||||
while (statusContinue) {
|
while (statusContinue) {
|
||||||
|
Loading…
Reference in New Issue
Block a user