Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ SED = sed
GREP = grep
CUT = cut

VERSION != $(GREP) VERSION main.h | $(CUT) -d \" -f2
PROGNAME != $(GREP) PROGNAME main.h | $(CUT) -d \" -f2
PROGUPPER != $(GREP) PROGUPPER main.h | $(CUT) -d \" -f2
MAIN_HEADER := include/main.h

VERSION != $(GREP) VERSION $(MAIN_HEADER) | $(CUT) -d \" -f2
PROGNAME != $(GREP) PROGNAME $(MAIN_HEADER) | $(CUT) -d \" -f2
PROGUPPER != $(GREP) PROGUPPER $(MAIN_HEADER) | $(CUT) -d \" -f2

PREFIX = /usr/local

Expand All @@ -25,6 +27,7 @@ MANPREFIX.=/usr/share/man
MANPREFIX=$(MANPREFIX.$(PREFIX))

INCLUDES != pkg-config --cflags libnotify
INCLUDES := $(INCLUDES) -I./include/
CFLAGS_EXTRA = -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Os
CFLAGS := $(CFLAGS_EXTRA) $(INCLUDES) $(CFLAGS)

Expand All @@ -33,9 +36,9 @@ LIBS := $(LIBS) -lm
LDFLAGS_EXTRA = -s
LDFLAGS := $(LDFLAGS_EXTRA) $(LDFLAGS)

SRC = main.c options.c battery.c notify.c
SRC = $(wildcard src/*.c)
OBJ = $(SRC:.c=.o)
HDR = $(SRC:.c=.h)
HDR = include/*.h

.PHONY: all install install-service clean test compile-test

Expand All @@ -46,7 +49,7 @@ $(TARGET): $(OBJ)

%.o: $(HDR)

$(TARGET).1: $(TARGET).1.in main.h
$(TARGET).1: $(TARGET).1.in $(MAIN_HEADER)
$(SED) "s/VERSION/$(VERSION)/g" < $(TARGET).1.in | $(SED) "s/PROGNAME/$(PROGNAME)/g" | $(SED) "s/PROGUPPER/$(PROGUPPER)/g" > $@

install: all
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Authors
batsignal is written by Corey Hinshaw. It was originally forked from juiced by
Aaron Marcher.

Development Notes
-----------------

For supporting language-server freatures, the `compile_commands.json` file is necessary (at least for the clangd-lsp).
This can be generated with [Bear](https://github.com/rizsotto/Bear):

$ bear -- make

License and Copyright
---------------------
Copyright (c) 2018-2024 Corey Hinshaw
Expand Down
198 changes: 0 additions & 198 deletions battery.c

This file was deleted.

13 changes: 12 additions & 1 deletion battery.h → include/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#ifndef BATTERY_H
#define BATTERY_H

#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <time.h>

/* battery states */
#define STATE_AC 0
Expand Down Expand Up @@ -34,10 +37,18 @@ typedef struct BatteryState {
int level;
int energy_full;
int energy_now;
int inotify_fd;
int *watch_fds;
pthread_cond_t *bat_state_change;
pthread_mutex_t *state_change_mut;
pthread_t *thread_ids;
atomic_bool *watching;
} BatteryState;

BatteryState* init_batteries(char **battery_names, int battery_count);
void uninit_batteries(BatteryState * battery);
int find_batteries(char ***battery_names);
int validate_batteries(char **battery_names, int battery_count);
void update_battery_state(BatteryState *battery, bool required);
void wait_for_update_battery_state(BatteryState *battery, bool required, struct timespec timeout);

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading