diff --git a/komorebi-bar/src/widgets/storage.rs b/komorebi-bar/src/widgets/storage.rs index 8c13d0b3..830e06f8 100644 --- a/komorebi-bar/src/widgets/storage.rs +++ b/komorebi-bar/src/widgets/storage.rs @@ -33,6 +33,8 @@ pub struct StorageConfig { /// Show removable disks #[cfg_attr(feature = "schemars", schemars(extend("default" = true)))] pub show_removable_disks: Option, + /// Storage display name + pub storage_display_name: Option, /// Select when the current percentage is over this value [[1-100]] pub auto_select_over: Option, /// Hide when the current percentage is under this value [[1-100]] @@ -48,6 +50,9 @@ impl From 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 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, auto_hide_under: Option, 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}%"), }, diff --git a/nix/komorebi-bar-options.nix b/nix/komorebi-bar-options.nix index 5780ae5b..07559ac2 100644 --- a/nix/komorebi-bar-options.nix +++ b/nix/komorebi-bar-options.nix @@ -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 ( diff --git a/nix/komorebi-options.nix b/nix/komorebi-options.nix index 06240b48..32659ffc 100644 --- a/nix/komorebi-options.nix +++ b/nix/komorebi-options.nix @@ -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 ( diff --git a/schema.bar.json b/schema.bar.json index 73e1e924..9d9aaebf 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -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",