diff --git a/examples/images/hyprspace.png b/examples/images/hyprspace.png
new file mode 100644
index 0000000..f89112b
Binary files /dev/null and b/examples/images/hyprspace.png differ
diff --git a/examples/worf-hyprspace/Readme.md b/examples/worf-hyprspace/Readme.md
index aa7864e..ac877ef 100644
--- a/examples/worf-hyprspace/Readme.md
+++ b/examples/worf-hyprspace/Readme.md
@@ -1 +1,15 @@
# Worf Hyprspace
+
+This allows to manage workspaces in hyprland using the Worf API.
+Inspired by https://github.com/sslater11/hyprland-dynamic-workspaces-manager
+
+
+
+## Features
+-Auto: Automatic detection of mode
+-Rename: Change the name of the chosen workspace
+-SwitchToWorkspace: Change the active workspace
+-MoveCurrentWindowToOtherWorkspace: Move the focused window to a new workspace and follow it
+-MoveCurrentWindowToOtherWorkspaceSilent: Move the focused window to a new workspace and don't follow it
+-MoveAllWindowsToOtherWorkSpace: Move all windows to a new workspace
+-DeleteWorkspace: Close all windows and go to another workspace
diff --git a/examples/worf-hyprswitch/src/main.rs b/examples/worf-hyprswitch/src/main.rs
index 100950f..0efbee3 100644
--- a/examples/worf-hyprswitch/src/main.rs
+++ b/examples/worf-hyprswitch/src/main.rs
@@ -157,7 +157,7 @@ fn main() -> Result<(), String> {
&cache,
)?));
let windows = provider.lock().unwrap().windows.clone();
- let result = gui::show(config, provider, None, None, ExpandMode::Verbatim, None)
+ let result = gui::show(&config, provider, None, None, ExpandMode::Verbatim, None)
.map_err(|e| e.to_string())?;
let update_cache = thread::spawn(move || {
windows.iter().for_each(|item| {
diff --git a/examples/worf-warden/src/main.rs b/examples/worf-warden/src/main.rs
index 125c3aa..d2e8fd0 100644
--- a/examples/worf-warden/src/main.rs
+++ b/examples/worf-warden/src/main.rs
@@ -1,9 +1,19 @@
-use std::{collections::HashMap, env, process::Command, thread::sleep, time::Duration, sync::{Arc, Mutex, RwLock}};
+use std::{
+ collections::HashMap,
+ env,
+ process::Command,
+ sync::{Arc, Mutex, RwLock},
+ thread::sleep,
+ time::Duration,
+};
use worf::{
config::{self, Config, CustomKeyHintLocation, Key},
desktop::{copy_to_clipboard, spawn_fork},
- gui::{self, CustomKeyHint, CustomKeys, ItemProvider, KeyBinding, MenuItem, Modifier, ProviderData, ExpandMode},
+ gui::{
+ self, CustomKeyHint, CustomKeys, ExpandMode, ItemProvider, KeyBinding, MenuItem, Modifier,
+ ProviderData,
+ },
};
#[derive(Clone)]
@@ -138,7 +148,7 @@ fn rbw(cmd: &str, args: Option>) -> Result {
let output = command
.output()
- .map_err(|e| format!("Failed to execute command: {}", e))?;
+ .map_err(|e| format!("Failed to execute command: {e}"))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
@@ -146,7 +156,7 @@ fn rbw(cmd: &str, args: Option>) -> Result {
}
let stdout =
- String::from_utf8(output.stdout).map_err(|e| format!("Invalid UTF-8 output: {}", e))?;
+ String::from_utf8(output.stdout).map_err(|e| format!("Invalid UTF-8 output: {e}"))?;
Ok(stdout.trim().to_string())
}
@@ -273,7 +283,7 @@ fn key_lock() -> KeyBinding {
fn show(config: Arc>, provider: Arc>) -> Result<(), String> {
match gui::show(
- Arc::clone(&config),
+ &config,
provider,
None,
None,
@@ -301,7 +311,10 @@ fn show(config: Arc>, provider: Arc>) ->
Ok(selection) => {
if let Some(meta) = selection.menu.data {
if meta.ids.len() > 1 {
- return show(config, Arc::new(Mutex::new(PasswordProvider::sub_provider(meta.ids)?)));
+ return show(
+ config,
+ Arc::new(Mutex::new(PasswordProvider::sub_provider(meta.ids)?)),
+ );
}
let id = meta.ids.first().unwrap_or(&selection.menu.label);
@@ -351,7 +364,9 @@ fn main() -> Result<(), String> {
.init();
let args = config::parse_args();
- let config = Arc::new(RwLock::new(config::load_config(Some(&args)).unwrap_or(args)));
+ let config = Arc::new(RwLock::new(
+ config::load_config(Some(&args)).unwrap_or(args),
+ ));
if !groups().contains("input") {
log::error!(
diff --git a/worf/src/lib/gui.rs b/worf/src/lib/gui.rs
index a674713..51b9be0 100644
--- a/worf/src/lib/gui.rs
+++ b/worf/src/lib/gui.rs
@@ -75,13 +75,20 @@ pub struct DefaultItemFactory {
}
impl DefaultItemFactory {
+ #[must_use]
pub fn new() -> DefaultItemFactory {
DefaultItemFactory:: {
- _marker: Default::default(),
+ _marker: PhantomData,
}
}
}
+impl Default for DefaultItemFactory {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl ItemFactory for DefaultItemFactory {
fn new_menu_item(&self, label: String) -> Option