From 673501a2d7929a9420fe6c2c3d9d35e0b67110f5 Mon Sep 17 00:00:00 2001 From: dqnk Date: Wed, 14 Apr 2021 21:27:14 +0200 Subject: [PATCH 1/6] [TYPO] fixed typos in CONTRIBUTING.md. --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fef80d..7c5fa11 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ To contribute to this project, you should follow some rules to keep the code consistent: - To indent I like to use tabs in size 4, so you should use them to commit. -- When an the code in an `if` (or `else`) statement is only one line please do not use curly brackets: +- When the code in an `if` (or `else`) statement is only one line please do not use curly brackets: ```c if (things) something(will_happen); @@ -17,7 +17,7 @@ else something(!will_happen); ``` -- When the the code in an `if` (or `else`) statement is too short, write it in one line (if it is readable): +- When the code in an `if` (or `else`) statement is too short, write it in one line (if it is readable): ```c if (this) that(); @@ -52,4 +52,4 @@ If you are requesting a feature, please specify if you are already working on it I know that adding this file now is a bit late, but I am writing this anyway, just to appear as a *professional* programmer, even though I am not. -I woult take some space to thank all the [contributors](https://github.com/TheDarkBug/uwufetch/graphs/contributors) that made this project better every day. \ No newline at end of file +I would take some space to thank all the [contributors](https://github.com/TheDarkBug/uwufetch/graphs/contributors) that made this project better every day. \ No newline at end of file From ffaa5a01944a4cb2f9b8e33a215348ded42acee1 Mon Sep 17 00:00:00 2001 From: dqnk <64268180+dqnk@users.noreply.github.com> Date: Wed, 14 Apr 2021 21:36:00 +0200 Subject: [PATCH 2/6] Added new lines where "Prettier" would add them you can remove this commit if you don't like the formatting from "Prettier" extension --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7c5fa11..c229a1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,7 @@ else nothing(); - Before pushing the commit, please delete double-new-lines. # + ## Pull requests Before sending a pull request be sure that no one is already working on the same thing and to follow this guide-lines. @@ -39,6 +40,7 @@ Before sending a pull request be sure that no one is already working on the same With pull requests you can `[FIX]` a bug (reported or not), add `[OS-SUPPORT]`, add a `[NEW-FEATURE]` requested in an [issue](https://github.com/TheDarkBug/uwufetch/blob/main/CONTRIBUTING.md#issues), fix a `[TYPO]` or `[OPTIMIZE]` the code. For everything else do not use tags. # + ## Issues You can use the issues to report bugs with `[BUG]`, to request features `[FEATURE-REQUEST]`, to request support for an os `[OS-SUPPORT]`. For everything else do not use tags. @@ -48,8 +50,9 @@ If you are reporting a `[BUG]`, please include a screenshot and the output of th If you are requesting a feature, please specify if you are already working on it, then send a [pull request](https://github.com/TheDarkBug/uwufetch/blob/main/CONTRIBUTING.md#pull-requests). # + ## Conclusions I know that adding this file now is a bit late, but I am writing this anyway, just to appear as a *professional* programmer, even though I am not. -I would take some space to thank all the [contributors](https://github.com/TheDarkBug/uwufetch/graphs/contributors) that made this project better every day. \ No newline at end of file +I would take some space to thank all the [contributors](https://github.com/TheDarkBug/uwufetch/graphs/contributors) that made this project better every day. From e4acabada7ccef152cdfaef74efb2f72fe54778d Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Wed, 14 Apr 2021 17:25:11 -0300 Subject: [PATCH 3/6] merge --custom and --image --- uwufetch.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index fbc8c38..08a264f 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -81,25 +81,20 @@ int main(int argc, char *argv[]) { int opt = 0; static struct option long_options[] = { { "ascii", no_argument, NULL, 'a' }, - { "custom", required_argument, NULL, 'c' }, { "config", required_argument, NULL, 0}, { "distro", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, - { "image", no_argument, NULL, 'i' }, + { "image", optional_argument, NULL, 'i' }, { "list", no_argument, NULL, 'l' }, { NULL, 0, NULL, 0 } }; get_info(); parse_config(); - while ((opt = getopt_long(argc, argv, "ad:hilc:", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "ad:hi::l", long_options, NULL)) != -1) { switch (opt) { case 'a': ascii_image_flag = 0; break; - case 'c': - ascii_image_flag = 1; - sprintf(image_name, "%s", optarg); - break; case 'd': if (optarg) sprintf(version_name, "%s", optarg); break; @@ -108,6 +103,10 @@ int main(int argc, char *argv[]) { return 0; case 'i': ascii_image_flag = 1; + char *image_dir = NULL; + if(!optarg && argv[optind] != NULL && argv[optind][0] != '-') image_dir = argv[optind++]; + else image_dir = optarg; + if(image_dir != NULL) sprintf(image_name, "%s", image_dir); break; case 'l': list(argv[0]); From 028a269b2438dfe54fd948b57abb9440dd47191e Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Wed, 14 Apr 2021 18:38:49 -0300 Subject: [PATCH 4/6] add --config --- uwufetch.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index 08a264f..97236da 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -62,7 +62,7 @@ int ascii_image_flag = 0, show_colors = 1; char user[32], host[256], shell[64], kernel[256], version_name[64], cpu_model[256], gpu_model[8][256] = {{'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}}, - pkgman_name[64], image_name[32]; + pkgman_name[64], image_name[128], *config_directory = NULL; // functions definitions, to use them in main() int pkgman(); @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) { int opt = 0; static struct option long_options[] = { { "ascii", no_argument, NULL, 'a' }, - { "config", required_argument, NULL, 0}, + { "config", required_argument, NULL, 'c'}, { "distro", required_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { "image", optional_argument, NULL, 'i' }, @@ -89,12 +89,14 @@ int main(int argc, char *argv[]) { { NULL, 0, NULL, 0 } }; get_info(); - parse_config(); - while ((opt = getopt_long(argc, argv, "ad:hi::l", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "ac:d:hi::l", long_options, NULL)) != -1) { switch (opt) { case 'a': ascii_image_flag = 0; break; + case 'c': + config_directory = optarg; + break; case 'd': if (optarg) sprintf(version_name, "%s", optarg); break; @@ -103,10 +105,8 @@ int main(int argc, char *argv[]) { return 0; case 'i': ascii_image_flag = 1; - char *image_dir = NULL; - if(!optarg && argv[optind] != NULL && argv[optind][0] != '-') image_dir = argv[optind++]; - else image_dir = optarg; - if(image_dir != NULL) sprintf(image_name, "%s", image_dir); + if(!optarg && argv[optind] != NULL && argv[optind][0] != '-') sprintf(image_name, "%s", argv[optind++]); + else if(optarg) sprintf(image_name, "%s", optarg); break; case 'l': list(argv[0]); @@ -115,6 +115,7 @@ int main(int argc, char *argv[]) { break; } } + parse_config(); if ((argc == 1 && ascii_image_flag == 0) || (argc > 1 && ascii_image_flag == 0)) print_ascii(); else if (ascii_image_flag) print_image(); uwu_name(); @@ -125,12 +126,14 @@ void parse_config() { char line[256]; char *homedir = getenv("HOME"); char *temp_buffer = ""; - - FILE *config = fopen(strcat(homedir, "/.config/uwufetch/config"), "r"); + FILE *config; + + if(config_directory == NULL) config = fopen(strcat(homedir, "/.config/uwufetch/config"), "r"); + else config = fopen(config_directory, "r"); if(config == NULL) return; while(fgets(line, sizeof(line), config)) { if(line[0] == '#') continue; - ascii_image_flag = sscanf(line, "image=%s", image_name); + if(strlen(image_name) < 1 && ascii_image_flag == 0) ascii_image_flag = sscanf(line, "image=%s", image_name); sscanf(line, "distro=%s", version_name); if (sscanf(line, "nouser%s", temp_buffer)) show_user_info = 0; if (sscanf(line, "noos%s", temp_buffer)) show_os = 0; From d0c8e5c1d778abb3d2079fd26e1b0dfede152ebd Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Wed, 14 Apr 2021 18:46:48 -0300 Subject: [PATCH 5/6] Update usage --- uwufetch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/uwufetch.c b/uwufetch.c index 97236da..0cff649 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -510,11 +510,10 @@ void print_image() { // prints logo (as an image) of the given system. distribut void usage(char *arg) { printf( "Usage: %s \n" " -a, --ascii prints logo as ascii text (default)\n" - " -c, --custom choose a custom image\n" // this options should be different, maybe merged with `-i` - " --config use custom config path\n" + " -c --config use custom config path\n" " -d, --distro lets you choose the logo to print\n" " -h, --help prints this help page\n" - " -i, --image prints logo as image\n" // someone should add an optional argument to change image without using `-c`, but I don't know how to do it. + " -i, --image prints logo as image and use a custom image if provided\n" " %sworks in most terminals\n" " read README.md for more info%s\n" " -l, --list lists all supported distributions\n", From 066ba03c3efc8d661c125960328b35b747b17359 Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Wed, 14 Apr 2021 18:49:02 -0300 Subject: [PATCH 6/6] Update man page --- uwufetch_man.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/uwufetch_man.md b/uwufetch_man.md index 36dba69..9098afa 100644 --- a/uwufetch_man.md +++ b/uwufetch_man.md @@ -16,10 +16,7 @@ uwufetch - A meme system info tool for Linux, based on nyan/uwu trend on r/linux -a --ascii\ prints the logo as ascii text (default) --c --custom\ -you can choose a custom image path - ---config\ +-c --config\ you can change config path -d --distro\ @@ -29,7 +26,8 @@ you can choose the logo to print by the distro name prints a help page -i --image\ -prints image instead of ascii logo +prints image instead of ascii logo\ +uses a custom image if one is provided -l --list\ prints a list of all supported distributions