Rename TimeSpace and CenterTime

Since you can now customize what widgets go in the center, the names of
these config options are no longer fitting. They are now renamed to
CenterSpace and CenterWidgets respectively.
This commit is contained in:
scorpion-26 2024-03-17 15:39:39 +01:00
parent 91532b952e
commit c5f2dd80c7
4 changed files with 48 additions and 19 deletions

View file

@ -98,18 +98,20 @@ Location: T
# *Always* make sure to enable SensorTooltips when enabling this option. Failure to do so *will* cause graphical issues. # *Always* make sure to enable SensorTooltips when enabling this option. Failure to do so *will* cause graphical issues.
IconsAlwaysUp: false IconsAlwaysUp: false
# Forces the time to be centered. # Forces the widgets in the center to be centered.
# This can cause the right widget to clip outside, if there is not enough space on screen (e.g. when opening the text) # This can cause the right widget to clip outside, if there is not enough space on screen (e.g. when opening the text)
# Setting this to false will definitely fix this issue, but it won't look very good, since it will be off-center. # Setting this to false will definitely fix this issue, but it won't look very good, since the widgets will be off-center.
# So try to decrease "TimeSpace" first, before setting this configuration to false. # So try to decrease "CenterSpace" first, before setting this configuration to false.
CenterTime: true # Legacy name: CenterTime
CenterWidgets: true
# How much space should be reserved for the time widget. Setting this too high can cause the right widget to clip outside. # How much space should be reserved for the center widgets. Setting this too high can cause the right widgets to clip outside.
# Therefore try to set it as low as possible if you experience clipping. # Therefore try to set it as low as possible if you experience clipping.
# Although keep in mind, that a value that is too low can cause the widget to be be off-center, # Although keep in mind, that a value that is too low can cause the widget to be be off-center,
# which can also cause clipping. # which can also cause clipping.
# If you can't find an optimal value, consider setting 'CenterTime' to false # If you can't find an optimal value, consider setting 'CenterWidgets' to false
TimeSpace: 300 # Legacy name: TimeSpace
CenterSpace: 300
# Set datetime style # Set datetime style
DateTimeStyle: %a %D - %H:%M:%S %Z DateTimeStyle: %a %D - %H:%M:%S %Z

View file

