Merge branch 'master' into master

This commit is contained in:
mrchainman 2020-03-02 16:20:26 +01:00 committed by GitHub
commit 7cb3daa077
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 18 deletions

View file

@ -1,6 +1,6 @@
output: dwmblocks.o output: dwmblocks.o
gcc dwmblocks.o -lX11 -o dwmblocks gcc dwmblocks.o -lX11 -o dwmblocks
dwmblocks.o: dwmblocks.c blocks.h dwmblocks.o: dwmblocks.c config.h
gcc -c -lX11 dwmblocks.c gcc -c -lX11 dwmblocks.c
clean: clean:
rm *.o *.gch dwmblocks rm *.o *.gch dwmblocks

View file

@ -3,6 +3,10 @@ Modular status bar for dwm written in c.
# modifying blocks # modifying blocks
The statusbar is made from text output from commandline programs. The statusbar is made from text output from commandline programs.
Blocks are added and removed by editing the blocks.h header file. Blocks are added and removed by editing the blocks.h header file.
# Luke's bulid
I have dwmblocks read my preexisting scripts [here in my dotfiles repo](https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin/statusbar).
So if you want my build out of the box, download those and put them in your `$PATH`.
I do this to avoid redundancy in LARBS, both i3 and dwm use the same statusbar scripts.
# signalling changes # signalling changes
For example, the audio module has the update signal 10 by default. For example, the audio module has the update signal 10 by default.
Thus, running `pkill -RTMIN+10 dwmblocks` will update it. Thus, running `pkill -RTMIN+10 dwmblocks` will update it.

View file

@ -1,12 +0,0 @@
//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*/
{"", "cat /tmp/recordingicon", 0, 9},
{"📬 ", "find ~/.local/share/mail/*/INBOX/new -type f | wc -l", 0, 13},
{"🔊 ", "amixer get Master | grep -o \"\\(\\[off\\]\\|[0-9]*%\\)\"", 0, 10},
{"🔋 ", "sed \"s/$/%/\" /sys/class/power_supply/BAT?/capacity", 5, 12},
{"🕗 ", "date '+%Y %b %d (%a) %I:%M%p'", 60, 0},
};
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim = ' ';

19
config.h Normal file
View file

@ -0,0 +1,19 @@
//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*/
/* {"", "cat /tmp/recordingicon", 0, 9}, */
/* {"", "music", 0, 11}, */
{"", "pacpackages", 0, 8},
{"", "crypto", 0, 13},
{"", "torrent", 20, 7},
{"", "news", 0, 6},
/* {"", "moonphase", 18000, 5}, */
{"", "weather", 18000, 5},
{"", "mailbox", 180, 12},
{"", "volume", 0, 10},
{"", "battery", 5, 0},
{"", "clock", 60, 0},
};
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim = '|';

View file

@ -25,7 +25,7 @@ void sighandler(int signum);
void termhandler(int signum); void termhandler(int signum);
#include "blocks.h" #include "config.h"
static Display *dpy; static Display *dpy;
static int screen; static int screen;
@ -69,7 +69,7 @@ void getcmds(int time)
{ {
const Block* current; const Block* current;
for(int i = 0; i < LENGTH(blocks); i++) for(int i = 0; i < LENGTH(blocks); i++)
{ {
current = blocks + i; current = blocks + i;
if ((current->interval != 0 && time % current->interval == 0) || time == -1) if ((current->interval != 0 && time % current->interval == 0) || time == -1)
getcmd(current,statusbar[i]); getcmd(current,statusbar[i]);
@ -90,7 +90,7 @@ void getsigcmds(int signal)
void setupsignals() void setupsignals()
{ {
for(int i = 0; i < LENGTH(blocks); i++) for(int i = 0; i < LENGTH(blocks); i++)
{ {
if (blocks[i].signal > 0) if (blocks[i].signal > 0)
signal(SIGRTMIN+blocks[i].signal, sighandler); signal(SIGRTMIN+blocks[i].signal, sighandler);
} }
@ -101,7 +101,7 @@ void getstatus(char *str)
{ {
int j = 0; int j = 0;
for(int i = 0; i < LENGTH(blocks); j+=strlen(statusbar[i++])) for(int i = 0; i < LENGTH(blocks); j+=strlen(statusbar[i++]))
{ {
strcpy(str + j, statusbar[i]); strcpy(str + j, statusbar[i]);
} }
str[--j] = '\0'; str[--j] = '\0';
@ -157,7 +157,7 @@ void termhandler(int signum)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
for(int i = 0; i < argc; i++) for(int i = 0; i < argc; i++)
{ {
if (!strcmp("-d",argv[i])) if (!strcmp("-d",argv[i]))
delim = argv[++i][0]; delim = argv[++i][0];
} }