Skip to content

Commit

Permalink
Merge branch 'main' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Sep 24, 2024
2 parents 1247f53 + b4b40b6 commit 3b75a18
Show file tree
Hide file tree
Showing 30 changed files with 576 additions and 345 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ output/
cufetch_r
thinkpad-arch_logo.txt
tanjiro_logo.txt
scripts/ascii_parser.py
scripts/dict_to_files.py
scripts/test*

*.tar.*

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ USE_DCONF ?= 1
# WAY easier way to build debug and release builds
ifeq ($(DEBUG), 1)
BUILDDIR = build/debug
CXXFLAGS := -ggdb3 -Wall -Wextra -Wpedantic -DDEBUG=1 $(DEBUG_CXXFLAGS) $(CXXFLAGS)
CXXFLAGS := -ggdb3 -Wall -Wextra -Wpedantic -Wno-unused-parameter -DDEBUG=1 $(DEBUG_CXXFLAGS) $(CXXFLAGS)
else
# Check if an optimization flag is not already set
ifneq ($(filter -O%,$(CXXFLAGS)),)
Expand Down
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
[![forthebadge](https://forthebadge.com/images/badges/works-on-my-machine.svg)](https://forthebadge.com)

# Customfetch
>[!WARNING]
>customfetch is in alpha, it will be 100% ready with a stable release.\
>It is pretty stable right now though, so give it a try, why not\
>Don't forget to open any issue/PR for any problem.\
>Thanks!

A system information fetch tool (or [neofetch](https://github.com/dylanaraps/neofetch) like program), which its focus point is the customizability and perfomance.\
`customfetch` is designed to provide a really customizable way to display your system informations in the way you like or want.
Expand Down Expand Up @@ -35,9 +30,6 @@ Currently supports Linux distros only. Android may be coming when stable release
* **GUI mode (GTK3)**
* Really customizable and fast, check [Config (with explanation)](#config-with-explanation) section
* Lightweight
>[!NOTE]
>enabling GUI mode may slow down customfetch a bit because it needs to load the GUI libraries at runtime\
>To check if it's enabled or not, run "cufetch --version"

## Depends
currently requires **C++20**, but it's possible to compile with C++17 too (not officially supported)
Expand All @@ -50,6 +42,10 @@ If you want to install with GUI mode install from your package manager:

## Installation

>[!NOTE]
>installing with GUI mode may slow down customfetch a bit because it needs to load the GUI libraries at runtime.\
>To check if it's enabled or not, run "cufetch --version"
### Debian/Ubuntu and based
Download the latest `.deb` package in [releases](https://github.com/Toni500github/customfetch/releases/latest)

Expand Down Expand Up @@ -134,8 +130,8 @@ layout = [
"${auto}GPU: $<gpu.name>",
"${auto}RAM: $<ram.ram>",
"",
"$<builtin.colors_bg>", # normal colors palette
"$<builtin.colors_light_bg>" # light colors palette
"$<builtin.colors>", # normal colors palette
"$<builtin.colors_light>" # light colors palette
]

# display ascii-art or image/gif (GUI only) near layout
Expand Down Expand Up @@ -251,7 +247,7 @@ bg-image = "/tmp/idk.png"
```

We use the `config.toml` file, in there we got an array variable called "layout". That's the variable where you customize how the infos should be displayed.\
You have 5 tags:
You have 5 tags:
* `$<module.member>` - Used for printing the value of a member of a module.
* `${color}` - Used for displaying text in a specific color.
* `$(bash command)` - Used to execute bash commands and print the output.
Expand Down Expand Up @@ -295,13 +291,13 @@ They can be used in the ascii art text file and layout, but how to use them?
* **The Percentage tag (`$%%`)** is used for displaying the percentage between 2 numbers.\
It **Must** contain a comma for separating the 2. They can be either be taken from a tag or it put yourself.\
For example: $%10,5%
For inverting colors of bad and great (red and green), before the last '%' a put '!' without quotes
For inverting colors of bad and great (red and green), before the first `%` a put `!`

Any `$` or brackets can be escaped with a backslash `\`

# TODOs
* Color all ASCII arts (101/262) will take long ahh time
* Support images on terminal as logo (currently only available in GUI mode)
* Support images on terminal as logo (currently only in kitty)
* idk

# Thanks
Expand All @@ -321,7 +317,7 @@ I would like to thanks:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Our favorite libraries that me and BurntRanch uses

* this string switch-case [library](https://github.com/xroche/stringswitch), \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Really amazing, thanks for making this
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Really amazing, thanks for making this

I hope you'll like customfetch, and also checkout [TabAUR](https://github.com/BurntRanch/TabAUR/tree/dev), our other project that was made before customfetch.\
Don't forgot [sdl_engine](https://github.com/BurntRanch/sdl_engine) too ;)
Expand Down
38 changes: 19 additions & 19 deletions assets/ascii/centos.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
${c1} ..
.PLTJ.
<><><><>
${c2}KKSSV' 4KKK ${c1}LJ${c4} KKKL.'VSSKK
${c2}KKV' 4KKKKK ${c1}LJ${c4} KKKKAL 'VKK
${c2}V' ' 'VKKKK ${c1}LJ${c4} KKKKV' ' 'V
${c2}.4MA.' 'VKK ${c1}LJ${c4} KKV' '.4Mb.
${c4} . ${c2}KKKKKA.' 'V ${c1}LJ${c4} V' '.4KKKKK ${c3}.
${c4} .4D ${c2}KKKKKKKA.'' ${c1}LJ${c4} ''.4KKKKKKK ${c3}FA.
${c4}<QDD ++++++++++++ ${c3}++++++++++++ GFD>
${c4} 'VD ${c3}KKKKKKKK'.. ${c2}LJ ${c1}..'KKKKKKKK ${c3}FV
${c4} ' ${c3}VKKKKK'. .4 ${c2}LJ ${c1}K. .'KKKKKV ${c3}'
${c3} 'VK'. .4KK ${c2}LJ ${c1}KKA. .'KV'
${c3}A. . .4KKKK ${c2}LJ ${c1}KKKKA. . .4
${c3}KKA. 'KKKKK ${c2}LJ ${c1}KKKKK' .4KK
${c3}KKSSA. VKKK ${c2}LJ ${c1}KKKV .4SSKK
${c2} <><><><>
'MKKM'
''
${yellow} ..
${yellow} .PLTJ.
${yellow} <><><><>
${green}KKSSV' 4KKK ${yellow}LJ${magenta} KKKL.'VSSKK
${green}KKV' 4KKKKK ${yellow}LJ${magenta} KKKKAL 'VKK
${green}V' ' 'VKKKK ${yellow}LJ${magenta} KKKKV' ' 'V
${green}.4MA.' 'VKK ${yellow}LJ${magenta} KKV' '.4Mb.
${magenta} . ${green}KKKKKA.' 'V ${yellow}LJ${magenta} V' '.4KKKKK ${blue}.
${magenta} .4D ${green}KKKKKKKA.'' ${yellow}LJ${magenta} ''.4KKKKKKK ${blue}FA.
${magenta}<QDD ++++++++++++ ${blue}++++++++++++ GFD>
${magenta} 'VD ${blue}KKKKKKKK'.. ${green}LJ ${yellow}..'KKKKKKKK ${blue}FV
${magenta} ' ${blue}VKKKKK'. .4 ${green}LJ ${yellow}K. .'KKKKKV ${blue}'
${blue} 'VK'. .4KK ${green}LJ ${yellow}KKA. .'KV'
${blue}A. . .4KKKK ${green}LJ ${yellow}KKKKA. . .4
${blue}KKA. 'KKKKK ${green}LJ ${yellow}KKKKK' .4KK
${blue}KKSSA. VKKK ${green}LJ ${yellow}KKKV .4SSKK
${green} <><><><>
${green} 'MKKM'
${green} ''
14 changes: 7 additions & 7 deletions assets/ascii/centos_small.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
${c2} ____${c1}^${c4}____
${c2} |\\ ${c1}|${c4} /|
${c2} | \\ ${c1}|${c4} / |
${c4}<---- ${c3}---->
${c3} | / ${c2}|${c1} \\ |
${c3} |/__${c2}|${c1}__\\|
${c2} v
${green} ____${yellow}^${magenta}____
${green} |\ ${yellow}|${magenta} /|
${green} | \ ${yellow}|${magenta} / |
${magenta}<---- ${blue}---->
${blue} | / ${green}|${yellow} \ |
${blue} |/__${green}|${yellow}__\|
${green} v
38 changes: 19 additions & 19 deletions assets/ascii/linux mint.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
${green} ...-:::::-...
${green} .-MMMMMMMMMMMMMMM-.
${green} .-MMMM${1}`..-:::::::-..`${green}MMMM-.
${green} .:MMMM${1}.:MMMMMMMMMMMMMMM:.${green}MMMM:.
${green} -MMM${1}-M---MMMMMMMMMMMMMMMMMMM.${green}MMM-
${green} `:MMM${1}:MM` :MMMM:....::-...-MMMM:${green}MMM:`
${green} :MMM${1}:MMM` :MM:` `` `` `:MMM:${green}MMM:
${green}.MMM${1}.MMMM` :MM. -MM. .MM- `MMMM.${green}MMM.
${green}:MMM${1}:MMMM` :MM. -MM- .MM: `MMMM-${green}MMM:
${green}:MMM${1}:MMMM` :MM. -MM- .MM: `MMMM:${green}MMM:
${green}:MMM${1}:MMMM` :MM. -MM- .MM: `MMMM-${green}MMM:
${green}.MMM${1}.MMMM` :MM:--:MM:--:MM: `MMMM.${green}MMM.
${green} :MMM${1}:MMM- `-MMMMMMMMMMMM-` -MMM-${green}MMM:
${green} :MMM${1}:MMM:` `:MMM:${green}MMM:
${green} .MMM${1}.MMMM:--------------:MMMM.${green}MMM.
${green} '-MMMM${1}.-MMMMMMMMMMMMMMM-.${green}MMMM-'
${green} '.-MMMM${1}``--:::::--``${green}MMMM-.'
${green} '-MMMMMMMMMMMMM-'
${green} ``-:::::-``
${1} ...-:::::-...
${1} .-MMMMMMMMMMMMMMM-.
${1} .-MMMM${green}`..-:::::::-..`${1}MMMM-.
${1} .:MMMM${green}.:MMMMMMMMMMMMMMM:.${1}MMMM:.
${1} -MMM${green}-M---MMMMMMMMMMMMMMMMMMM.${1}MMM-
${1} `:MMM${green}:MM` :MMMM:....::-...-MMMM:${1}MMM:`
${1} :MMM${green}:MMM` :MM:` `` `` `:MMM:${1}MMM:
${1}.MMM${green}.MMMM` :MM. -MM. .MM- `MMMM.${1}MMM.
${1}:MMM${green}:MMMM` :MM. -MM- .MM: `MMMM-${1}MMM:
${1}:MMM${green}:MMMM` :MM. -MM- .MM: `MMMM:${1}MMM:
${1}:MMM${green}:MMMM` :MM. -MM- .MM: `MMMM-${1}MMM:
${1}.MMM${green}.MMMM` :MM:--:MM:--:MM: `MMMM.${1}MMM.
${1} :MMM${green}:MMM- `-MMMMMMMMMMMM-` -MMM-${1}MMM:
${1} :MMM${green}:MMM:` `:MMM:${1}MMM:
${1} .MMM${green}.MMMM:--------------:MMMM.${1}MMM.
${1} '-MMMM${green}.-MMMMMMMMMMMMMMM-.${1}MMMM-'
${1} '.-MMMM${green}``--:::::--``${1}MMMM-.'
${1} '-MMMMMMMMMMMMM-'
${1} ``-:::::-``
File renamed without changes.
10 changes: 5 additions & 5 deletions assets/ascii/linuxlite_small.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
${yellow} /\\
${yellow} / \\
${yellow} /\
${yellow} / \
${yellow} / ${1}/ ${yellow}/
${yellow}> ${1}/ ${yellow}/
${yellow}\\ ${1}\\ ${yellow}\\
${yellow} \\_${1}\\${yellow}_\\
${1} \\
${yellow}\ ${1}\ ${yellow}\
${yellow} \_${1}\\${yellow}_\
${1} \
2 changes: 1 addition & 1 deletion assets/ascii/raspbian_small.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
${red}${green} .. ,.
${green} :oo: .:oo:
${green} 'o\\o o/o:
${green} 'o\o o/o:
${red} :: . :: . ::
${red}:: ::: ::: ::
${red}:' '',.'' ':
Expand Down
6 changes: 3 additions & 3 deletions assets/config-examples/config_cool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# The Percentage tag $%% is used for displaying the percentage between 2 numbers.\
# It **Must** contain a comma for separating the 2. They can be either be taken from a tag or it put yourself.\
# For example: $%50,100%
# For inverting colors of bad and great (red and green), before the last '%' put '!'
# For inverting colors of bad and great (red and green), before the first '%' put '!'
# without quotes ofc

# Little FAQ
Expand Down Expand Up @@ -94,8 +94,8 @@ layout = [
" ┃ ┃",
" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛",
"",
"$<builtin.colors_bg>", # normal colors
"$<builtin.colors_light_bg>" # light colors
"$<builtin.colors>", # normal colors
"$<builtin.colors_light>" # light colors
]

# display ascii-art or image/gif (GUI only) near layout
Expand Down
2 changes: 1 addition & 1 deletion assets/config-examples/config_simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# The Percentage tag $%% is used for displaying the percentage between 2 numbers.\
# It **Must** contain a comma for separating the 2. They can be either be taken from a tag or it put yourself.\
# For example: $%50,100%
# For inverting colors of bad and great (red and green), before the last '%' put '!'
# For inverting colors of bad and great (red and green), before the first '%' put '!'
# without quotes ofc

# Little FAQ
Expand Down
2 changes: 1 addition & 1 deletion assets/config-examples/nitch_like_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# The Percentage tag $%% is used for displaying the percentage between 2 numbers.\
# It **Must** contain a comma for separating the 2. They can be either be taken from a tag or it put yourself.\
# For example: $%50,100%
# For inverting colors of bad and great (red and green), before the last '%' put '!'
# For inverting colors of bad and great (red and green), before the first '%' put '!'
# without quotes ofc

# Little FAQ
Expand Down
10 changes: 9 additions & 1 deletion cufetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ layout = [
.br
For example: $%50,100%
.br
For inverting colors of bad and great (red and green), before the last '%' put '!' (without quotes ofc)
For inverting colors of bad and great (red and green), before the first '%' put '!' (without quotes ofc)
.PP
To escape any $ or bracket, just use \\
.SH OPTIONS
Expand Down Expand Up @@ -130,6 +130,11 @@ The font to be used in GUI mode (syntax must be "[FAMILY\-LIST] [STYLE\-OPTIONS]
.br
An example: "[Liberation Mono] [Normal] [12]", which can be "Liberation Mono Normal 12"
.TP
\fB\-i\fR, \fB\-\-image\-backend\fR <name>
\fB\fI(EXPERIMENTAL)\fR Image backend tool for displaying images in terminal. Right now only kitty is supported
.br
It's recommended to use GUI mode for the moment if something doesn't work
.TP
\fB\-g\fR, \fB\-\-gui\fR
Use GUI mode instead of priting in the terminal (use \fB\-V\fR to check if it's enabled)
.TP
Expand Down Expand Up @@ -171,6 +176,9 @@ Generate default config file to config folder (if path, it will generate to the
.br
Will ask for confirmation if file exists already
.TP
\fB\-\-kitty\fR
Alias to "--image-backend=kitty"
.TP
\fB\-\-color\fR <string>
Replace instances of a color with another value.
.br
Expand Down
21 changes: 15 additions & 6 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Config

// config file
std::vector<std::string> layout;
std::vector<std::string> percentage_colors;
std::string source_path;
std::string font;
std::string data_dir;
Expand Down Expand Up @@ -72,13 +73,13 @@ class Config
std::vector<std::string> m_arg_colors_name, m_arg_colors_value;

void loadConfigFile(const std::string_view filename, colors_t& colors);
std::string getThemeValue(const std::string& value, const std::string& fallback) const;
std::string getThemeValue(const std::string_view value, const std::string_view fallback) const;
void generateConfig(const std::string_view filename);

std::vector<std::string> getValueArrayStr(const std::string_view value, const std::vector<std::string>& fallback);

template <typename T>
T getValue(const std::string& value, const T&& fallback) const
T getValue(const std::string_view value, const T&& fallback) const
{
std::optional<T> ret = this->tbl.at_path(value).value<T>();
if constexpr (toml::is_string<T>) // if we want to get a value that's a string
Expand Down Expand Up @@ -130,15 +131,15 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
# Alternatively, ANSI escape codes can be used, e.g ${\e[1;32m} or ${\e[0;34m}.
# NOTE: 256-color ANSI escape codes (those that starts with \\[38 or \\[48) cannot be used in GUI mode.
#
# To reset colors, use ${0} for a full reset or ${1} for a bold reset.
# To reset colors, use ${0} for a normal reset or ${1} for a bold reset.
#
# To use the colors that the ascii art logo uses, use ${auto} for getting the 1st color, ${auto4} for the 4th one and so on.
# If you're using GUI mode and wants to display a custom source that's an image, all the auto colors will be the same colors as the distro ones
# The Percentage tag $%% is used for displaying the percentage between 2 numbers.\
# It **Must** contain a comma for separating the 2. They can be either be taken from a tag or it put yourself.\
# For example: $%50,100%
# For inverting colors of bad and great (red and green), before the last '%' put '!'
# For inverting colors of bad and great (red and green), before the first '%' put '!'
# without quotes ofc
# Little FAQ
Expand Down Expand Up @@ -175,8 +176,8 @@ layout = [
"${auto}GPU: $<gpu.vendor> $<gpu.name>",
"${auto}RAM: $<ram.ram>",
"",
"$<builtin.colors_bg>", # normal colors
"$<builtin.colors_light_bg>" # light colors
"$<builtin.colors>", # normal colors
"$<builtin.colors_light>" # light colors
]
# display ascii-art or image/gif (GUI only) near layout
Expand Down Expand Up @@ -234,6 +235,14 @@ magenta = "\e[1;35m"
cyan = "\e[1;36m"
white = "\e[1;37m"
# Colors to be used in percentage tag and modules members.
# They are used as if you're using the color tag.
# It's an array just for "convinience"
# 1st color for good
# 2nd color for normal
# 3rd color for bad
percentage-colors = ["green", "yellow", "red"]
# $<os.uptime> config
[os.uptime]
# how to display the name of the uptime
Expand Down
424 changes: 352 additions & 72 deletions include/pci.ids.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r
if (req_comp == img_n) return data;
STBI_ASSERT(req_comp >= 1 && req_comp <= 4);

good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
good = (stbi__uint16 *) stbi__malloc((size_t)req_comp * x * y * 2);
if (good == NULL) {
STBI_FREE(data);
return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
Expand Down
3 changes: 1 addition & 2 deletions include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::string name_from_entry(size_t dev_entry_pos);
std::string vendor_from_entry(size_t vendor_entry_pos, const std::string_view vendor_id);
std::string binarySearchPCIArray(const std::string_view vendor_id, const std::string_view pci_id);
std::string binarySearchPCIArray(const std::string_view vendor_id);
std::string shell_exec(const std::string_view cmd);
std::string read_shell_exec(const std::string_view cmd);
void getFileValue(u_short& iterIndex, const std::string_view line, std::string& str, const size_t& amount);
byte_units_t auto_devide_bytes(const size_t num);
bool is_file_image(const unsigned char* bytes);
Expand All @@ -72,7 +72,6 @@ std::string str_toupper(std::string str);
void strip(std::string& input);
std::string read_by_syspath(const std::string_view path);
fmt::rgb hexStringToColor(const std::string_view hexstr);
void shorten_vendor_name_inplace(std::string& vendor);
std::string shorten_vendor_name(std::string vendor);
std::string getHomeConfigDir();
std::string getConfigDir();
Expand Down
Loading

0 comments on commit 3b75a18

Please sign in to comment.