mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 22:31:03 +02:00
refactor: address requested changes (2)
This commit is contained in:
parent
40d449e011
commit
d5e4e08863
5 changed files with 18 additions and 24 deletions
|
@ -280,10 +280,11 @@ Check [here](config) for an example config file for a fully configured bar in ea
|
|||
|
||||
The following table lists each of the top-level bar config options:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|--------------------|-----------------------------------------|---------|---------------------------------------------------------------|
|
||||
| `ironvar_defaults` | `Map<string, string>` | `{}` | Map of [ironvar](ironvars) keys against their default values. |
|
||||
| `monitors` | `Map<string, BarConfig or BarConfig[]>` | `null` | Map of monitor names against bar configs. |
|
||||
| Name | Type | Default | Description |
|
||||
|--------------------|-----------------------------------------|---------|-------------------------------------------------------------------------------|
|
||||
| `ironvar_defaults` | `Map<string, string>` | `{}` | Map of [ironvar](ironvars) keys against their default values. |
|
||||
| `monitors` | `Map<string, BarConfig or BarConfig[]>` | `null` | Map of monitor names against bar configs. |
|
||||
| `icon_overrides` | `Map<string, string>` | `{}` | Map of app IDs (or classes) to icon names, overriding the app's default icon. |
|
||||
|
||||
> [!TIP]
|
||||
> `monitors` is only required if you are following **2b** or **2c** (ie not the same bar across all monitors).
|
||||
|
@ -309,7 +310,6 @@ The following table lists each of the bar-level bar config options:
|
|||
| `exclusive_zone` | `boolean` | `true` unless `start_hidden` is enabled. | Whether the bar should reserve an exclusive zone around it. |
|
||||
| `popup_gap` | `integer` | `5` | The gap between the bar and popup window. |
|
||||
| `icon_theme` | `string` | `null` | Name of the GTK icon theme to use. Leave blank to use default. |
|
||||
| `icon_overrides` | `Map<string, string>` | `{}` | Map of app IDs (or classes) to icon names, overriding the app's default icon. |
|
||||
| `start_hidden` | `boolean` | `false`, or `true` if `autohide` set | Whether the bar should be hidden when the application starts. Enabled by default when `autohide` is set. |
|
||||
| `autohide` | `integer` | `null` | The duration in milliseconds before the bar is hidden after the cursor leaves. Leave unset to disable auto-hide behaviour. |
|
||||
| `start` | `Module[]` | `[]` | Array of left or top modules. |
|
||||
|
|
|
@ -268,7 +268,7 @@ impl Bar {
|
|||
output_name: &self.monitor_name,
|
||||
location: $location,
|
||||
icon_theme: &icon_theme,
|
||||
icon_overrides: &config.icon_overrides,
|
||||
icon_overrides: &self.ironbar.config.borrow().icon_overrides,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -290,13 +290,6 @@ pub struct BarConfig {
|
|||
/// **Default**: `null`
|
||||
pub icon_theme: Option<String>,
|
||||
|
||||
/// Map of app IDs (or classes) to icon names,
|
||||
/// overriding the app's default icon.
|
||||
///
|
||||
/// **Default**; `{}`
|
||||
#[serde(default)]
|
||||
pub icon_overrides: HashMap<String, String>,
|
||||
|
||||
/// An array of modules to append to the start of the bar.
|
||||
/// Depending on the orientation, this is either the top of the left edge.
|
||||
///
|
||||
|
@ -345,7 +338,6 @@ impl Default for BarConfig {
|
|||
start_hidden: None,
|
||||
autohide: None,
|
||||
icon_theme: None,
|
||||
icon_overrides: HashMap::default(),
|
||||
start: Some(vec![ModuleConfig::Label(
|
||||
LabelModule::new("ℹ️ Using default config".to_string()).into(),
|
||||
)]),
|
||||
|
@ -396,6 +388,13 @@ pub struct Config {
|
|||
///
|
||||
/// Providing this option overrides the single, global `bar` option.
|
||||
pub monitors: Option<HashMap<String, MonitorConfig>>,
|
||||
|
||||
/// Map of app IDs (or classes) to icon names,
|
||||
/// overriding the app's default icon.
|
||||
///
|
||||
/// **Default**: `{}`
|
||||
#[serde(default)]
|
||||
pub icon_overrides: HashMap<String, String>,
|
||||
}
|
||||
|
||||
const fn default_layer() -> gtk_layer_shell::Layer {
|
||||
|
|
|
@ -9,6 +9,7 @@ use color_eyre::Result;
|
|||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -132,9 +133,6 @@ impl Module<gtk::Box> for FocusedModule {
|
|||
context: WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
|
||||
info: &ModuleInfo,
|
||||
) -> Result<ModuleParts<gtk::Box>> {
|
||||
let icon_theme = info.icon_theme;
|
||||
let icon_overrides = info.icon_overrides;
|
||||
|
||||
let container = gtk::Box::new(info.bar_position.orientation(), 5);
|
||||
|
||||
let icon = gtk::Image::new();
|
||||
|
@ -153,8 +151,9 @@ impl Module<gtk::Box> for FocusedModule {
|
|||
container.add(&label);
|
||||
|
||||
{
|
||||
let icon_theme = icon_theme.clone();
|
||||
let icon_overrides = icon_overrides.clone();
|
||||
let icon_overrides = Arc::new(info.icon_overrides.clone());
|
||||
let icon_theme = info.icon_theme.clone();
|
||||
|
||||
glib_recv!(context.subscribe(), data => {
|
||||
if let Some((name, mut id)) = data {
|
||||
if self.show_icon {
|
||||
|
|
|
@ -165,8 +165,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
let items = arc_mut!(items);
|
||||
let items2 = Arc::clone(&items);
|
||||
|
||||
let icon_overrides = arc_mut!(info.icon_overrides.clone());
|
||||
let icon_overrides2 = Arc::clone(&icon_overrides);
|
||||
let icon_overrides = Arc::new(info.icon_overrides.clone());
|
||||
|
||||
let tx = context.tx.clone();
|
||||
let tx2 = context.tx.clone();
|
||||
|
@ -174,7 +173,6 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
let wl = context.client::<wayland::Client>();
|
||||
spawn(async move {
|
||||
let items = items2;
|
||||
let icon_overrides = icon_overrides2;
|
||||
let tx = tx2;
|
||||
|
||||
let mut wlrx = wl.subscribe_toplevels();
|
||||
|
@ -189,7 +187,6 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
}
|
||||
None => {
|
||||
let mut item = Item::from(info.clone());
|
||||
let icon_overrides = lock!(icon_overrides);
|
||||
|
||||
if let Some(icon) = icon_overrides.get(&info.app_id) {
|
||||
item.icon_override = icon.clone();
|
||||
|
@ -226,7 +223,6 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
match item {
|
||||
None => {
|
||||
let mut item: Item = info.into();
|
||||
let icon_overrides = lock!(icon_overrides);
|
||||
|
||||
if let Some(icon) = icon_overrides.get(&app_id) {
|
||||
item.icon_override = icon.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue