mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
Add workspace symbol configuration (#2)
Also added an example line to the config at data/config. Config syntax is: "WorkspaceSymbol-[workspace_number]: [symbol]". If no default is provided it will default to the circle with dot.
This commit is contained in:
parent
75527924c4
commit
7c7c58f384
4 changed files with 29 additions and 5 deletions
|
@ -3,3 +3,5 @@ SuspendCommand: ~/.config/scripts/sys.sh suspend
|
||||||
LockCommand: ~/.config/scripts/sys.sh lock
|
LockCommand: ~/.config/scripts/sys.sh lock
|
||||||
ExitCommand: killall Hyprland
|
ExitCommand: killall Hyprland
|
||||||
BatteryFolder: /sys/class/power_supply/BAT1
|
BatteryFolder: /sys/class/power_supply/BAT1
|
||||||
|
WorkspaceSymbol-1:
|
||||||
|
DefaultWorkspaceSymbol:
|
||||||
|
|
|
@ -170,25 +170,21 @@ namespace Bar
|
||||||
{
|
{
|
||||||
case System::WorkspaceStatus::Dead:
|
case System::WorkspaceStatus::Dead:
|
||||||
workspaces[i]->SetClass("ws-dead");
|
workspaces[i]->SetClass("ws-dead");
|
||||||
workspaces[i]->SetText(" ");
|
|
||||||
break;
|
break;
|
||||||
case System::WorkspaceStatus::Inactive:
|
case System::WorkspaceStatus::Inactive:
|
||||||
workspaces[i]->SetClass("ws-inactive");
|
workspaces[i]->SetClass("ws-inactive");
|
||||||
workspaces[i]->SetText(" ");
|
|
||||||
break;
|
break;
|
||||||
case System::WorkspaceStatus::Visible:
|
case System::WorkspaceStatus::Visible:
|
||||||
workspaces[i]->SetClass("ws-visible");
|
workspaces[i]->SetClass("ws-visible");
|
||||||
workspaces[i]->SetText(" ");
|
|
||||||
break;
|
break;
|
||||||
case System::WorkspaceStatus::Current:
|
case System::WorkspaceStatus::Current:
|
||||||
workspaces[i]->SetClass("ws-current");
|
workspaces[i]->SetClass("ws-current");
|
||||||
workspaces[i]->SetText(" ");
|
|
||||||
break;
|
break;
|
||||||
case System::WorkspaceStatus::Active:
|
case System::WorkspaceStatus::Active:
|
||||||
workspaces[i]->SetClass("ws-active");
|
workspaces[i]->SetClass("ws-active");
|
||||||
workspaces[i]->SetText(" ");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
workspaces[i]->SetText(System::GetWorkspaceSymbol(i));
|
||||||
}
|
}
|
||||||
return TimerResult::Ok;
|
return TimerResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace System
|
||||||
std::string lockCommand = ""; // idk, no standard way of doing this.
|
std::string lockCommand = ""; // idk, no standard way of doing this.
|
||||||
std::string exitCommand = ""; // idk, no standard way of doing this.
|
std::string exitCommand = ""; // idk, no standard way of doing this.
|
||||||
std::string batteryFolder = ""; // this can be BAT0, BAT1, etc. Usually in /sys/class/power_supply
|
std::string batteryFolder = ""; // this can be BAT0, BAT1, etc. Usually in /sys/class/power_supply
|
||||||
|
std::vector<std::string> workspaceSymbols = std::vector<std::string>(9, "");
|
||||||
|
std::string defaultWorkspaceSymbol = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
static Config config;
|
static Config config;
|
||||||
|
@ -74,6 +76,17 @@ namespace System
|
||||||
{
|
{
|
||||||
prop = &config.batteryFolder;
|
prop = &config.batteryFolder;
|
||||||
}
|
}
|
||||||
|
else if (line.find("DefaultWorkspaceSymbol") != std::string::npos) {
|
||||||
|
prop = &config.defaultWorkspaceSymbol;
|
||||||
|
}
|
||||||
|
else if (line.find("WorkspaceSymbol") != std::string::npos) {
|
||||||
|
for (int i = 1; i < 10; i++) {
|
||||||
|
if (line.find("WorkspaceSymbol-" + std::to_string(i)) != std::string::npos) {
|
||||||
|
// Subtract 1 to index from 1 to 9 rather than 0 to 8
|
||||||
|
prop = &(config.workspaceSymbols[i - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (prop == nullptr)
|
if (prop == nullptr)
|
||||||
{
|
{
|
||||||
LOG("Warning: unknown config var: " << line);
|
LOG("Warning: unknown config var: " << line);
|
||||||
|
@ -451,6 +464,18 @@ namespace System
|
||||||
{
|
{
|
||||||
return Hyprland::Goto(workspace);
|
return Hyprland::Goto(workspace);
|
||||||
}
|
}
|
||||||
|
std::string GetWorkspaceSymbol(int index) {
|
||||||
|
if (index < 0 || index > 9) {
|
||||||
|
LOG("Workspace Symbol Index Out Of Bounds: " + std::to_string(index));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.workspaceSymbols[index].empty()) {
|
||||||
|
return config.defaultWorkspaceSymbol + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return config.workspaceSymbols[index] + " ";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string GetTime()
|
std::string GetTime()
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace System
|
||||||
};
|
};
|
||||||
WorkspaceStatus GetWorkspaceStatus(uint32_t monitor, uint32_t workspace);
|
WorkspaceStatus GetWorkspaceStatus(uint32_t monitor, uint32_t workspace);
|
||||||
void GotoWorkspace(uint32_t workspace);
|
void GotoWorkspace(uint32_t workspace);
|
||||||
|
std::string GetWorkspaceSymbol(int index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string GetTime();
|
std::string GetTime();
|
||||||
|
|
Loading…
Reference in a new issue