bar/workspaces: add option for ws name capitalisation (#543)

This commit is contained in:
sweenu 2025-09-01 13:47:10 +02:00 committed by GitHub
parent 42f0f317ca
commit 1d5360d3f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -61,9 +61,10 @@ JsonObject {
property bool showWindowsOnSpecialWorkspaces: showWindows
property bool activeTrail: false
property bool perMonitorWorkspaces: true
property string label: " "
property string label: " " // if empty, will show workspace name's first letter
property string occupiedLabel: "󰮯"
property string activeLabel: "󰮯"
property string capitalisation: "preserve" // upper, lower, or preserve - relevant only if label is empty
}
component Tray: JsonObject {

View file

@ -36,7 +36,14 @@ ColumnLayout {
animate: true
text: {
const ws = Hypr.workspaces.values.find(w => w.id === root.ws);
const label = Config.bar.workspaces.label || (!ws || ws.name == root.ws ? root.ws : ws.name[0].toUpperCase());
const wsName = !ws || ws.name == root.ws ? root.ws : ws.name[0];
let displayName = wsName.toString();
if (Config.bar.workspaces.capitalisation.toLowerCase() === "upper") {
displayName = displayName.toUpperCase();
} else if (Config.bar.workspaces.capitalisation.toLowerCase() === "lower") {
displayName = displayName.toLowerCase();
}
const label = Config.bar.workspaces.label || displayName;
const occupiedLabel = Config.bar.workspaces.occupiedLabel || label;
const activeLabel = Config.bar.workspaces.activeLabel || (root.isOccupied ? occupiedLabel : label);
return root.activeWsId === root.ws ? activeLabel : root.isOccupied ? occupiedLabel : label;