@ -1202,9 +1202,9 @@ namespace Bar
// This ensures that the center widget is centered. // This ensures that the center widget is centered.
bool topToBottom = Config::Get().location == 'L' || Config::Get().location == 'R'; bool topToBottom = Config::Get().location == 'L' || Config::Get().location == 'R';
int windowCenter = (topToBottom ? window.GetHeight() : window.GetWidth()) / 2; int windowCenter = (topToBottom ? window.GetHeight() : window.GetWidth()) / 2;
int endLeftWidgets = windowCenter - Config::Get().timeSpace / 2; int endLeftWidgets = windowCenter - Config::Get().centerSpace / 2;
if (!Config::Get().centerTime) if (!Config::Get().centerWidgets)
{ {
// Don't care if time is centered or not. // Don't care if time is centered or not.
endLeftWidgets = -1; endLeftWidgets = -1;
@ -1216,7 +1216,7 @@ namespace Bar
left->SetOrientation(Utils::GetOrientation()); left->SetOrientation(Utils::GetOrientation());
// For centerTime the width of the left widget handles the centering. // For centerTime the width of the left widget handles the centering.
// For not centerTime we want to set it as much right as possible. So let this expand as much as possible. // For not centerTime we want to set it as much right as possible. So let this expand as much as possible.
Utils::SetTransform(*left, {endLeftWidgets, !Config::Get().centerTime, Alignment::Left, 12, 0}); Utils::SetTransform(*left, {endLeftWidgets, !Config::Get().centerWidgets, Alignment::Left, 12, 0});
for (auto& widget : Config::Get().widgetsLeft) for (auto& widget : Config::Get().widgetsLeft)
{ {
@ -1226,7 +1226,7 @@ namespace Bar
auto center = Widget::Create<Box>(); auto center = Widget::Create<Box>();
center->SetClass("center"); center->SetClass("center");
center->SetOrientation(Utils::GetOrientation()); center->SetOrientation(Utils::GetOrientation());
Utils::SetTransform(*center, {(int)Config::Get().timeSpace, false, Alignment::Left}); Utils::SetTransform(*center, {(int)Config::Get().centerSpace, false, Alignment::Left});
center->SetSpacing({6, false}); center->SetSpacing({6, false});
for (auto& widget : Config::Get().widgetsCenter) for (auto& widget : Config::Get().widgetsCenter)

View file

@ -10,6 +10,18 @@ const Config& Config::Get()
return config; return config;
} }
void PrintLegacyVariable(const std::string_view& oldName, const std::string_view& newName)
{
LOG("Warning: Legacy variable \"" << oldName << "\" used.");
LOG(" Please consider switching to its new alias \"" << newName << "\" instead!");
}
void PrintLegacyNotation(const std::string_view& variableName, const std::string_view& newNotation)
{
LOG("Warning: Legacy notation for \"" << variableName << "\" used.");
LOG(" Please consider switching to its new alias \"" << newNotation << "\" instead!");
}
template<typename T> template<typename T>
void ApplyProperty(T& propertyToSet, const std::string_view& value); void ApplyProperty(T& propertyToSet, const std::string_view& value);
@ -271,7 +283,7 @@ void Config::Load(const std::string& overrideConfigLocation)
AddConfigVar("MicHighIcon", config.micHighIcon, lineView, foundProperty); AddConfigVar("MicHighIcon", config.micHighIcon, lineView, foundProperty);
AddConfigVar("PackageOutOfDateIcon", config.packageOutOfDateIcon, lineView, foundProperty); AddConfigVar("PackageOutOfDateIcon", config.packageOutOfDateIcon, lineView, foundProperty);
AddConfigVar("CenterTime", config.centerTime, lineView, foundProperty); AddConfigVar("CenterWidgets", config.centerWidgets, lineView, foundProperty);
AddConfigVar("AudioInput", config.audioInput, lineView, foundProperty); AddConfigVar("AudioInput", config.audioInput, lineView, foundProperty);
AddConfigVar("AudioRevealer", config.audioRevealer, lineView, foundProperty); AddConfigVar("AudioRevealer", config.audioRevealer, lineView, foundProperty);
AddConfigVar("AudioNumbers", config.audioNumbers, lineView, foundProperty); AddConfigVar("AudioNumbers", config.audioNumbers, lineView, foundProperty);
@ -289,7 +301,7 @@ void Config::Load(const std::string& overrideConfigLocation)
AddConfigVar("MaxDownloadBytes", config.maxDownloadBytes, lineView, foundProperty); AddConfigVar("MaxDownloadBytes", config.maxDownloadBytes, lineView, foundProperty);
AddConfigVar("CheckUpdateInterval", config.checkUpdateInterval, lineView, foundProperty); AddConfigVar("CheckUpdateInterval", config.checkUpdateInterval, lineView, foundProperty);
AddConfigVar("TimeSpace", config.timeSpace, lineView, foundProperty); AddConfigVar("CenterSpace", config.centerSpace, lineView, foundProperty);
AddConfigVar("NumWorkspaces", config.numWorkspaces, lineView, foundProperty); AddConfigVar("NumWorkspaces", config.numWorkspaces, lineView, foundProperty);
AddConfigVar("AudioScrollSpeed", config.audioScrollSpeed, lineView, foundProperty); AddConfigVar("AudioScrollSpeed", config.audioScrollSpeed, lineView, foundProperty);
AddConfigVar("SensorSize", config.sensorSize, lineView, foundProperty); AddConfigVar("SensorSize", config.sensorSize, lineView, foundProperty);
@ -307,21 +319,36 @@ void Config::Load(const std::string& overrideConfigLocation)
AddConfigVar("SNIDisabled", config.sniDisabled, lineView, foundProperty); AddConfigVar("SNIDisabled", config.sniDisabled, lineView, foundProperty);
// Modern map syntax // Modern map syntax
AddConfigVar("WorkspaceSymbol", config.workspaceSymbols, lineView, foundProperty); AddConfigVar("WorkspaceSymbol", config.workspaceSymbols, lineView, foundProperty);
// Legacy syntax
// Legacy WorkspaceSymbol
bool hasFoundProperty = false;
for (int i = 1; i < 10; i++) for (int i = 1; i < 10; i++)
{ {
// Subtract 1 to index from 1 to 9 rather than 0 to 8 // Subtract 1 to index from 1 to 9 rather than 0 to 8
std::string symbol; std::string symbol;
bool hasFoundProperty = foundProperty; hasFoundProperty = foundProperty;
AddConfigVar("WorkspaceSymbol-" + std::to_string(i), symbol, lineView, foundProperty); AddConfigVar("WorkspaceSymbol-" + std::to_string(i), symbol, lineView, foundProperty);
if (foundProperty && !hasFoundProperty) if (foundProperty && !hasFoundProperty)
{ {
config.workspaceSymbols[i] = symbol; config.workspaceSymbols[i] = symbol;
LOG("Warning: Legacy notation for WorkspaceSymbol used."); PrintLegacyNotation("WorkspaceSymbol", "WorkspaceSymbol: [number], [symbol]");
LOG(" Please consider switching to \"WorkspaceSymbol: [number], [symbol]!\"");
} }
} }
// Legacy center configuration (CenterTime, TimeSpace)
hasFoundProperty = foundProperty;
AddConfigVar("CenterTime", config.centerWidgets, lineView, foundProperty);
if (foundProperty && !hasFoundProperty)
{
PrintLegacyVariable("CenterTime", "CenterWidgets");
}
hasFoundProperty = foundProperty;
AddConfigVar("TimeSpace", config.centerSpace, lineView, foundProperty);
if (foundProperty && !hasFoundProperty)
{
PrintLegacyVariable("TimeSpace", "CenterSpace");
}
if (foundProperty == false) if (foundProperty == false)
{ {
LOG("Warning: unknown config var: " << lineView); LOG("Warning: unknown config var: " << lineView);

View file

@ -54,7 +54,7 @@ public:
std::string checkPackagesCommand = std::string checkPackagesCommand =
"p=\"$(checkupdates)\"; e=$?; if [ $e -eq 127 ] ; then exit 127; fi; if [ $e -eq 2 ] ; then echo \"0\" && exit 0; fi; echo \"$p\" | wc -l"; "p=\"$(checkupdates)\"; e=$?; if [ $e -eq 127 ] ; then exit 127; fi; if [ $e -eq 2 ] ; then echo \"0\" && exit 0; fi; echo \"$p\" | wc -l";
bool centerTime = true; bool centerWidgets = true; // Force the center widgets to be in the center.
bool audioRevealer = false; bool audioRevealer = false;
bool audioInput = false; bool audioInput = false;
bool audioNumbers = false; // Affects both audio sliders bool audioNumbers = false; // Affects both audio sliders
@ -74,7 +74,7 @@ public:
uint32_t audioScrollSpeed = 5; // 5% each scroll uint32_t audioScrollSpeed = 5; // 5% each scroll
uint32_t checkUpdateInterval = 5 * 60; // Interval to run the "checkPackagesCommand". In seconds uint32_t checkUpdateInterval = 5 * 60; // Interval to run the "checkPackagesCommand". In seconds
uint32_t timeSpace = 300; // How much time should be reserved for the time widget. uint32_t centerSpace = 300; // How much space should be reserved for the center widgets.
uint32_t numWorkspaces = 9; // How many workspaces to display uint32_t numWorkspaces = 9; // How many workspaces to display
uint32_t sensorSize = 24; // The size of the circular sensors uint32_t sensorSize = 24; // The size of the circular sensors
uint32_t networkIconSize = 24; // The size of the two network arrows uint32_t networkIconSize = 24; // The size of the two network arrows