Skip to content

Commit 5ac2bad

Browse files
authored
Merge pull request #1 from siddhp1/v2
Version 2.0.0
2 parents 4e23a23 + 2528473 commit 5ac2bad

31 files changed

+1667
-1007
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated directories
22
/bin/
33
/build/
4+
/logs/
45

56
# CMake
67
CMakeLists.txt.user

Diff for: CMakeLists.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,25 @@ set(CMAKE_C_STANDARD_REQUIRED True)
1515
include_directories(include)
1616

1717
# Source files
18-
set(SOURCES src/main.c src/data.c src/config.c src/art.c)
18+
set(SOURCES src/main.c src/sysgrab_art.c src/sysgrab_config.c src/sysgrab_data.c src/sysgrab_log.c src/sysgrab_number.c src/sysgrab_path.c src/sysgrab_print.c src/sysgrab_string.c src/sysgrab_time.c)
1919

2020
# Specify the output directory for binaries
2121
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
2222

2323
# Add the executable
2424
add_executable(sysgrab ${SOURCES})
2525

26+
# Link the yaml library
27+
target_link_libraries(sysgrab yaml)
28+
2629
# Copy resource files to the bin directory
2730
add_custom_command(TARGET sysgrab POST_BUILD
2831
COMMAND ${CMAKE_COMMAND} -E copy_if_different
2932
${CMAKE_SOURCE_DIR}/resources/art.txt
30-
${CMAKE_SOURCE_DIR}/resources/config.txt
33+
${CMAKE_SOURCE_DIR}/resources/config.yaml
3134
$<TARGET_FILE_DIR:sysgrab>
3235
)
3336

3437
# Install the executable and resource files
3538
install(TARGETS sysgrab DESTINATION ${CMAKE_SOURCE_DIR}/bin)
36-
install(FILES resources/art.txt resources/config.txt DESTINATION ${CMAKE_SOURCE_DIR}/bin)
39+
install(FILES resources/art.txt resources/config.yaml DESTINATION ${CMAKE_SOURCE_DIR}/bin)

Diff for: README.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Sysgrab is a lightweight and customizable system information tool for fetching a
44

55
<p align="center"><a><img width="800" alt="Thumbnail Image of Sysgrab" src="https://www.siddhp.me/_next/image?url=%2Fsysgrab.png&w=3840&q=75"></a></p>
66

7-
Users can configure Sysgrab's base and accent colors, and add ASCII art of their choice through the CLI or by directly editing the configuration files.
7+
Users can configure Sysgrab's colors, the ordering of datpoints and add ASCII art of their choice by editing the configuration files.
88

99
Sysgrab is compatible with all Linux distributions.
1010

@@ -20,13 +20,11 @@ To install Sysgrab, follow these steps:
2020

2121
Add the extracted directory to your system PATH to make `sysgrab` accessible from anywhere in the terminal.
2222

23-
Add this line to `.bashrc` or `.zshrc` to make the change persistent.
23+
Add this line to your shell configuration to make the change persistent
2424

2525
```bash
2626
export PATH=$PATH:/path/to/sysgrab-directory
27-
```
28-
29-
27+
```
3028

3129
## Usage
3230

@@ -41,25 +39,19 @@ sysgrab [OPTIONS]
4139
(no option) Display system information
4240
-h, --help Show a help message and exit
4341
-v, --version Display version information and exit
44-
-b, --base-color [r,g,b] Set base color in the format r,g,b
45-
-a, --accent-color [r,g,b] Set accent color in the format r,g,b
4642
```
4743

4844
## Configuration
4945

5046
To configure Sysgrab, follow these steps:
5147

52-
1. **Configure colors**:
53-
54-
To configure the colors, edit the `config.txt` file, or run the following command with rgb values of choice:
48+
1. **Configure colors, logging, and data ordering**:
5549

56-
```bash
57-
sysgrab --base-color r,g,b --accent-color r,g,b
58-
```
50+
To configure the colors, edit the `config.yaml` file.
5951

6052
2. **Add art**:
6153

62-
To configure the art, paste any ASCII art in the `art.txt` file.
54+
To configure the art, create a text file with ASCII art, and put the file name in the `config.yaml` file.
6355

6456
## License
6557

Diff for: include/art.h

