Skip to content

Commit 412e587

Browse files
committed
parse: add $<user.sep_title>
Yeah I'm back from the shitty 3 days, needs to take some break sometimes
1 parent 41f859f commit 412e587

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

.clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ TabWidth: 4
1919
UseTab: Never
2020

2121
# Bracing styles
22+
BreakBeforeBraces: Custom
2223
BraceWrapping:
24+
AfterCaseLabel: true
2325
AfterClass: true
2426
AfterControlStatement: true
2527
AfterEnum: true
@@ -60,7 +62,6 @@ ReflowComments: true
6062
AllowShortIfStatementsOnASingleLine: false
6163
AllowShortLoopsOnASingleLine: false
6264
AllowShortFunctionsOnASingleLine: All
63-
BreakBeforeBraces: Allman
6465
IndentCaseLabels: true
6566

6667
AlignConsecutiveShortCaseStatements:

include/config.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Config
4040
std::string font;
4141
std::string data_dir;
4242
std::string sep_reset;
43+
std::string user_sep_title;
4344
std::string gui_bg_image;
4445
std::string ascii_logo_type;
4546
std::uint16_t offset = 0;
@@ -118,7 +119,7 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
118119
119120
layout = [
120121
"${auto}$<user.name>${0}@${auto2}$<os.hostname>",
121-
"───────────────────────────",
122+
"$<user.sep_title>",
122123
"${auto}OS: $<os.name> $<system.arch>",
123124
"${auto}Host: $<system.host>",
124125
"${auto}Kernel: $<os.kernel>",
@@ -158,7 +159,10 @@ data-dir = "/usr/share/customfetch"
158159
# Leave empty it for regular.
159160
ascii-logo-type = ""
160161
161-
# A separetor (string) that when ecountered, will automatically
162+
# A char (or string) to use in $<user.title_sep>
163+
sep-title = "-"
164+
165+
# A separetor (or string) that when ecountered, will automatically
162166
# reset color, aka. automatically add ${0} (only in layout)
163167
# Make it empty for disabling
164168
sep-reset = ":"

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ void Config::loadConfigFile(const std::string_view filename, colors_t& colors)
5151
this->gui_bg_image = this->getValue<std::string>("gui.bg-image", "disable");
5252
this->logo_padding_top = this->getValue<std::uint16_t>("config.logo-padding-top", 0);
5353

54+
this->user_sep_title = this->getValue<std::string>("config.sep-title", "-");
55+
5456
this->uptime_d_fmt = this->getValue<std::string>("os.uptime.days", " days");
5557
this->uptime_h_fmt = this->getValue<std::string>("os.uptime.hours", " hours");
5658
this->uptime_m_fmt = this->getValue<std::string>("os.uptime.mins", " mins");

src/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void modules_list()
8080
{
8181
fmt::println(R"(
8282
Syntax:
83-
# comments of the module
83+
# maybe comments of the module
8484
module
8585
member : description [example of what it prints, maybe another]
8686
@@ -105,7 +105,13 @@ os
105105
initsys_name : Init system name [systemd]
106106
initsys_version: Init system version [256.5-1-arch]
107107
108+
# you may ask, why is there a sep_title but no title???
109+
# well, it's kinda a "bug" or "regression" in my spaghetti code.
110+
# It has more to do with coloring than actually implementing it.
111+
# I won't rework the whole codebase for one single line,
112+
# and it's already written in the default config
108113
user
114+
sep_title : the separator between the title and the system infos (with the title lenght) [--------]
109115
name : name you are currently logged in (not real name) [toni69]
110116
shell : login shell name and version [zsh 5.9]
111117
shell_name : login shell [zsh]

src/parse.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co
630630
{
631631
switch (moduleValue_hash)
632632
{
633+
case "sep_title"_fnv1a16:
634+
{
635+
Query::System query_system;
636+
const size_t& title_len = fmt::format("{}@{}", query_user.name(), query_system.hostname()).length();
637+
std::string str;
638+
str.reserve(config.user_sep_title.length() * title_len);
639+
for (size_t i = 0; i < title_len; i++)
640+
str += config.user_sep_title;
641+
642+
SYSINFO_INSERT(str);
643+
} break;
644+
633645
case "name"_fnv1a16: SYSINFO_INSERT(query_user.name()); break;
634646

635647
case "shell"_fnv1a16:

0 commit comments

Comments
 (0)