migrate tstatus to an object-based compiliation format

This commit is contained in:
randomuser 2022-11-13 16:03:55 +00:00
parent d421df5a0b
commit c588f3ae65
9 changed files with 27 additions and 16 deletions

View File

@ -1,8 +1,13 @@
tstatus:
cc tstatus.c -o tstatus -lxcb -lasound -Wall -Wextra -std=c99
CC = cc
CFLAGS = -Wall -Wextra -Wno-missing-field-initializers -std=c99
LDFLAGS = -lxcb -lasound
OBJFILES = alsa.o battery.o bspwm.o datetime.o file.o thermal.o tstatus.o
TARGET = tstatus
debug:
cc tstatus.c -o tstatus -lxcb -Wall -Wextra -std=c99 -ggdb
all: $(TARGET)
$(TARGET): $(OBJFILES)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJFILES) $(LDFLAGS)
clean:
rm tstatus
rm -f $(OBJFILES) $(TARGET) *~

View File

@ -3,7 +3,7 @@
#include <unistd.h>
#include "module.h"
#include "file.c"
#include "file.h"
#include "battery.h"
int battery_update(struct module *module) {

View File

@ -13,7 +13,7 @@
#define BATTERY_PRE "/sys/class/power_supply/"
#define BATTERY_CAP "/capacity"
int battery_module(struct module *module);
int battery_update(struct module *module);
#endif
#define TSTATUS_BATTERY_H

View File

@ -24,6 +24,8 @@
* modifications made by randomuser for use in tstatus
*/
#define LENGTH(x) (sizeof(x) / sizeof(*x))
#define RUNTIME_DIR_ENV "XDG_RUNTIME_DIR"
#define SOCKET_PATH_TPL "/tmp/bspwm%s_%i_%i-socket"
#define SOCKET_ENV_VAR "BSPWM_SOCKET"

View File

@ -2,6 +2,7 @@
#include <stdio.h>
#include <time.h>
#include "module.h"
#include "datetime.h"
int datetime_update(struct module *module) {

View File

@ -1,7 +1,7 @@
/* see LICENSE file for details on license */
#ifndef TSTATUS_TIMEDATE_H
int timedate_update(struct module *module);
int datetime_update(struct module *module);
#endif
#define TSTATUS_TIMEDATE_H

3
file.c
View File

@ -1,6 +1,9 @@
/* see LICENSE file for details on license */
#ifndef TSTATUS_FILE_C
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include "file.h"
void populate_buffer(char *buffer, char pattern) {

View File

@ -1,9 +1,10 @@
/* see LICENSE file for details on license */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "module.h"
#include "file.c"
#include "file.h"
#include "thermal.h"
int convert_milli_to_reg(int millidegree) {

View File

@ -1,14 +1,13 @@
/* see LICENSE file for details on license */
#define _POSIX_C_SOURCE 2
#include <stdio.h>
#define LENGTH(x) (sizeof(x) / sizeof(*x))
#include "module.h"
#include "bspwm.c"
#include "battery.c"
#include "thermal.c"
#include "datetime.c"
#include "alsa.c"
#include "bspwm.h"
#include "battery.h"
#include "thermal.h"
#include "datetime.h"
#include "alsa.h"
struct module table[] = {
{0, 10, bspwm_update, {'\0'}},