mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
Merge pull request #404 from thmasq/master
Make feature flags for the "focused" and launcher "modules"
This commit is contained in:
commit
b9a42f0f66
10 changed files with 76 additions and 15 deletions
12
Cargo.toml
12
Cargo.toml
|
@ -11,11 +11,13 @@ keywords = ["gtk", "bar", "wayland", "wlroots", "gtk-layer-shell"]
|
|||
[features]
|
||||
default = [
|
||||
"cli",
|
||||
"ipc",
|
||||
"http",
|
||||
"config+all",
|
||||
"clipboard",
|
||||
"clock",
|
||||
"config+all",
|
||||
"focused",
|
||||
"http",
|
||||
"ipc",
|
||||
"launcher",
|
||||
"music+all",
|
||||
"sys_info",
|
||||
"tray",
|
||||
|
@ -45,6 +47,10 @@ clipboard = ["nix"]
|
|||
|
||||
clock = ["chrono"]
|
||||
|
||||
focused = []
|
||||
|
||||
launcher = []
|
||||
|
||||
music = ["regex"]
|
||||
"music+all" = ["music", "music+mpris", "music+mpd"]
|
||||
"music+mpris" = ["music", "mpris"]
|
||||
|
|
|
@ -73,6 +73,8 @@ cargo build --release --no-default-features \
|
|||
| **Modules** | |
|
||||
| clipboard | Enables the `clipboard` module. |
|
||||
| clock | Enables the `clock` module. |
|
||||
| focused | Enables the `focused` module. |
|
||||
| launcher | Enables the `launcher` module. |
|
||||
| music+all | Enables the `music` module with support for all player types. |
|
||||
| music+mpris | Enables the `music` module with MPRIS support. |
|
||||
| music+mpd | Enables the `music` module with MPD support. |
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
> [!NOTE]
|
||||
> This module requires a `wlroots-based` compositor. It will not work without the [wlr data control](https://wayland.app/protocols/wlr-data-control-unstable-v1) protocol.
|
||||
|
||||
Shows recent clipboard items, allowing you to switch between them to re-copy previous values.
|
||||
Clicking the icon button opens the popup containing all functionality.
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
> [!NOTE]
|
||||
> This module requires a `wlroots-based` compositor. It will not work without the [wlr-foreign-toplevel-management](https://wayland.app/protocols/wlr-foreign-toplevel-management-unstable-v1) protocol.
|
||||
|
||||
Displays the title and/or icon of the currently focused window.
|
||||
|
||||

|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
> [!NOTE]
|
||||
> This module requires a `wlroots-based` compositor. It will not work without the [wlr-foreign-toplevel-management](https://wayland.app/protocols/wlr-foreign-toplevel-management-unstable-v1) protocol.
|
||||
|
||||
Windows-style taskbar that displays running windows, grouped by program.
|
||||
Hovering over a program with multiple windows open shows a popup with each window.
|
||||
Clicking an icon/popup item focuses or launches the program.
|
||||
|
|
|
@ -377,8 +377,10 @@ fn add_modules(
|
|||
#[cfg(feature = "clock")]
|
||||
ModuleConfig::Clock(mut module) => add_module!(module, id),
|
||||
ModuleConfig::Custom(mut module) => add_module!(module, id),
|
||||
#[cfg(feature = "focused")]
|
||||
ModuleConfig::Focused(mut module) => add_module!(module, id),
|
||||
ModuleConfig::Label(mut module) => add_module!(module, id),
|
||||
#[cfg(feature = "launcher")]
|
||||
ModuleConfig::Launcher(mut module) => add_module!(module, id),
|
||||
#[cfg(feature = "music")]
|
||||
ModuleConfig::Music(mut module) => add_module!(module, id),
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
mod macros;
|
||||
mod wl_output;
|
||||
mod wl_seat;
|
||||
mod wlr_foreign_toplevel;
|
||||
|
||||
use crate::error::ERR_CHANNEL_RECV;
|
||||
use crate::{
|
||||
arc_mut, delegate_foreign_toplevel_handle, delegate_foreign_toplevel_manager, lock,
|
||||
register_client, send, Ironbar,
|
||||
};
|
||||
use crate::{arc_mut, lock, register_client, send, Ironbar};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use calloop_channel::Event::Msg;
|
||||
|
@ -26,11 +22,17 @@ use tokio::sync::{broadcast, mpsc};
|
|||
use tracing::{debug, error, trace};
|
||||
use wayland_client::globals::registry_queue_init;
|
||||
use wayland_client::{Connection, QueueHandle};
|
||||
|
||||
use wlr_foreign_toplevel::manager::ToplevelManagerState;
|
||||
|
||||
pub use wl_output::{OutputEvent, OutputEventType};
|
||||
pub use wlr_foreign_toplevel::{ToplevelEvent, ToplevelHandle, ToplevelInfo};
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "focused", feature = "launcher"))] {
|
||||
mod wlr_foreign_toplevel;
|
||||
use crate::{delegate_foreign_toplevel_handle, delegate_foreign_toplevel_manager};
|
||||
use wlr_foreign_toplevel::manager::ToplevelManagerState;
|
||||
pub use wlr_foreign_toplevel::{ToplevelEvent, ToplevelHandle, ToplevelInfo};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "clipboard")] {
|
||||
|
@ -56,6 +58,7 @@ cfg_if! {
|
|||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
Output(OutputEvent),
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
Toplevel(ToplevelEvent),
|
||||
#[cfg(feature = "clipboard")]
|
||||
Clipboard(ClipboardItem),
|
||||
|
@ -68,7 +71,9 @@ pub enum Request {
|
|||
#[cfg(feature = "ipc")]
|
||||
OutputInfoAll,
|
||||
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
ToplevelInfoAll,
|
||||
#[cfg(feature = "launcher")]
|
||||
ToplevelFocus(usize),
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
@ -85,6 +90,9 @@ pub enum Response {
|
|||
#[cfg(feature = "ipc")]
|
||||
OutputInfoAll(Vec<smithay_client_toolkit::output::OutputInfo>),
|
||||
|
||||
#[cfg(feature = "launcher")]
|
||||
ToplevelInfo(Option<ToplevelInfo>),
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
ToplevelInfoAll(Vec<ToplevelInfo>),
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
@ -106,6 +114,7 @@ pub struct Client {
|
|||
rx: Arc<Mutex<std::sync::mpsc::Receiver<Response>>>,
|
||||
|
||||
output_channel: BroadcastChannel<OutputEvent>,
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
toplevel_channel: BroadcastChannel<ToplevelEvent>,
|
||||
#[cfg(feature = "clipboard")]
|
||||
clipboard_channel: BroadcastChannel<ClipboardItem>,
|
||||
|
@ -119,6 +128,7 @@ impl Client {
|
|||
let (response_tx, response_rx) = std::sync::mpsc::channel();
|
||||
|
||||
let output_channel = broadcast::channel(32);
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
let toplevel_channel = broadcast::channel(32);
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
@ -131,6 +141,7 @@ impl Client {
|
|||
// listen to events
|
||||
{
|
||||
let output_tx = output_channel.0.clone();
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
let toplevel_tx = toplevel_channel.0.clone();
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
@ -141,6 +152,7 @@ impl Client {
|
|||
while let Some(event) = event_rx.recv().await {
|
||||
match event {
|
||||
Event::Output(event) => send!(output_tx, event),
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
Event::Toplevel(event) => send!(toplevel_tx, event),
|
||||
#[cfg(feature = "clipboard")]
|
||||
Event::Clipboard(item) => send!(clipboard_tx, item),
|
||||
|
@ -154,6 +166,7 @@ impl Client {
|
|||
rx: arc_mut!(response_rx),
|
||||
|
||||
output_channel: output_channel.into(),
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
toplevel_channel: toplevel_channel.into(),
|
||||
#[cfg(feature = "clipboard")]
|
||||
clipboard_channel: clipboard_channel.into(),
|
||||
|
@ -187,6 +200,7 @@ pub struct Environment {
|
|||
response_tx: std::sync::mpsc::Sender<Response>,
|
||||
|
||||
// local state
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
handles: Vec<ToplevelHandle>,
|
||||
|
||||
// -- clipboard --
|
||||
|
@ -210,8 +224,12 @@ delegate_registry!(Environment);
|
|||
delegate_output!(Environment);
|
||||
delegate_seat!(Environment);
|
||||
|
||||
delegate_foreign_toplevel_manager!(Environment);
|
||||
delegate_foreign_toplevel_handle!(Environment);
|
||||
cfg_if! {
|
||||
if #[cfg(any(feature = "focused", feature = "launcher"))] {
|
||||
delegate_foreign_toplevel_manager!(Environment);
|
||||
delegate_foreign_toplevel_handle!(Environment);
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "clipboard")] {
|
||||
|
@ -247,6 +265,7 @@ impl Environment {
|
|||
|
||||
let output_state = OutputState::new(&globals, &qh);
|
||||
let seat_state = SeatState::new(&globals, &qh);
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
ToplevelManagerState::bind(&globals, &qh)
|
||||
.expect("to bind to wlr_foreign_toplevel_manager global");
|
||||
|
||||
|
@ -264,6 +283,7 @@ impl Environment {
|
|||
loop_handle: loop_handle.clone(),
|
||||
event_tx,
|
||||
response_tx,
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
handles: vec![],
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
@ -306,6 +326,7 @@ impl Environment {
|
|||
let infos = env.output_info_all();
|
||||
send!(env.response_tx, Response::OutputInfoAll(infos));
|
||||
}
|
||||
#[cfg(any(feature = "focused", feature = "launcher"))]
|
||||
Msg(Request::ToplevelInfoAll) => {
|
||||
let infos = env
|
||||
.handles
|
||||
|
@ -314,15 +335,18 @@ impl Environment {
|
|||
.collect();
|
||||
send!(env.response_tx, Response::ToplevelInfoAll(infos));
|
||||
}
|
||||
#[cfg(feature = "launcher")]
|
||||
Msg(Request::ToplevelFocus(id)) => {
|
||||
let handle = env
|
||||
.handles
|
||||
.iter()
|
||||
.find(|handle| handle.info().map_or(false, |info| info.id == id));
|
||||
|
||||
if let Some(handle) = handle {
|
||||
let seat = env.default_seat();
|
||||
handle.focus(&seat);
|
||||
}
|
||||
|
||||
send!(env.response_tx, Response::Ok);
|
||||
}
|
||||
#[cfg(feature = "clipboard")]
|
||||
|
|
|
@ -28,6 +28,7 @@ impl Client {
|
|||
}
|
||||
|
||||
/// Focuses the toplevel with the provided ID.
|
||||
#[cfg(feature = "launcher")]
|
||||
pub fn toplevel_focus(&self, handle_id: usize) {
|
||||
match self.send_request(Request::ToplevelFocus(handle_id)) {
|
||||
Response::Ok => (),
|
||||
|
|
|
@ -7,8 +7,10 @@ use crate::modules::clipboard::ClipboardModule;
|
|||
#[cfg(feature = "clock")]
|
||||
use crate::modules::clock::ClockModule;
|
||||
use crate::modules::custom::CustomModule;
|
||||
#[cfg(feature = "focused")]
|
||||
use crate::modules::focused::FocusedModule;
|
||||
use crate::modules::label::LabelModule;
|
||||
#[cfg(feature = "launcher")]
|
||||
use crate::modules::launcher::LauncherModule;
|
||||
#[cfg(feature = "music")]
|
||||
use crate::modules::music::MusicModule;
|
||||
|
@ -36,8 +38,10 @@ pub enum ModuleConfig {
|
|||
#[cfg(feature = "clock")]
|
||||
Clock(Box<ClockModule>),
|
||||
Custom(Box<CustomModule>),
|
||||
#[cfg(feature = "focused")]
|
||||
Focused(Box<FocusedModule>),
|
||||
Label(Box<LabelModule>),
|
||||
#[cfg(feature = "launcher")]
|
||||
Launcher(Box<LauncherModule>),
|
||||
#[cfg(feature = "music")]
|
||||
Music(Box<MusicModule>),
|
||||
|
@ -127,6 +131,15 @@ impl Default for Config {
|
|||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "focused")] {
|
||||
let center = Some(vec![ModuleConfig::Focused(Box::default())]);
|
||||
}
|
||||
else {
|
||||
let center = None;
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
position: BarPosition::default(),
|
||||
height: default_bar_height(),
|
||||
|
@ -140,7 +153,7 @@ impl Default for Config {
|
|||
start: Some(vec![ModuleConfig::Label(
|
||||
LabelModule::new("ℹ️ Using default config".to_string()).into(),
|
||||
)]),
|
||||
center: Some(vec![ModuleConfig::Focused(Box::default())]),
|
||||
center,
|
||||
end,
|
||||
anchor_to_edges: default_true(),
|
||||
monitors: None,
|
||||
|
|
|
@ -28,8 +28,10 @@ pub mod clipboard;
|
|||
#[cfg(feature = "clock")]
|
||||
pub mod clock;
|
||||
pub mod custom;
|
||||
#[cfg(feature = "focused")]
|
||||
pub mod focused;
|
||||
pub mod label;
|
||||
#[cfg(feature = "launcher")]
|
||||
pub mod launcher;
|
||||
#[cfg(feature = "music")]
|
||||
pub mod music;
|
||||
|
@ -68,6 +70,7 @@ pub enum ModuleUpdateEvent<T: Clone> {
|
|||
/// Force sets the popup open.
|
||||
/// Takes the button ID.
|
||||
OpenPopup(usize),
|
||||
#[cfg(feature = "launcher")]
|
||||
OpenPopupAt(WidgetGeometry),
|
||||
/// Force sets the popup closed.
|
||||
ClosePopup,
|
||||
|
@ -317,6 +320,7 @@ fn setup_receiver<TSend>(
|
|||
has_popup_opened = true;
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "launcher")]
|
||||
ModuleUpdateEvent::OpenPopupAt(geometry) => {
|
||||
debug!("Opening popup for {} [#{}]", name, id);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue