Skip to content

Commit 9d5fbaa

Browse files
committed
core-modules: linux: fix ram/swap query + use MAGIC_LINE for themes
1 parent e3666f3 commit 9d5fbaa

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

include/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ layout = [
195195
#if !CF_ANDROID
196196
R"#(
197197
"${auto}Theme: $<theme.gtk.all.name>",
198-
"${auto}Icons: $<theme.gtk.all.icons>",
198+
"${auto}Icons: $<theme.gtk.all.icon>",
199199
"${auto}Font: $<theme.gtk.all.font>",
200200
"${auto}Cursor: $<theme.cursor>",
201201
"${auto}WM: $<user.wm.name>",

src/core-modules/linux/ram.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static double read_value(const std::string_view key)
3939

4040
free(line);
4141
rewind(meminfo);
42-
return std::stod(result);
42+
return std::stod(result) * 1024.0f;
4343
}
4444

4545
double ram_free()

src/core-modules/linux/theme.cc

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static std::string get_xsettings_xfce4(const std::string_view property, const st
5454
const std::string& path = configDir + "/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml";
5555
std::ifstream f(path, std::ios::in);
5656
if (!f.is_open())
57-
return UNKNOWN;
57+
return MAGIC_LINE;
5858

5959
buffer.assign(std::istreambuf_iterator<char>{ f }, std::istreambuf_iterator<char>());
6060
buffer.push_back('\0');
@@ -75,7 +75,7 @@ static std::string get_xsettings_xfce4(const std::string_view property, const st
7575
return node2->first_attribute("value")->value();
7676
}
7777

78-
return UNKNOWN;
78+
return MAGIC_LINE;
7979
}
8080