-12
This file was deleted.

Diff for: include/config.h

-19
This file was deleted.

Diff for: include/data.h

-24
This file was deleted.

Diff for: include/sysgrab_art.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef SYSGRAB_ART_H
2+
#define SYSGRAB_ART_H
3+
4+
#include <stddef.h>
5+
6+
typedef struct Art {
7+
size_t lines;
8+
size_t maximum_line_length;
9+
char **art_array;
10+
} Art;
11+
12+
void free_art(Art *art);
13+
Art *get_art(const char *file_path);
14+
15+
#endif

Diff for: include/sysgrab_config.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef SYSGRAB_CONFIG_H
2+
#define SYSGRAB_CONFIG_H
3+
4+
#include "sysgrab_data.h"
5+
6+
typedef struct Color {
7+
unsigned char red;
8+
unsigned char green;
9+
unsigned char blue;
10+
} Color;
11+
12+
typedef struct Config {
13+
bool log_errors;
14+
Color base_color;
15+
Color accent_color;
16+
char *art_file_name;
17+
Data *data;
18+
} Config;
19+
20+
Config *get_config(const char *file_path);
21+
22+
#endif

Diff for: include/sysgrab_data.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef SYSGRAB_DATA_H
2+
#define SYSGRAB_DATA_H
3+
4+
#include <stdbool.h>
5+
#include <stddef.h>
6+
7+
typedef struct DataPoint {
8+
char *key;
9+
char *value;
10+
} DataPoint;
11+
12+
typedef struct Data {
13+
size_t length;
14+
DataPoint **datapoints;
15+
} Data;
16+
17+
DataPoint *get_datapoint(const char *data_point);
18+
19+
Data *create_data(void);
20+
bool add_datapoint(Data *data, DataPoint *datapoint);
21+
void free_datapoint(DataPoint *datapoint);
22+
void free_data(Data *data);
23+
24+
#endif

Diff for: include/sysgrab_log.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SYSGRAB_LOGS_H
2+
#define SYSGRAB_LOGS_H
3+
4+
char *get_log_file_path(void);
5+
6+
#endif

Diff for: include/sysgrab_number.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef SYSGRAB_NUMBER_H
2+
#define SYSGRAB_NUMBER_H
3+
4+
double get_double_from_string(const char *string);
5+
long int get_long_from_string(const char *string);
6+
unsigned char get_unsigned_char_from_ascii(const char *ascii);
7+
8+
#endif

Diff for: include/sysgrab_path.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SYSGRAB_PATH_H
2+
#define SYSGRAB_PATH_H
3+
4+
char *get_file_path(const char *file_name);
5+
6+
#endif

Diff for: include/sysgrab_print.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SYSGRAB_PRINT_H
2+
#define SYSGRAB_PRINT_H
3+
4+
void print_sysgrab(const Art *art, const Config *config);
5+
6+
#endif

Diff for: include/sysgrab_string.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef SYSGRAB_STRING_H
2+
#define SYSGRAB_STRING_H
3+
4+
char *clean_string(const char *original_string, const char *prefix,
5+
const char *suffix);
6+
char *get_string_from_command(const char *command, const char *look_up);
7+
char *get_string_from_double(const double value,
8+
const char *conversion_specifier);
9+
char *get_string_from_file(const char *file_path, const char *look_up);
10+
char *get_string_from_long(const long value);
11+
12+
#endif

Diff for: include/sysgrab_time.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SYSGRAB_TIME_H
2+
#define SYSGRAB_TIME_H
3+
4+
char *get_datetime(void);
5+
6+
#endif

Diff for: resources/art.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
| `. | `' \Zq
1414
_) \.___.,| .'
1515
\____ )MMMMMP| .'
16-
`-' `--' hjm
16+
`-' `--' hj

Diff for: resources/config.txt

-2
This file was deleted.

Diff for: resources/config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
log_errors: True
2+
art_file_name: art.txt
3+
base_color: [255, 255, 255]
4+
accent_color: [20, 200, 255]
5+
ordering:
6+
- os
7+
- architecture
8+
- kernel
9+
- computer
10+
- shell
11+
- uptime
12+
- cpu
13+
- memory

Diff for: src/art.c

-99
This file was deleted.

0 commit comments

Comments
 (0)