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
Mkfile.old
dkms.conf
# Patch file for NixOS
custom_someblocks.patch

View file

@ -2,14 +2,19 @@ PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man
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
${CC} someblocks.c $(LDFLAGS) -o someblocks
${CC} someblocks.c $(LDFLAGS) $(DEVCFLAGS) -o someblocks
strip someblocks
blocks.h:
cp blocks.def.h $@
clean:
rm -f *.o *.gch someblocks
rm -f *.o *.gch someblocks blocks.h
install: output
mkdir -p $(DESTDIR)$(PREFIX)/bin
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[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0},
{"", "date '+%b %d (%a) %I:%M%p'", 5, 0},
/* Updates whenever "pkill -SIGRTMIN+10 someblocks" is ran */
/* {"", "date '+%b %d (%a) %I:%M%p'", 0, 10}, */
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"󱄠 ", "pamixer --get-volume-human", 1, 0},
{"󰍛 ", "free -h | awk '/^Mem/ { print $3\"/\"$2 }'", 1, 0},
{"󰥔 ", "date -Is", 1, 0},
/* Updates whenever "pkill -SIGRTMIN+10 someblocks" is ran */
/* {"", "date '+%b %d (%a) %I:%M%p'", 0, 10}, */
};
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
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 getcmds(int time);
void getsigcmds(unsigned int signal);
void setupsignals();
void setupsignals(void);
void sighandler(int signum);
int getstatus(char *str, char *last);
void statusloop();
void termhandler();
void pstdout();
void psomebar();
static void (*writestatus) () = psomebar;
void statusloop(void);
void termhandler(int sig);
void pstdout(void);
void psomebar(void);
static void (*writestatus) (void) = psomebar;
#include "blocks.h"
static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
static char statusstr[2][STATUSLENGTH];
static int statusContinue = 1;
static int returnStatus = 0;
static char somebarPath[128];
static int somebarFd = -1;
//opens process *cmd and stores output in *output
void getcmd(const Block *block, char *output)
{
FILE *cmdf;
int i;
strcpy(output, block->icon);
FILE *cmdf = popen(block->command, "r");
cmdf = popen(block->command, "r");
if (!cmdf)
return;
int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
i = strlen(block->icon);
if (fgets(output+i, CMDLENGTH-i-delimLen, cmdf) != (output+i)) {
exit(1);
}
i = strlen(output);
if (i == 0) {
//return if block and command output are both empty
@ -152,15 +155,16 @@ void psomebar()
void statusloop()
{
int i;
setupsignals();
int i = 0;
i = 0;
getcmds(-1);
while (1) {
getcmds(i++);
writestatus();
if (!statusContinue)
break;
sleep(1.0);
sleep(1);
}
}
@ -178,12 +182,12 @@ void sighandler(int signum)
writestatus();
}
void termhandler()
void termhandler(int sig)
{
statusContinue = 0;
}
void sigpipehandler()
void sigpipehandler(int sig)
{
close(somebarFd);
somebarFd = -1;