feat(bar): add storage_display_name option

This commit implements this feature as it was added in
LGUG2Z/komorebi@c84fa50fc9.
This commit is contained in:
LGUG2Z committed 2026-03-29 15:22:29 -07:00
1 parent 24878dc3a4
commit a17a39ea3b
4 files changed
+124 -45

No files matched your search

+31 -1
View File
@@ -33,6 +33,8 @@ pub struct StorageConfig {
/// Show removable disks
#[cfg_attr(feature = "schemars", schemars(extend("default" = true)))]
pub show_removable_disks: Option<bool>,
/// Storage display name
pub storage_display_name: Option<StorageDisplayName>,
/// Select when the current percentage is over this value [[1-100]]
pub auto_select_over: Option<u8>,
/// Hide when the current percentage is under this value [[1-100]]
@@ -48,6 +50,9 @@ impl From<StorageConfig> for Storage {
label_prefix: value.label_prefix.unwrap_or(LabelPrefix::IconAndText),
show_read_only_disks: value.show_read_only_disks.unwrap_or(false),
show_removable_disks: value.show_removable_disks.unwrap_or(true),
storage_display_name: value
.storage_display_name
.unwrap_or(StorageDisplayName::Mount),
auto_select_over: value.auto_select_over.map(|o| o.clamp(1, 100)),
auto_hide_under: value.auto_hide_under.map(|o| o.clamp(1, 100)),
last_updated: Instant::now(),
@@ -55,6 +60,19 @@ impl From<StorageConfig> for Storage {
}
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum StorageDisplayName {
/// Display label as mount point eg. /
Mount,
/// Display label as name eg. Macintosh HD
Name,
/// Display label as mount then name eg. / Macintosh HD
MountAndName,
/// Display label as name then mount eg. Macintosh HD /
NameAndMount,
}
struct StorageDisk {
label: String,
selected: bool,
@@ -67,6 +85,7 @@ pub struct Storage {
label_prefix: LabelPrefix,
show_read_only_disks: bool,
show_removable_disks: bool,
storage_display_name: StorageDisplayName,
auto_select_over: Option<u8>,
auto_hide_under: Option<u8>,
last_updated: Instant,
@@ -90,6 +109,17 @@ impl Storage {
continue;
}
let mount = disk.mount_point();
let name = disk.name();
let display_name = match self.storage_display_name {
StorageDisplayName::Mount => mount.to_string_lossy(),
StorageDisplayName::Name => name.to_string_lossy(),
StorageDisplayName::MountAndName => {
mount.to_string_lossy() + name.to_string_lossy()
}
StorageDisplayName::NameAndMount => {
name.to_string_lossy() + mount.to_string_lossy()
}
};
let total = disk.total_space();
let available = disk.available_space();
let used = total - available;
@@ -103,7 +133,7 @@ impl Storage {
disks.push(StorageDisk {
label: match self.label_prefix {
LabelPrefix::Text | LabelPrefix::IconAndText => {
format!("{} {}%", mount.to_string_lossy(), percentage)
format!("{} {}%", display_name, percentage)
}
LabelPrefix::None | LabelPrefix::Icon => format!("{percentage}%"),
},
+25 -11
View File
@@ -704,6 +704,20 @@ let
default = true;
description = "Show removable disks";
};
storage_display_name = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Mount"
"Name"
"MountAndName"
"NameAndMount"
]
)
);
default = null;
description = "Storage display name";
};
};
}
)
@@ -1262,6 +1276,17 @@ in
);
default = null;
};
auto_select_fill = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
colours = lib.mkOption {
type = (
lib.types.nullOr (
@@ -1337,17 +1362,6 @@ in
);
default = null;
};
auto_select_fill = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
accent = lib.mkOption {
type = (
lib.types.nullOr (
+33 -33
View File
@@ -788,17 +788,6 @@ in
]
);
};
monocle_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
colours = lib.mkOption {
type = (
lib.types.nullOr (
@@ -874,6 +863,17 @@ in
);
default = null;
};
unfocused_locked_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
bar_accent = lib.mkOption {
type = (
lib.types.nullOr (
@@ -885,6 +885,28 @@ in
);
default = null;
};
monocle_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
stack_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
floating_border = lib.mkOption {
type = (
lib.types.nullOr (
@@ -907,28 +929,6 @@ in
);
default = null;
};
unfocused_locked_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
stack_border = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
(lib.types.nullOr catppuccinValue)
(lib.types.nullOr base16Value)
]
)
);
default = null;
};
name = lib.mkOption {
type = (
lib.types.nullOr (
+35
View File
@@ -3434,12 +3434,47 @@
"null"
],
"default": true
},
"storage_display_name": {
"description": "Storage display name",
"anyOf": [
{
"$ref": "#/$defs/StorageDisplayName"
},
{
"type": "null"
}
]
}
},
"required": [
"enable"
]
},
"StorageDisplayName": {
"oneOf": [
{
"description": "Display label as mount point eg. /",
"type": "string",
"const": "Mount"
},
{
"description": "Display label as name eg. Macintosh HD",
"type": "string",
"const": "Name"
},
{
"description": "Display label as mount then name eg. / Macintosh HD",
"type": "string",
"const": "MountAndName"
},
{
"description": "Display label as name then mount eg. Macintosh HD /",
"type": "string",
"const": "NameAndMount"
}
]
},
"TimeConfig": {
"description": "Time widget configuration",
"type": "object",