Added .prettierignore to avoid removing tabs in man page.
This commit is contained in:
parent
284a85485d
commit
c802f4041f
5 changed files with 117 additions and 93 deletions
1
.prettierignore
Normal file
1
.prettierignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uwufetch_man.md
|
8
Makefile
8
Makefile
|
@ -2,18 +2,19 @@ NAME = uwufetch
|
||||||
FILES = uwufetch.c
|
FILES = uwufetch.c
|
||||||
CFLAGS = -O3
|
CFLAGS = -O3
|
||||||
CFLAGS_DEBUG = -Wall -Wextra
|
CFLAGS_DEBUG = -Wall -Wextra
|
||||||
|
LIBS = -ljson-c
|
||||||
PREFIX = /usr/bin
|
PREFIX = /usr/bin
|
||||||
CC = cc
|
CC = cc
|
||||||
MAN_COMPILER = pandoc
|
MAN_COMPILER = pandoc
|
||||||
|
|
||||||
build: $(FILES)
|
build: $(FILES)
|
||||||
$(CC) $(CFLAGS) -o $(NAME) $(FILES)
|
$(CC) $(CFLAGS) $(LIBS) -o $(NAME) $(FILES)
|
||||||
$(MAN_COMPILER) $(NAME)_man.md -st man -o $(NAME).1
|
$(MAN_COMPILER) $(NAME)_man.md -st man -o $(NAME).1
|
||||||
@gzip $(NAME).1
|
@gzip $(NAME).1
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
@clear
|
@clear
|
||||||
$(CC) $(CFLAGS_DEBUG) -o $(NAME) $(FILES)
|
$(CC) $(CFLAGS_DEBUG) $(LIBS) -o $(NAME) $(FILES)
|
||||||
./uwufetch
|
./uwufetch
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@ -36,6 +37,7 @@ termux_uninstall:
|
||||||
rm -rf $(DESTDIR)/data/data/com.termux/files$(PREFIX)/$(NAME)
|
rm -rf $(DESTDIR)/data/data/com.termux/files$(PREFIX)/$(NAME)
|
||||||
rm -rf $(DESTDIR)/data/data/com.termux/files/usr/lib/uwufetch/
|
rm -rf $(DESTDIR)/data/data/com.termux/files/usr/lib/uwufetch/
|
||||||
|
|
||||||
man_debug: build
|
man_debug:
|
||||||
|
$(MAN_COMPILER) $(NAME)_man.md -st man -o $(NAME).1
|
||||||
@clear
|
@clear
|
||||||
@man -P cat ./uwufetch.1
|
@man -P cat ./uwufetch.1
|
||||||
|
|
|
@ -20,6 +20,8 @@ endeavOwO, KDE NeOwOn, nixOwOs, Swackwawe, sOwOlus; Plus FweeBSD, OwOpenBSD and
|
||||||
|
|
||||||
[lshw](https://github.com/lyonel/lshw) to get gpu info.
|
[lshw](https://github.com/lyonel/lshw) to get gpu info.
|
||||||
|
|
||||||
|
[json-c](https://github.com/json-c/json-c) to parse the json config.
|
||||||
|
|
||||||
##### Via package manager
|
##### Via package manager
|
||||||
|
|
||||||
Right now, the package is only available on the AUR:
|
Right now, the package is only available on the AUR:
|
||||||
|
|
97
uwufetch.c
97
uwufetch.c
|
@ -19,6 +19,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <json-c/json.h>
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -68,14 +69,11 @@ struct utsname sys_var;
|
||||||
struct sysinfo sys;
|
struct sysinfo sys;
|
||||||
#endif
|
#endif
|
||||||
struct winsize win;
|
struct winsize win;
|
||||||
int ram_total, ram_used = 0;
|
|
||||||
// initialise the variables to store data, gpu array can hold up to 8 gpus
|
// initialise the variables to store data, gpu array can hold up to 8 gpus
|
||||||
int pkgs, target_width = 0;
|
int target_width = 0, screen_width = 0, screen_height = 0, ram_total, ram_used = 0, pkgs = 0;
|
||||||
long uptime = 0;
|
long uptime = 0;
|
||||||
// all flags available
|
// all flags available
|
||||||
int ascii_image_flag = 0,
|
int ascii_image_flag = 0,
|
||||||
screen_width = 0,
|
|
||||||
screen_height = 0,
|
|
||||||
show_user_info = 1,
|
show_user_info = 1,
|
||||||
show_os = 1,
|
show_os = 1,
|
||||||
show_kernel = 1,
|
show_kernel = 1,
|
||||||
|
@ -93,6 +91,7 @@ char user[32], host[256], shell[64], kernel[256], version_name[64], cpu_model[25
|
||||||
|
|
||||||
// functions definitions, to use them in main()
|
// functions definitions, to use them in main()
|
||||||
int pkgman();
|
int pkgman();
|
||||||
|
void parse_json();
|
||||||
void parse_config();
|
void parse_config();
|
||||||
void get_info();
|
void get_info();
|
||||||
void list();
|
void list();
|
||||||
|
@ -147,7 +146,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse_config();
|
parse_json();
|
||||||
if ((argc == 1 && ascii_image_flag == 0) || (argc > 1 && ascii_image_flag == 0))
|
if ((argc == 1 && ascii_image_flag == 0) || (argc > 1 && ascii_image_flag == 0))
|
||||||
print_ascii();
|
print_ascii();
|
||||||
else if (ascii_image_flag)
|
else if (ascii_image_flag)
|
||||||
|
@ -156,49 +155,59 @@ int main(int argc, char *argv[])
|
||||||
print_info();
|
print_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_config()
|
void parse_json()
|
||||||
{
|
{ // using json-c library to parse the config
|
||||||
char line[256];
|
// allocating all necessary variables
|
||||||
|
char buffer[1024];
|
||||||
char *homedir = getenv("HOME");
|
char *homedir = getenv("HOME");
|
||||||
char *temp_buffer = "";
|
config_directory = "./test.json";
|
||||||
FILE *config;
|
struct json_object *parsed_json, *distributon, *image, *ascii, *user, *os, *kernel, *cpu, *gpu, *ram, *resolution, *shell, *pkgs, *uptime, *colors;
|
||||||
|
|
||||||
|
// opening and reading the config file
|
||||||
|
FILE *config;
|
||||||
if (config_directory == NULL)
|
if (config_directory == NULL)
|
||||||
config = fopen(strcat(homedir, "/.config/uwufetch/config"), "r");
|
config = fopen(strcat(homedir, "/.config/uwufetch/config"), "r");
|
||||||
else
|
else
|
||||||
config = fopen(config_directory, "r");
|
config = fopen(config_directory, "r");
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
return;
|
return;
|
||||||
while (fgets(line, sizeof(line), config))
|
fread(buffer, 1024, 1, config);
|
||||||
{
|
fclose(config);
|
||||||
if (line[0] == '#')
|
|
||||||
continue;
|
// parsing json data
|
||||||
if (strlen(image_name) < 1 && ascii_image_flag == 0)
|
parsed_json = json_tokener_parse(buffer);
|
||||||
ascii_image_flag = sscanf(line, "image=%s", image_name);
|
json_object_object_get_ex(parsed_json, "distribution", &distributon);
|
||||||
sscanf(line, "distro=%s", version_name);
|
json_object_object_get_ex(parsed_json, "image", &image);
|
||||||
if (sscanf(line, "nouser%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "ascii", &ascii);
|
||||||
show_user_info = 0;
|
json_object_object_get_ex(parsed_json, "user", &user);
|
||||||
if (sscanf(line, "noos%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "os", &os);
|
||||||
show_os = 0;
|
json_object_object_get_ex(parsed_json, "kernel", &kernel);
|
||||||
if (sscanf(line, "nokernel%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "cpu", &cpu);
|
||||||
show_kernel = 0;
|
json_object_object_get_ex(parsed_json, "gpu", &gpu);
|
||||||
if (sscanf(line, "nocpu%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "ram", &ram);
|
||||||
show_cpu = 0;
|
json_object_object_get_ex(parsed_json, "resolution", &resolution);
|
||||||
if (sscanf(line, "nogpu%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "shell", &shell);
|
||||||
show_gpu = 0;
|
json_object_object_get_ex(parsed_json, "pkgs", &pkgs);
|
||||||
if (sscanf(line, "noram%s", temp_buffer))
|
json_object_object_get_ex(parsed_json, "uptime", &uptime);
|
||||||
show_ram = 0;
|
json_object_object_get_ex(parsed_json, "colors", &colors);
|
||||||
if (sscanf(line, "noresolution%s", temp_buffer))
|
|
||||||
show_resolution = 0;
|
sprintf(version_name, "%s", json_object_get_string(distributon));
|
||||||
if (sscanf(line, "noshell%s", temp_buffer))
|
if (sprintf(image_name, "%s", json_object_get_string(image)) == 0)
|
||||||
show_shell = 0;
|
ascii_image_flag = 1;
|
||||||
if (sscanf(line, "nopkgs%s", temp_buffer))
|
else // reset image_name var to avoid errors
|
||||||
show_pkgs = 0;
|
sprintf(image_name, "");
|
||||||
if (sscanf(line, "nouptime%s", temp_buffer))
|
ascii_image_flag = !json_object_get_boolean(ascii);
|
||||||
show_uptime = 0;
|
show_user_info = json_object_get_boolean(user);
|
||||||
if (sscanf(line, "nocolors%s", temp_buffer))
|
show_os = json_object_get_boolean(os);
|
||||||
show_colors = 0;
|
show_kernel = json_object_get_boolean(kernel);
|
||||||
}
|
show_cpu = json_object_get_boolean(cpu);
|
||||||
|
show_gpu = json_object_get_boolean(gpu);
|
||||||
|
show_ram = json_object_get_boolean(ram);
|
||||||
|
show_resolution = json_object_get_boolean(resolution);
|
||||||
|
show_shell = json_object_get_boolean(shell);
|
||||||
|
show_pkgs = json_object_get_boolean(pkgs);
|
||||||
|
show_uptime = json_object_get_boolean(uptime);
|
||||||
|
show_colors = json_object_get_boolean(colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pkgman()
|
int pkgman()
|
||||||
|
@ -294,17 +303,19 @@ void print_info()
|
||||||
printf("\033[18C%s%sPKGS %s%s%d %s\n",
|
printf("\033[18C%s%sPKGS %s%s%d %s\n",
|
||||||
NORMAL, BOLD, NORMAL, NORMAL, pkgs, pkgman_name);
|
NORMAL, BOLD, NORMAL, NORMAL, pkgs, pkgman_name);
|
||||||
if (show_uptime)
|
if (show_uptime)
|
||||||
#ifdef __APPLE__
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
uptime = uptime_mac();
|
uptime = uptime_mac();
|
||||||
#else
|
#else
|
||||||
uptime = sys.uptime;
|
uptime = sys.uptime;
|
||||||
#endif
|
#endif
|
||||||
if (uptime / 3600 < 24)
|
if (uptime / 3600 < 24)
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n",
|
printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
||||||
else
|
else
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n",
|
printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
||||||
|
}
|
||||||
if (show_colors)
|
if (show_colors)
|
||||||
printf("\033[18C%s%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\n",
|
printf("\033[18C%s%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\n",
|
||||||
BOLD, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, NORMAL);
|
BOLD, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, NORMAL);
|
||||||
|
|
|
@ -41,20 +41,26 @@ prints a list of all supported distributions
|
||||||
|
|
||||||
The config file is located in $HOME/.config/uwufetch/config (you need to create it), but you can change the path by using the `--config` option.
|
The config file is located in $HOME/.config/uwufetch/config (you need to create it), but you can change the path by using the `--config` option.
|
||||||
|
|
||||||
## OPTIONS
|
## EXAMPLE
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"distribution": "debian",
|
||||||
|
"image": "/home/user/Pictures/debian.png",
|
||||||
|
"ascii": false,
|
||||||
|
"user": true,
|
||||||
|
"os": true,
|
||||||
|
"kernel": true,
|
||||||
|
"cpu": true,
|
||||||
|
"gpu": true,
|
||||||
|
"ram": true,
|
||||||
|
"resolution": true,
|
||||||
|
"shell": true,
|
||||||
|
"pkgs": true,
|
||||||
|
"uptime": true,
|
||||||
|
"colors": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
distribution=name\ \ \ \ \ # use it to change displayed distribution\
|
|
||||||
image=/path/to/image\ \ \ # enable images (leave blank), or use custom image path\
|
|
||||||
nouser\ \ \ \ \ \ \ \ \ \ \ # disable username and hostname\
|
|
||||||
noos\ \ \ \ \ \ \ \ \ \ \ # disable os\
|
|
||||||
nokernel\ \ \ \ \ \ \ \ \ # disable kernel\
|
|
||||||
nocpu\ \ \ \ \ \ \ \ \ \ \ # disable cpu\
|
|
||||||
nogpu\ \ \ \ \ \ \ \ \ \ \ # disable gpu\
|
|
||||||
noram\ \ \ \ \ \ \ \ \ \ \ # disable ram\
|
|
||||||
noshell\ \ \ \ \ \ \ \ \ \ # disable shell\
|
|
||||||
nopkgs\ \ \ \ \ \ \ \ \ \ \ # disable pkgs\
|
|
||||||
nouptime\ \ \ \ \ \ \ \ \ # disable uptime\
|
|
||||||
nocolors\ \ \ \ \ \ \ \ \ # disable colors
|
|
||||||
|
|
||||||
# SUPPORTED DISTRIBUTIONS
|
# SUPPORTED DISTRIBUTIONS
|
||||||
|
|
||||||
|
@ -100,12 +106,14 @@ ueufetch -i -d artix\ \ \ \ \ \ \ \ # prints artix image
|
||||||
|
|
||||||
# DEPENDANCES
|
# DEPENDANCES
|
||||||
|
|
||||||
lshw\ \ better gpu info\
|
json-c\ \ \ to parse the config file\
|
||||||
viu\ \ \ print images instead of ascii logo\
|
lshw\ \ \ better gpu info\
|
||||||
kitty\ \ better image viewing
|
viu\ \ \ \ print images instead of ascii logo\
|
||||||
|
kitty\ \ \ better image viewing
|
||||||
|
|
||||||
All of this are optional, there is no necessary dependancy.
|
All of this are optional, there is no necessary dependancy.
|
||||||
|
|
||||||
# LICENSE AND COPYRIGTH
|
# LICENSE AND COPYRIGTH
|
||||||
|
|
||||||
uwufetch is provided under the GPL3 license, for copyright info read https://github.com/TheDarkBug/uwufetch/tree/main/res/COPYRIGHT.md.
|
uwufetch is provided under the GPL3 license, for copyright info read\
|
||||||
|
https://github.com/TheDarkBug/uwufetch/tree/main/res/COPYRIGHT.md.
|
||||||
|
|
Loading…
Reference in a new issue