mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 22:31:03 +02:00
feat: add .urgent
workspace css class
This commit is contained in:
parent
32e6fc5dc2
commit
afe534ccd9
6 changed files with 80 additions and 9 deletions
|
@ -98,15 +98,16 @@ end:
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
| Selector | Description |
|
| Selector | Description |
|
||||||
|--------------------------------|--------------------------------------|
|
| ------------------------------ | ------------------------------------------------------- |
|
||||||
| `.workspaces` | Workspaces widget box |
|
| `.workspaces` | Workspaces widget box |
|
||||||
| `.workspaces .item` | Workspace button |
|
| `.workspaces .item` | Workspace button |
|
||||||
| `.workspaces .item.focused` | Workspace button (workspace focused) |
|
| `.workspaces .item.focused` | Workspace button (workspace focused) |
|
||||||
| `.workspaces .item.visible` | Workspace button (workspace visible, including focused) |
|
| `.workspaces .item.visible` | Workspace button (workspace visible, including focused) |
|
||||||
| `.workspaces .item.inactive` | Workspace button (favourite, not currently open)
|
| `.workspaces .item.urgent` | Workspace button (workspace contains urgent window) |
|
||||||
| `.workspaces .item .icon` | Workspace button icon (any type) |
|
| `.workspaces .item.inactive` | Workspace button (favourite, not currently open) |
|
||||||
| `.workspaces .item .text-icon` | Workspace button icon (textual only) |
|
| `.workspaces .item .icon` | Workspace button icon (any type) |
|
||||||
| `.workspaces .item .image` | Workspace button icon (image only) |
|
| `.workspaces .item .text-icon` | Workspace button icon (textual only) |
|
||||||
|
| `.workspaces .item .image` | Workspace button icon (image only) |
|
||||||
|
|
||||||
For more information on styling, please see the [styling guide](styling-guide).
|
For more information on styling, please see the [styling guide](styling-guide).
|
||||||
|
|
|
@ -201,6 +201,10 @@ scale trough {
|
||||||
background-color: @color_bg_dark;
|
background-color: @color_bg_dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workspaces .item.urgent {
|
||||||
|
background-color: @color_urgent;
|
||||||
|
}
|
||||||
|
|
||||||
.workspaces .item:hover {
|
.workspaces .item:hover {
|
||||||
box-shadow: inset 0 -3px;
|
box-shadow: inset 0 -3px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,9 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
let tx = tx.clone();
|
||||||
|
let lock = lock.clone();
|
||||||
|
|
||||||
event_listener.add_workspace_destroy_handler(move |data| {
|
event_listener.add_workspace_destroy_handler(move |data| {
|
||||||
let _lock = lock!(lock);
|
let _lock = lock!(lock);
|
||||||
debug!("Received workspace destroy: {data:?}");
|
debug!("Received workspace destroy: {data:?}");
|
||||||
|
@ -173,6 +176,35 @@ impl Client {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
event_listener.add_urgent_state_handler(move |address| {
|
||||||
|
let _lock = lock!(lock);
|
||||||
|
debug!("Received urgent state: {address:?}");
|
||||||
|
|
||||||
|
let clients = match hyprland::data::Clients::get() {
|
||||||
|
Ok(clients) => clients,
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to get clients: {err}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
clients.iter().find(|c| c.address == address).map_or_else(
|
||||||
|
|| {
|
||||||
|
error!("Unable to locate client");
|
||||||
|
},
|
||||||
|
|c| {
|
||||||
|
send!(
|
||||||
|
tx,
|
||||||
|
WorkspaceUpdate::Urgent {
|
||||||
|
id: c.workspace.id as i64,
|
||||||
|
urgent: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
event_listener
|
event_listener
|
||||||
.start_listener()
|
.start_listener()
|
||||||
.expect("Failed to start listener");
|
.expect("Failed to start listener");
|
||||||
|
@ -194,6 +226,14 @@ impl Client {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
send!(
|
||||||
|
tx,
|
||||||
|
WorkspaceUpdate::Urgent {
|
||||||
|
id: workspace.id,
|
||||||
|
urgent: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
prev_workspace.replace(workspace);
|
prev_workspace.replace(workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,12 @@ pub enum WorkspaceUpdate {
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// The urgent state of a node changed.
|
||||||
|
Urgent {
|
||||||
|
id: i64,
|
||||||
|
urgent: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// An update was triggered by the compositor but this was not mapped by Ironbar.
|
/// An update was triggered by the compositor but this was not mapped by Ironbar.
|
||||||
///
|
///
|
||||||
/// This is purely used for ergonomics within the compositor clients
|
/// This is purely used for ergonomics within the compositor clients
|
||||||
|
|
|
@ -109,6 +109,16 @@ impl From<WorkspaceEvent> for WorkspaceUpdate {
|
||||||
WorkspaceChange::Move => {
|
WorkspaceChange::Move => {
|
||||||
Self::Move(event.current.expect("Missing current workspace").into())
|
Self::Move(event.current.expect("Missing current workspace").into())
|
||||||
}
|
}
|
||||||
|
WorkspaceChange::Urgent => {
|
||||||
|
if let Some(node) = event.current {
|
||||||
|
Self::Urgent {
|
||||||
|
id: node.id,
|
||||||
|
urgent: node.urgent,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Self::Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => Self::Unknown,
|
_ => Self::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,6 +413,16 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WorkspaceUpdate::Urgent { id, urgent } => {
|
||||||
|
let button = button_map.get(&id);
|
||||||
|
if let Some(item) = button {
|
||||||
|
if urgent {
|
||||||
|
item.add_class("urgent");
|
||||||
|
} else {
|
||||||
|
item.style_context().remove_class("urgent");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
WorkspaceUpdate::Unknown => warn!("Received unknown type workspace event")
|
WorkspaceUpdate::Unknown => warn!("Received unknown type workspace event")
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue