Skip to content

Commit

Permalink
Merge pull request #86 from MalpenZibo/81-show-only-monitor-workspaces
Browse files Browse the repository at this point in the history
81 Show only monitor workspaces
  • Loading branch information
MalpenZibo authored Jan 19, 2025
2 parents 79c86f7 + da21b51 commit bf85cce
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 109 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Multi monitor support
- Tray module
- Dynamic modules system configuration
- New workspace module configuration

### Changed

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ updates: # optional, default None
# Maximum number of chars that can be present in the window title
# after that the title will be truncated
truncateTitleAfterLength: 150 # optional, default 150
# Workspaces module configuration, optional
workspaces:
# The visibility mode of the workspaces, possible values are:
# All: all the workspaces will be displayed
# MonitorSpecific: only the workspaces of the related monitor will be displayed
visibilityMode: All # optional, default All
# Enable filling with empty workspaces
# For example:
# With this flag set to true if there are only 2 workspaces,
# the workspace 1 and the workspace 4, the module will show also
# two more workspaces, the workspace 2 and the workspace 3
enableWorkspaceFilling: false # optional, default false
# The system module configuration
system:
cpuWarnThreshold: 6O # cpu indicator warning level (default 60)
Expand Down
5 changes: 3 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use log::{debug, info, warn};
pub struct App {
logger: LoggerHandle,
pub config: Config,
outputs: Outputs,
pub outputs: Outputs,
pub app_launcher: AppLauncher,
pub updates: Updates,
pub clipboard: Clipboard,
Expand Down Expand Up @@ -68,6 +68,7 @@ impl App {
pub fn new((logger, config): (LoggerHandle, Config)) -> impl FnOnce() -> (Self, Task<Message>) {
|| {
let (outputs, task) = Outputs::new(config.position);
let enable_workspace_filling = config.workspaces.enable_workspace_filling;
(
App {
logger,
Expand All @@ -76,7 +77,7 @@ impl App {
app_launcher: AppLauncher,
updates: Updates::default(),
clipboard: Clipboard,
workspaces: Workspaces::default(),
workspaces: Workspaces::new(enable_workspace_filling),
window_title: WindowTitle::default(),
system_info: SystemInfo::default(),
keyboard_layout: KeyboardLayout::default(),
Expand Down
19 changes: 19 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ pub struct UpdatesModuleConfig {
pub update_cmd: String,
}

#[derive(Deserialize, Clone, Default, PartialEq, Eq, Debug)]
pub enum WorkspaceVisibilityMode {
#[default]
All,
MonitorSpecific,
}

#[derive(Deserialize, Clone, Default, Debug)]
#[serde(rename_all = "camelCase")]
pub struct WorkspacesModuleConfig {
#[serde(default)]
pub visibility_mode: WorkspaceVisibilityMode,
#[serde(default)]
pub enable_workspace_filling: bool,
}

#[derive(Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SystemModuleConfig {
Expand Down Expand Up @@ -342,6 +358,8 @@ pub struct Config {
#[serde(default)]
pub updates: Option<UpdatesModuleConfig>,
#[serde(default)]
pub workspaces: WorkspacesModuleConfig,
#[serde(default)]
pub system: SystemModuleConfig,
#[serde(default)]
pub clock: ClockModuleConfig,
Expand Down Expand Up @@ -370,6 +388,7 @@ impl Default for Config {
clipboard_cmd: None,
truncate_title_after_length: default_truncate_title_after_length(),
updates: None,
workspaces: WorkspacesModuleConfig::default(),
system: SystemModuleConfig::default(),
clock: ClockModuleConfig::default(),
settings: SettingsModuleConfig::default(),
Expand Down
5 changes: 4 additions & 1 deletion src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ impl App {
ModuleName::Updates => self.updates.view(&self.config.updates),
ModuleName::Clipboard => self.clipboard.view(&self.config.clipboard_cmd),
ModuleName::Workspaces => self.workspaces.view((
&self.outputs,
id,
&self.config.workspaces,
&self.config.appearance.workspace_colors,
self.config.appearance.special_workspace_colors.as_deref(),
)),
Expand All @@ -232,7 +235,7 @@ impl App {
.as_ref()
.and_then(|updates_config| self.updates.subscription(updates_config)),
ModuleName::Clipboard => self.clipboard.subscription(()),
ModuleName::Workspaces => self.workspaces.subscription(()),
ModuleName::Workspaces => self.workspaces.subscription(&self.config.workspaces),
ModuleName::WindowTitle => self.window_title.subscription(()),
ModuleName::SystemInfo => self.system_info.subscription(()),
ModuleName::KeyboardLayout => self.keyboard_layout.subscription(()),
Expand Down
Loading

0 comments on commit bf85cce

Please sign in to comment.