mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
SNI: Allow IconPath to be empty
Fixes network-manager-applet
This commit is contained in:
parent
7567465454
commit
18f3e123ed
2 changed files with 26 additions and 1 deletions
15
src/Common.h
15
src/Common.h
|
@ -2,6 +2,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
@ -82,6 +83,20 @@ namespace Utils
|
||||||
snprintf(buf, sizeof(buf), fmt, bytes, "B");
|
snprintf(buf, sizeof(buf), fmt, bytes, "B");
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string FindFileWithName(const std::string& directory, const std::string& name, const std::string& extension)
|
||||||
|
{
|
||||||
|
for (auto& path : std::filesystem::recursive_directory_iterator(directory))
|
||||||
|
{
|
||||||
|
if (path.is_directory())
|
||||||
|
continue;
|
||||||
|
if (path.path().filename().string().find(name) != std::string::npos && path.path().extension().string() == extension)
|
||||||
|
{
|
||||||
|
return path.path().string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Process
|
struct Process
|
||||||
|
|
12
src/SNI.cpp
12
src/SNI.cpp
|
@ -2,6 +2,7 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Widget.h"
|
#include "Widget.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
#ifdef WITH_SNI
|
#ifdef WITH_SNI
|
||||||
|
|
||||||
|
@ -136,7 +137,16 @@ namespace SNI
|
||||||
|
|
||||||
const char* themePath = g_variant_get_string(themePathStr, nullptr);
|
const char* themePath = g_variant_get_string(themePathStr, nullptr);
|
||||||
const char* iconName = g_variant_get_string(iconNameStr, nullptr);
|
const char* iconName = g_variant_get_string(iconNameStr, nullptr);
|
||||||
iconPath = std::string(themePath) + "/" + iconName + ".png"; // TODO: Find out if this is always png
|
if (strlen(themePath) == 0)
|
||||||
|
{
|
||||||
|
// Nothing defined, look in /usr/share/icons
|
||||||
|
// network-manager-applet does this
|
||||||
|
iconPath = Utils::FindFileWithName("/usr/share/icons", iconName, ".png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iconPath = std::string(themePath) + "/" + iconName + ".png"; // TODO: Find out if this is always png
|
||||||
|
}
|
||||||
|
|
||||||
g_variant_unref(themePathVariant);
|
g_variant_unref(themePathVariant);
|
||||||
g_variant_unref(themePathStr);
|
g_variant_unref(themePathStr);
|
||||||
|
|
Loading…
Reference in a new issue