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