Compare commits
No commits in common. "d58dfbb32237d688955ab7cddfe83ed391e48dc2" and "23e1d5732a8c9eb0d811a49cea151c066627edcb" have entirely different histories.
d58dfbb322
...
23e1d5732a
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[] = {
|
||||||
/* script, refresh, signal */
|
BLOCK("sb-mail", 1800, 17),
|
||||||
|
BLOCK("sb-music", 0, 18),
|
||||||
BLOCK("~/scripts/blocks/net-rate.sh", 5, 23),
|
BLOCK("sb-disk", 1800, 19),
|
||||||
BLOCK("~/scripts/blocks/ram-free.sh", 5, 22),
|
BLOCK("sb-memory", 10, 20),
|
||||||
BLOCK("~/scripts/blocks/cpu-use.sh", 5, 21),
|
BLOCK("sb-loadavg", 5, 21),
|
||||||
BLOCK("~/scripts/blocks/cpu-temp.sh", 5, 20),
|
BLOCK("sb-mic", 0, 26),
|
||||||
|
BLOCK("sb-record", 0, 27),
|
||||||
// TODO: Update volume in a hook rather than querying it every 2 seconds
|
BLOCK("sb-volume", 0, 22),
|
||||||
BLOCK("~/scripts/blocks/volume.sh", 2, 19),
|
BLOCK("sb-battery", 5, 23),
|
||||||
|
BLOCK("sb-date", 1, 24)
|
||||||
BLOCK("~/scripts/blocks/datetime.sh", 15, 18),
|
|
||||||
};
|
};
|
||||||
|
18
main.c
18
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 = 1;
|
static int timer = 0, timerTick = 0, maxInterval = 0;
|
||||||
static int signalFD;
|
static int signalFD;
|
||||||
static int epollFD;
|
static int epollFD;
|
||||||
static int execLock = 0;
|
static int execLock = 0;
|
||||||
@ -115,15 +115,10 @@ 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
|
||||||
|
if ((buffer[j++] & 0xc0) != 0x80)
|
||||||
count++;
|
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
|
||||||
@ -131,8 +126,7 @@ void updateBlock(int i) {
|
|||||||
buffer[j] = ' ';
|
buffer[j] = ' ';
|
||||||
|
|
||||||
// Trim trailing spaces
|
// Trim trailing spaces
|
||||||
while (j >= 0 && buffer[j] == ' ')
|
while (j >= 0 && buffer[j] == ' ') j--;
|
||||||
j--;
|
|
||||||
buffer[j + 1] = 0;
|
buffer[j + 1] = 0;
|
||||||
|
|
||||||
// Clear the pipe
|
// Clear the pipe
|
||||||
@ -245,7 +239,7 @@ void setupSignals() {
|
|||||||
|
|
||||||
void statusLoop() {
|
void statusLoop() {
|
||||||
// Update all blocks initially
|
// Update all blocks initially
|
||||||
raise(SIGALRM);
|
kill(0, 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