Implement ability to disable certain SNI icons

Implements https://github.com/scorpion-26/gBar/issues/69 (nice)
This commit is contained in:
scorpion-26 2023-12-03 22:48:31 +01:00
parent 37b0896d6d
commit 0e8634a227
4 changed files with 20 additions and 0 deletions

View file

@ -165,7 +165,9 @@ EnableSNI: true
# SNIIconSize sets the icon size for a SNI icon.
# SNIPaddingTop Can be used to push the Icon down. Negative values are allowed
# SNIIconName overrides what icon from an icon theme to display.
# SNIDisabled prevents an icon from being registered.
# For all SNI properties: The first parameter is a filter of the tooltip(The text that pops up, when the icon is hovered) of the icon.
# The wildcard filter '*' does not work for SNIIconName and SNIDisabled
# Scale everything down to 25 pixels ('*' as filter means everything)
#SNIIconSize: *, 25
@ -175,6 +177,8 @@ EnableSNI: true
#SNIPaddingTop: Discord, 5
# Override the default icon given to gBar by discord to an icon theme supplied one (Example is from papirus theme)
#SNIIconName: Discord, discord-tray
# Prevents steam from displaying. Note: Steam doesn't have a tooltip, which means the object path is filtered instead.
#SNIDisabled: steam, true
# These set the range for the network widget. The widget changes colors at six intervals:
# - Below Min...Bytes ("under")

View file

@ -299,6 +299,7 @@ void Config::Load()
AddConfigVar("SNIIconSize", config.sniIconSizes, lineView, foundProperty);
AddConfigVar("SNIPaddingTop", config.sniPaddingTop, lineView, foundProperty);
AddConfigVar("SNIIconName", config.sniIconNames, lineView, foundProperty);
AddConfigVar("SNIDisabled", config.sniDisabled, lineView, foundProperty);
// Modern map syntax
AddConfigVar("WorkspaceSymbol", config.workspaceSymbols, lineView, foundProperty);
// Legacy syntax

View file

@ -85,6 +85,7 @@ public:
std::unordered_map<std::string, uint32_t> sniIconSizes;
std::unordered_map<std::string, int32_t> sniPaddingTop;
std::unordered_map<std::string, std::string> sniIconNames;
std::unordered_map<std::string, bool> sniDisabled;
// Only affects outputs (i.e.: speakers, not microphones). This remaps the range of the volume; In percent
double audioMinVolume = 0.f; // Map the minimum volume to this value

View file

@ -166,8 +166,22 @@ namespace SNI
}
bool wasExplicitOverride = false;
for (auto& [filter, disabled] : Config::Get().sniDisabled)
{
if (ItemMatchesFilter(item, filter, wasExplicitOverride))
{
if (disabled)
{
LOG("SNI: Disabling item due to config");
// We're done here.
return item;
}
}
}
// First try icon theme querying
std::string iconName;
wasExplicitOverride = false;
for (auto& [filter, name] : Config::Get().sniIconNames)
{
if (ItemMatchesFilter(item, filter, wasExplicitOverride))