8181
static std::string get_auto_gtk_format(const std::string_view gtk2, const std::string_view gtk3,
@@ -125,7 +125,7 @@ static std::string get_auto_gtk_format(const std::string_view gtk2, const std::s
125125
//
126126
static CursorInfo get_cursor_xresources()
127127
{
128-
std::string cursor_name{ UNKNOWN }, cursor_size{ UNKNOWN };
128+
std::string cursor_name{ MAGIC_LINE }, cursor_size{ MAGIC_LINE };
129129
const std::string& path = expandVar("~/.Xresources");
130130
std::ifstream f(path, std::ios::in);
131131
if (!f.is_open())
@@ -153,11 +153,11 @@ static CursorInfo get_cursor_xresources()
153153

154154
static CursorInfo get_cursor_dconf()
155155
{
156-
std::string cursor{ UNKNOWN }, cursor_size{ UNKNOWN };
156+
std::string cursor{ MAGIC_LINE }, cursor_size{ MAGIC_LINE };
157157
#if USE_DCONF
158158
void* handle = LOAD_LIBRARY("libdconf.so");
159159
if (!handle)
160-
return { UNKNOWN, UNKNOWN };
160+
return { MAGIC_LINE, MAGIC_LINE };
161161

162162
LOAD_LIB_SYMBOL(handle, DConfClient*, dconf_client_new, void);
163163
LOAD_LIB_SYMBOL(handle, GVariant*, dconf_client_read, DConfClient*, const char*);
@@ -182,7 +182,7 @@ static CursorInfo get_cursor_dconf()
182182
static CursorInfo get_cursor_gsettings()
183183
{
184184
const CursorInfo& dconf = get_cursor_dconf();
185-
if (dconf != CursorInfo{ UNKNOWN, UNKNOWN })
185+
if (dconf != CursorInfo{ MAGIC_LINE, MAGIC_LINE })
186186
return dconf;
187187

188188
std::string cursor;
@@ -194,15 +194,15 @@ static CursorInfo get_cursor_gsettings()
194194
cursor_size.erase(std::remove(cursor_size.begin(), cursor_size.end(), '\''), cursor_size.end());
195195

196196
if (cursor.empty())
197-
cursor = UNKNOWN;
197+
cursor = MAGIC_LINE;
198198
if (cursor_size.empty())
199-
cursor_size = UNKNOWN;
199+
cursor_size = MAGIC_LINE;
200200
return { cursor, cursor_size };
201201
}
202202

203203
static CursorInfo get_gtk_cursor_config(const std::string_view path)
204204
{
205-
std::string cursor{ UNKNOWN }, cursor_size{ UNKNOWN };
205+
std::string cursor{ MAGIC_LINE }, cursor_size{ MAGIC_LINE };
206206
std::ifstream f(path.data(), std::ios::in);
207207
if (!f.is_open())
208208
return { cursor, cursor_size };
@@ -233,10 +233,10 @@ static CursorInfo get_cursor_from_gtk_configs(const std::uint8_t ver)
233233
for (const std::string& path : paths)
234234
{
235235
const CursorInfo& result = get_gtk_cursor_config(path);
236-
if (result != CursorInfo{ UNKNOWN, UNKNOWN })
236+
if (result != CursorInfo{ MAGIC_LINE, MAGIC_LINE })
237237
return result;
238238
}
239-
return { UNKNOWN, UNKNOWN };
239+
return { MAGIC_LINE, MAGIC_LINE };
240240
}
241241

242242
static CursorInfo get_de_cursor(const std::string_view de_name)
@@ -250,7 +250,7 @@ static CursorInfo get_de_cursor(const std::string_view de_name)
250250
return { get_xsettings_xfce4("Gtk", "CursorThemeName"), get_xsettings_xfce4("Gtk", "CursorThemeSize") };
251251
}
252252
}
253-
return { UNKNOWN, UNKNOWN };
253+
return { MAGIC_LINE, MAGIC_LINE };
254254
}
255255

256256
//
@@ -259,7 +259,7 @@ static CursorInfo get_de_cursor(const std::string_view de_name)
259259
//
260260
static ThemeInfo get_gtk_theme_config(const std::string_view path)
261261
{
262-
std::string theme{ UNKNOWN }, icon_theme{ UNKNOWN }, font{ UNKNOWN };
262+
std::string theme{ MAGIC_LINE }, icon_theme{ MAGIC_LINE }, font{ MAGIC_LINE };
263263
std::ifstream f(path.data(), std::ios::in);
264264
if (!f.is_open())
265265
return { theme, icon_theme, font };
@@ -283,7 +283,7 @@ static ThemeInfo get_gtk_theme_config(const std::string_view path)
283283

284284
static ThemeInfo get_gtk_theme_dconf()
285285
{
286-
std::string theme{ UNKNOWN }, icon_theme{ UNKNOWN }, font{ UNKNOWN };
286+
std::string theme{ MAGIC_LINE }, icon_theme{ MAGIC_LINE }, font{ MAGIC_LINE };
287287
#if USE_DCONF
288288
void* handle = LOAD_LIBRARY("libdconf.so");
289289
if (!handle)
@@ -316,7 +316,7 @@ static ThemeInfo get_gtk_theme_dconf()
316316
static ThemeInfo get_gtk_theme_gsettings()
317317
{
318318
const ThemeInfo& dconf = get_gtk_theme_dconf();
319-
if (dconf != ThemeInfo{ UNKNOWN, UNKNOWN, UNKNOWN })
319+
if (dconf != ThemeInfo{ MAGIC_LINE, MAGIC_LINE, MAGIC_LINE })
320320
return dconf;
321321

322322
std::string theme, icon_theme, font;
@@ -331,11 +331,11 @@ static ThemeInfo get_gtk_theme_gsettings()
331331
font.erase(std::remove(font.begin(), font.end(), '\''), font.end());
332332

333333
if (theme.empty())
334-
theme = UNKNOWN;
334+
theme = MAGIC_LINE;
335335
if (icon_theme.empty())
336-
icon_theme = UNKNOWN;
336+
icon_theme = MAGIC_LINE;
337337
if (font.empty())
338-
font = UNKNOWN;
338+
font = MAGIC_LINE;
339339
return { theme, icon_theme, font };
340340
}
341341

@@ -351,7 +351,7 @@ static ThemeInfo get_gtk_theme_from_configs(const std::uint8_t ver)
351351
for (const auto& path : paths)
352352
{
353353
const ThemeInfo& result = get_gtk_theme_config(path);
354-
if (result != ThemeInfo{ UNKNOWN, UNKNOWN, UNKNOWN })
354+
if (result != ThemeInfo{ MAGIC_LINE, MAGIC_LINE, MAGIC_LINE })
355355
return result;
356356
}
357357
return get_gtk_theme_gsettings();
@@ -386,7 +386,7 @@ MODFUNC(theme_gtk_name)
386386

387387
const ThemeInfo& result = is_tty ? get_gtk_theme_from_configs(ver) : get_de_gtk_theme(wmde_name, ver);
388388

389-
return result[THEME_NAME] == UNKNOWN ? MAGIC_LINE : result[THEME_NAME];
389+
return result[THEME_NAME];
390390
}
391391

392392
MODFUNC(theme_gtk_icon)
@@ -400,7 +400,7 @@ MODFUNC(theme_gtk_icon)
400400

401401
const ThemeInfo& result = is_tty ? get_gtk_theme_from_configs(ver) : get_de_gtk_theme(wmde_name, ver);
402402

403-
return result[THEME_ICON] == UNKNOWN ? MAGIC_LINE : result[THEME_ICON];
403+
return result[THEME_ICON];
404404
}
405405

406406
MODFUNC(theme_gtk_font)
@@ -414,7 +414,7 @@ MODFUNC(theme_gtk_font)
414414

415415
const ThemeInfo& result = is_tty ? get_gtk_theme_from_configs(ver) : get_de_gtk_theme(wmde_name, ver);
416416

417-
return result[THEME_FONT] == UNKNOWN ? MAGIC_LINE : result[THEME_FONT];
417+
return result[THEME_FONT];
418418
}
419419

