-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luxfetch: stub for a neofetch-like app
- Loading branch information
1 parent
ba488aa
commit 9858e83
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
PLATFORM=x86_64-lux | ||
CCFLAGS=-Wall -c -O3 | ||
LDFLAGS=-llux | ||
CC=x86_64-lux-gcc | ||
LD=x86_64-lux-gcc | ||
SRC:=$(shell find . -type f -name "*.c") | ||
OBJ:=$(SRC:.c=.o) | ||
|
||
all: luxfetch | ||
|
||
%.o: %.c | ||
@echo "\x1B[0;1;32m cc \x1B[0m $<" | ||
@$(CC) $(CCFLAGS) -o $@ $< | ||
|
||
luxfetch: $(OBJ) | ||
@echo "\x1B[0;1;93m ld \x1B[0m luxfetch" | ||
@$(LD) $(OBJ) -o luxfetch $(LDFLAGS) | ||
|
||
install: luxfetch | ||
@cp luxfetch ../out/ | ||
|
||
clean: | ||
@rm -f luxfetch $(OBJ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* luxOS - a unix-like operating system | ||
* Omar Elghoul, 2024 | ||
* | ||
* luxfetch: neofetch clone for luxOS | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#define COLOR "\e[0;94m" | ||
#define RESET "\e[0m" | ||
|
||
int main(void) { | ||
// get kernel info | ||
FILE *f = fopen("/proc/kernel", "r"); | ||
if(!f) { | ||
fprintf(stderr, "unable to open /proc/kernel for reading\n"); | ||
return -1; | ||
} | ||
|
||
fseek(f, 0, SEEK_END); | ||
long size = ftell(f); | ||
fseek(f, 0, SEEK_SET); | ||
|
||
char *kernel = calloc(1, size+1); | ||
if(!kernel) { | ||
fprintf(stderr, "failed to allocate memory\n"); | ||
fclose(f); | ||
return -1; | ||
} | ||
|
||
if(fread(kernel, 1, size, f) != size) { | ||
fprintf(stderr, "failed to read from /proc/kernel\n"); | ||
fclose(f); | ||
return -1; | ||
} | ||
|
||
printf("%s\n", kernel); | ||
return 0; | ||
} |