diff --git a/docs/modules/Clock.md b/docs/modules/Clock.md index 28630ffa..627be83b 100644 --- a/docs/modules/Clock.md +++ b/docs/modules/Clock.md @@ -13,6 +13,7 @@ Clicking on the widget opens a popup with the time and a calendar. | `format` | `string` | `%d/%m/%Y %H:%M` | Date/time format string. Pango markup is supported. | | `format_popup` | `string` | `%H:%M:%S` | Date/time format string to display in the popup header. Pango markup is supported. | | `locale` | `string` | `$LC_TIME` or `$LANG` or `'POSIX'` | Locale to use (eg `en_GB`). Defaults to the system language (reading from env var). | +| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the time on the clock button. | > Detail on available tokens can be found here: diff --git a/docs/modules/Custom.md b/docs/modules/Custom.md index 4d9a44b0..f9e718fb 100644 --- a/docs/modules/Custom.md +++ b/docs/modules/Custom.md @@ -57,6 +57,7 @@ A text label. Pango markup is supported. | Name | Type | Default | Description | |---------|-------------------------------------------------|---------|---------------------------------------------------------------------| | `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Widget text label. Pango markup and embedded scripts are supported. | +| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the label. | #### Button @@ -69,6 +70,7 @@ A clickable button, which can run a command when clicked. | `label` | [Dynamic String](dynamic-values#dynamic-string) | `null` | Widget text label. Pango markup and embedded scripts are supported. Ignored if `widgets` is set. | | `widgets` | `(Module or Widget)[]` | `[]` | List of modules/widgets to add to this button. | | `on_click` | `string [command]` | `null` | Command to execute. More on this [below](#commands). | +| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the button. | #### Image diff --git a/docs/modules/Sys-Info.md b/docs/modules/Sys-Info.md index 232c802f..d2aeddc7 100644 --- a/docs/modules/Sys-Info.md +++ b/docs/modules/Sys-Info.md @@ -19,6 +19,8 @@ Pango markup is supported. | `interval.temps` | `integer` | `5` | Seconds between refreshing temperature data | | `interval.disks` | `integer` | `5` | Seconds between refreshing disk data | | `interval.network` | `integer` | `5` | Seconds between refreshing network data | +| `orientation` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | Orientation of the labels. | +| `direction` | `'horizontal'` or `'vertical'` (shorthand: `'h'` or `'v'`) | `'horizontal'` | How the labels are laid out (not the rotation of an individual label). |
JSON diff --git a/src/config/common.rs b/src/config/common.rs index 286e294e..25a89446 100644 --- a/src/config/common.rs +++ b/src/config/common.rs @@ -40,6 +40,34 @@ pub enum TransitionType { SlideEnd, } +#[derive(Debug, Default, Deserialize, Clone, Copy)] +#[serde(rename_all = "snake_case")] +pub enum ModuleOrientation { + #[default] + #[serde(alias = "h")] + Horizontal, + #[serde(alias = "v")] + Vertical, +} + +impl ModuleOrientation { + pub const fn to_angle(self) -> f64 { + match self { + Self::Horizontal => 0.0, + Self::Vertical => 90.0, + } + } +} + +impl From for Orientation { + fn from(o: ModuleOrientation) -> Self { + match o { + ModuleOrientation::Horizontal => Self::Horizontal, + ModuleOrientation::Vertical => Self::Vertical, + } + } +} + impl TransitionType { pub const fn to_revealer_transition_type( &self, diff --git a/src/config/mod.rs b/src/config/mod.rs index 52fcb8d6..e57fac8e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -34,7 +34,7 @@ use color_eyre::Result; use serde::Deserialize; use std::collections::HashMap; -pub use self::common::{CommonConfig, TransitionType}; +pub use self::common::{CommonConfig, ModuleOrientation, TransitionType}; pub use self::truncate::TruncateMode; #[derive(Debug, Deserialize, Clone)] diff --git a/src/modules/clock.rs b/src/modules/clock.rs index 9978716c..602c6e4b 100644 --- a/src/modules/clock.rs +++ b/src/modules/clock.rs @@ -8,7 +8,7 @@ use serde::Deserialize; use tokio::sync::{broadcast, mpsc}; use tokio::time::sleep; -use crate::config::CommonConfig; +use crate::config::{CommonConfig, ModuleOrientation}; use crate::gtk_helpers::IronbarGtkExt; use crate::modules::{ Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, PopupButton, WidgetContext, @@ -31,6 +31,9 @@ pub struct ClockModule { #[serde(default = "default_locale")] locale: String, + #[serde(default)] + orientation: ModuleOrientation, + #[serde(flatten)] pub common: Option, } @@ -41,6 +44,7 @@ impl Default for ClockModule { format: default_format(), format_popup: default_popup_format(), locale: default_locale(), + orientation: ModuleOrientation::Horizontal, common: Some(CommonConfig::default()), } } @@ -98,7 +102,7 @@ impl Module