420420
MODFUNC(theme_gtk_all_name)
@@ -447,31 +447,31 @@ MODFUNC(theme_gtk_all_font)
447447
MODFUNC(theme_gsettings_name)
448448
{
449449
const ThemeInfo& result = get_gtk_theme_gsettings();
450-
return result[THEME_NAME] == UNKNOWN ? MAGIC_LINE : result[THEME_NAME];
450+
return result[THEME_NAME];
451451
}
452452

453453
MODFUNC(theme_gsettings_icon)
454454
{
455455
const ThemeInfo& result = get_gtk_theme_gsettings();
456-
return result[THEME_ICON] == UNKNOWN ? MAGIC_LINE : result[THEME_ICON];
456+
return result[THEME_ICON];
457457
}
458458

459459
MODFUNC(theme_gsettings_font)
460460
{
461461
const ThemeInfo& result = get_gtk_theme_gsettings();
462-
return result[THEME_FONT] == UNKNOWN ? MAGIC_LINE : result[THEME_FONT];
462+
return result[THEME_FONT];
463463
}
464464

465465
MODFUNC(theme_gsettings_cursor_name)
466466
{
467467
const CursorInfo& result = get_cursor_gsettings();
468-
return result[CURSOR_NAME] == UNKNOWN ? MAGIC_LINE : result[CURSOR_NAME];
468+
return result[CURSOR_NAME];
469469
}
470470

471471
MODFUNC(theme_gsettings_cursor_size)
472472
{
473473
const CursorInfo& result = get_cursor_gsettings();
474-
return result[CURSOR_SIZE] == UNKNOWN ? MAGIC_LINE : result[CURSOR_SIZE];
474+
return result[CURSOR_SIZE];
475475
}
476476

477477
const std::array<std::function<CursorInfo()>, 6> funcs{
@@ -490,11 +490,11 @@ MODFUNC(theme_cursor_name)
490490
for (const auto& method : funcs)
491491
{
492492
result = method();
493-
if (result != CursorInfo{ UNKNOWN, UNKNOWN })
493+
if (result != CursorInfo{ MAGIC_LINE, MAGIC_LINE })
494494
break;
495495
}
496496

497-
if (result[CURSOR_NAME] == UNKNOWN)
497+
if (result[CURSOR_NAME] == MAGIC_LINE)
498498
return MAGIC_LINE;
499499

500500
std::string& cursor_name = result[CURSOR_NAME];
@@ -514,11 +514,11 @@ MODFUNC(theme_cursor_size)
514514
for (const auto& method : funcs)
515515
{
516516
result = method();
517-
if (result != CursorInfo{ UNKNOWN, UNKNOWN })
517+
if (result != CursorInfo{ MAGIC_LINE, MAGIC_LINE })
518518
break;
519519
}
520520

521-
if (result[CURSOR_SIZE] == UNKNOWN)
521+
if (result[CURSOR_SIZE] == MAGIC_LINE)
522522
return MAGIC_LINE;
523523

524524
std::string& cursor_size = result[CURSOR_SIZE];

0 commit comments

Comments
 (0)