custom changes

This commit is contained in:
Tobias Berger 2024-01-24 23:02:21 +01:00
parent 540a90e521
commit 92ecfd9b81
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
5 changed files with 35 additions and 26 deletions

3
.gitignore vendored
View file

@ -54,3 +54,6 @@ modules.order
Module.symvers Module.symvers
Mkfile.old Mkfile.old
dkms.conf dkms.conf
# Patch file for NixOS
custom_someblocks.patch

View file

@ -2,14 +2,19 @@ PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man MANPREFIX ?= $(PREFIX)/share/man
CC ?= cc CC ?= cc
DEVCFLAGS = -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wshadow -Wunused-macros\
-Werror=strict-prototypes -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Wfloat-conversion\
-Ofast -flto
output: someblocks.c blocks.def.h blocks.h output: someblocks.c blocks.def.h blocks.h
${CC} someblocks.c $(LDFLAGS) -o someblocks ${CC} someblocks.c $(LDFLAGS) $(DEVCFLAGS) -o someblocks
strip someblocks
blocks.h: blocks.h:
cp blocks.def.h $@ cp blocks.def.h $@
clean: clean:
rm -f *.o *.gch someblocks rm -f *.o *.gch someblocks blocks.h
install: output install: output
mkdir -p $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
install -m 0755 someblocks $(DESTDIR)$(PREFIX)/bin/someblocks install -m 0755 someblocks $(DESTDIR)$(PREFIX)/bin/someblocks

View file

@ -1,16 +1,12 @@
//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*/ /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, {"󱄠 ", "pamixer --get-volume-human", 1, 0},
{"󰍛 ", "free -h | awk '/^Mem/ { print $3\"/\"$2 }'", 1, 0},
{"", "date '+%b %d (%a) %I:%M%p'", 5, 0}, {"󰥔 ", "date -Is", 1, 0},
/* Updates whenever "pkill -SIGRTMIN+10 someblocks" is ran */
/* Updates whenever "pkill -SIGRTMIN+10 someblocks" is ran */ /* {"", "date '+%b %d (%a) %I:%M%p'", 0, 10}, */
/* {"", "date '+%b %d (%a) %I:%M%p'", 0, 10}, */
}; };
//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 = 5;

1
generate_patch.sh Executable file
View file

@ -0,0 +1 @@
git diff 540a90e521e7c17c2010e038b934b73d2cf46df3 > custom_someblocks.patch

View file

@ -30,33 +30,36 @@ void dummysighandler(int num);
void sighandler(int num); void sighandler(int num);
void getcmds(int time); void getcmds(int time);
void getsigcmds(unsigned int signal); void getsigcmds(unsigned int signal);
void setupsignals(); void setupsignals(void);
void sighandler(int signum); void sighandler(int signum);
int getstatus(char *str, char *last); int getstatus(char *str, char *last);
void statusloop(); void statusloop(void);
void termhandler(); void termhandler(int sig);
void pstdout(); void pstdout(void);
void psomebar(); void psomebar(void);
static void (*writestatus) () = psomebar; static void (*writestatus) (void) = psomebar;
#include "blocks.h" #include "blocks.h"
static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
static char statusstr[2][STATUSLENGTH]; static char statusstr[2][STATUSLENGTH];
static int statusContinue = 1; static int statusContinue = 1;
static int returnStatus = 0;
static char somebarPath[128]; static char somebarPath[128];
static int somebarFd = -1; static int somebarFd = -1;
//opens process *cmd and stores output in *output //opens process *cmd and stores output in *output
void getcmd(const Block *block, char *output) void getcmd(const Block *block, char *output)
{ {
FILE *cmdf;
int i;
strcpy(output, block->icon); strcpy(output, block->icon);
FILE *cmdf = popen(block->command, "r"); cmdf = popen(block->command, "r");
if (!cmdf) if (!cmdf)
return; return;
int i = strlen(block->icon); i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i-delimLen, cmdf); if (fgets(output+i, CMDLENGTH-i-delimLen, cmdf) != (output+i)) {
exit(1);
}
i = strlen(output); i = strlen(output);
if (i == 0) { if (i == 0) {
//return if block and command output are both empty //return if block and command output are both empty
@ -152,15 +155,16 @@ void psomebar()
void statusloop() void statusloop()
{ {
int i;
setupsignals(); setupsignals();
int i = 0; i = 0;
getcmds(-1); getcmds(-1);
while (1) { while (1) {
getcmds(i++); getcmds(i++);
writestatus(); writestatus();
if (!statusContinue) if (!statusContinue)
break; break;
sleep(1.0); sleep(1);
} }
} }
@ -178,12 +182,12 @@ void sighandler(int signum)
writestatus(); writestatus();
} }
void termhandler() void termhandler(int sig)
{ {
statusContinue = 0; statusContinue = 0;
} }
void sigpipehandler() void sigpipehandler(int sig)
{ {
close(somebarFd); close(somebarFd);
somebarFd = -1; somebarFd = -1;