From ccb03195b942d95315bf3c396e0a0e7dfdcc1bc9 Mon Sep 17 00:00:00 2001 From: Kirill Unitsaev Date: Sat, 2 Nov 2024 17:16:40 +0300 Subject: [PATCH 1/3] add clipboard button --- src/app.rs | 15 ++++++++++++++- src/components/icons.rs | 2 ++ src/config.rs | 2 ++ src/modules/clipboard.rs | 14 ++++++++++++++ src/modules/mod.rs | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/modules/clipboard.rs diff --git a/src/app.rs b/src/app.rs index ba21829..823b1b6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,7 +4,7 @@ use crate::{ get_log_spec, menu::{menu_wrapper, Menu, MenuPosition, MenuType}, modules::{ - self, clock::Clock, launcher, privacy::PrivacyMessage, settings::Settings, + self, clipboard, clock::Clock, launcher, privacy::PrivacyMessage, settings::Settings, system_info::SystemInfo, title::Title, updates::Updates, workspaces::Workspaces, }, services::{privacy::PrivacyService, ReadOnlyService, ServiceEvent}, @@ -41,6 +41,7 @@ pub enum Message { ConfigChanged(Box), CloseMenu, OpenLauncher, + OpenClipboard, Updates(modules::updates::Message), Workspaces(modules::workspaces::Message), Title(modules::title::Message), @@ -117,6 +118,12 @@ impl Application for App { } Command::none() } + Message::OpenClipboard => { + if let Some(clipboard_cmd) = self.config.clipboard_cmd.as_ref() { + utils::launcher::execute_command(clipboard_cmd.to_string()); + } + Command::none() + } Message::Workspaces(msg) => { self.workspaces.update(msg); @@ -185,6 +192,12 @@ impl Application for App { .as_ref() .map(|_| launcher::launcher()), ) + .push_maybe( + self.config + .clipboard_cmd + .as_ref() + .map(|_| clipboard::clipboard()), + ) .push_maybe( self.config .updates diff --git a/src/components/icons.rs b/src/components/icons.rs index ccb3f38..ec2ee12 100644 --- a/src/components/icons.rs +++ b/src/components/icons.rs @@ -8,6 +8,7 @@ pub enum Icons { #[default] None, Launcher, + Clipboard, Refresh, NoUpdatesAvailable, UpdatesAvailable, @@ -71,6 +72,7 @@ impl From for &'static str { match icon { Icons::None => "", Icons::Launcher => "󱗼", + Icons::Clipboard => "󰅌", Icons::Refresh => "󰑐", Icons::NoUpdatesAvailable => "󰗠", Icons::UpdatesAvailable => "󰳛", diff --git a/src/config.rs b/src/config.rs index b57aa47..2e6d5bb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -262,6 +262,7 @@ pub struct Config { #[serde(default)] pub position: Position, pub app_launcher_cmd: Option, + pub clipboard_cmd: Option, #[serde(default = "default_truncate_title_after_length")] pub truncate_title_after_length: u32, #[serde(deserialize_with = "try_default")] @@ -305,6 +306,7 @@ impl Default for Config { log_level: default_log_level(), position: Position::Top, app_launcher_cmd: None, + clipboard_cmd: None, truncate_title_after_length: default_truncate_title_after_length(), updates: None, system: SystemModuleConfig::default(), diff --git a/src/modules/clipboard.rs b/src/modules/clipboard.rs new file mode 100644 index 0000000..0782d20 --- /dev/null +++ b/src/modules/clipboard.rs @@ -0,0 +1,14 @@ +use crate::{ + app::Message, + components::icons::{icon, Icons}, + style::HeaderButtonStyle, +}; +use iced::{theme, widget::button, Element}; + +pub fn clipboard<'a>() -> Element<'a, Message> { + button(icon(Icons::Clipboard)) + .padding([2, 7]) + .on_press(Message::OpenClipboard) + .style(theme::Button::custom(HeaderButtonStyle::Full)) + .into() +} diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 422abef..ea0bbc8 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -1,3 +1,4 @@ +pub mod clipboard; pub mod clock; pub mod launcher; pub mod privacy; From 1ef6810c481d24422273499122d04975168a695e Mon Sep 17 00:00:00 2001 From: Kirill Unitsaev Date: Sat, 2 Nov 2024 17:16:54 +0300 Subject: [PATCH 2/3] update readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 369fa22..4a82dc9 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,9 @@ position: Top # optional, default Top # App lancher commanda, it will be used to open the launcher, # without a value the related button will not appear appLauncherCmd: "~/.config/rofi/launcher.sh" # optional, default None +# Clipboard command, it will be used to open the clipboard menu, +# without a value the related button will not appear +clipboardCmd: "cliphist-rofi-img | wl-copy" # optional, default None # Update module configuration. # Without a value the related button will not appear. updates: # optional, default None From 9f77f7a4bd3d92d79f93cdbfc63cc429ffba19c9 Mon Sep 17 00:00:00 2001 From: Kirill Unitsaev Date: Sun, 3 Nov 2024 14:34:03 +0300 Subject: [PATCH 3/3] upd changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71eebde..59357e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Changed +### Added + +- Added a clipboard button ### Fixed