mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 06:11:03 +02:00
feat: change icon_overrides
to apply to all resolved images
This commit is contained in:
parent
3e55d87c3a
commit
3a0e102afc
7 changed files with 18 additions and 64 deletions
|
@ -280,11 +280,12 @@ 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. |
|
||||
| `icon_overrides` | `Map<string, string>` | `{}` | Map of app IDs (or classes) to icon names, overriding the app's default icon. |
|
||||
| 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_theme` | `string` | `null` | Name of the GTK icon theme to use. Leave blank to use default. |
|
||||
| `icon_overrides` | `Map<string, string>` | `{}` | Map of image inputs to override names. Usually used for 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:
|
|||
| `layer` | `background` or `bottom` or `top` or `overlay` | `top` | The layer-shell layer to place the bar on. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
|
|
26
src/bar.rs
26
src/bar.rs
|
@ -6,11 +6,9 @@ use color_eyre::Result;
|
|||
use glib::Propagation;
|
||||
use gtk::gdk::Monitor;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{Application, ApplicationWindow, IconTheme, Orientation, Window, WindowType};
|
||||
use gtk::{Application, ApplicationWindow, Orientation, Window, WindowType};
|
||||
use gtk_layer_shell::LayerShell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tracing::{debug, info};
|
||||
|
||||
|
@ -25,7 +23,6 @@ pub struct Bar {
|
|||
name: String,
|
||||
monitor_name: String,
|
||||
monitor_size: (i32, i32),
|
||||
icon_overrides: Arc<HashMap<String, String>>,
|
||||
position: BarPosition,
|
||||
|
||||
ironbar: Rc<Ironbar>,
|
||||
|
@ -46,7 +43,6 @@ impl Bar {
|
|||
app: &Application,
|
||||
monitor_name: String,
|
||||
monitor_size: (i32, i32),
|
||||
icon_overrides: Arc<HashMap<String, String>>,
|
||||
config: BarConfig,
|
||||
ironbar: Rc<Ironbar>,
|
||||
) -> Self {
|
||||
|
@ -96,7 +92,6 @@ impl Bar {
|
|||
name,
|
||||
monitor_name,
|
||||
monitor_size,
|
||||
icon_overrides,
|
||||
position,
|
||||
ironbar,
|
||||
window,
|
||||
|
@ -257,11 +252,6 @@ impl Bar {
|
|||
monitor: &Monitor,
|
||||
output_size: (i32, i32),
|
||||
) -> Result<BarLoadResult> {
|
||||
let icon_theme = IconTheme::new();
|
||||
if let Some(ref theme) = config.icon_theme {
|
||||
icon_theme.set_custom_theme(Some(theme));
|
||||
}
|
||||
|
||||
let app = &self.window.application().expect("to exist");
|
||||
|
||||
macro_rules! info {
|
||||
|
@ -272,15 +262,13 @@ impl Bar {
|
|||
monitor,
|
||||
output_name: &self.monitor_name,
|
||||
location: $location,
|
||||
icon_theme: &icon_theme,
|
||||
icon_overrides: self.icon_overrides.clone(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// popup ignores module location so can bodge this for now
|
||||
let popup = Popup::new(
|
||||
self.ironbar.clone(),
|
||||
&self.ironbar,
|
||||
&info!(ModuleLocation::Left),
|
||||
output_size,
|
||||
config.popup_gap,
|
||||
|
@ -404,17 +392,9 @@ pub fn create_bar(
|
|||
monitor: &Monitor,
|
||||
monitor_name: String,
|
||||
monitor_size: (i32, i32),
|
||||
icon_overrides: Arc<HashMap<String, String>>,
|
||||
config: BarConfig,
|
||||
ironbar: Rc<Ironbar>,
|
||||
) -> Result<Bar> {
|
||||
let bar = Bar::new(
|
||||
app,
|
||||
monitor_name,
|
||||
monitor_size,
|
||||
icon_overrides,
|
||||
config,
|
||||
ironbar,
|
||||
);
|
||||
let bar = Bar::new(app, monitor_name, monitor_size, config, ironbar);
|
||||
bar.init(monitor)
|
||||
}
|
||||
|
|
|
@ -166,10 +166,7 @@ impl Provider {
|
|||
) -> Result<Option<ImageLocation>> {
|
||||
const MAX_RECURSE_DEPTH: u8 = 2;
|
||||
|
||||
let input = self
|
||||
.overrides
|
||||
.get(input)
|
||||
.map_or(input, String::as_str);
|
||||
let input = self.overrides.get(input).map_or(input, String::as_str);
|
||||
|
||||
let should_parse_desktop_file = !Self::is_explicit_input(input);
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ fn load_output_bars(
|
|||
};
|
||||
|
||||
let config = ironbar.config.borrow();
|
||||
let icon_overrides = Arc::new(config.icon_overrides.clone());
|
||||
|
||||
let display = get_display();
|
||||
|
||||
let pos = output.logical_position.unwrap_or_default();
|
||||
|
@ -416,7 +416,6 @@ fn load_output_bars(
|
|||
&monitor,
|
||||
monitor_name.to_string(),
|
||||
output_size,
|
||||
icon_overrides,
|
||||
config.clone(),
|
||||
ironbar.clone(),
|
||||
)?]
|
||||
|
@ -429,7 +428,6 @@ fn load_output_bars(
|
|||
&monitor,
|
||||
monitor_name.to_string(),
|
||||
output_size,
|
||||
icon_overrides.clone(),
|
||||
config.clone(),
|
||||
ironbar.clone(),
|
||||
)
|
||||
|
@ -440,7 +438,6 @@ fn load_output_bars(
|
|||
&monitor,
|
||||
monitor_name.to_string(),
|
||||
output_size,
|
||||
icon_overrides,
|
||||
config.bar.clone(),
|
||||
ironbar.clone(),
|
||||
)?],
|
||||
|
|
|
@ -261,11 +261,7 @@ impl Module<gtk::Box> for KeyboardModule {
|
|||
|
||||
let caps = IconLabel::new(&self.icons.caps_off, self.icon_size, &image_provider);
|
||||
let num = IconLabel::new(&self.icons.num_off, self.icon_size, &image_provider);
|
||||
let scroll = IconLabel::new(
|
||||
&self.icons.scroll_off,
|
||||
self.icon_size,
|
||||
&image_provider,
|
||||
);
|
||||
let scroll = IconLabel::new(&self.icons.scroll_off, self.icon_size, &image_provider);
|
||||
|
||||
caps.label().set_angle(self.layout.angle(info));
|
||||
caps.label().set_justify(self.layout.justify.into());
|
||||
|
|
|
@ -23,23 +23,16 @@ pub struct Item {
|
|||
pub open_state: OpenState,
|
||||
pub windows: IndexMap<usize, Window>,
|
||||
pub name: String,
|
||||
pub icon_override: String,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn new(
|
||||
app_id: String,
|
||||
icon_override: String,
|
||||
open_state: OpenState,
|
||||
favorite: bool,
|
||||
) -> Self {
|
||||
pub fn new(app_id: String, open_state: OpenState, favorite: bool) -> Self {
|
||||
Self {
|
||||
app_id,
|
||||
favorite,
|
||||
open_state,
|
||||
windows: IndexMap::new(),
|
||||
name: String::new(),
|
||||
icon_override,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +107,6 @@ impl From<ToplevelInfo> for Item {
|
|||
open_state,
|
||||
windows,
|
||||
name,
|
||||
icon_override: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,9 +171,7 @@ impl ItemButton {
|
|||
}
|
||||
|
||||
if appearance.show_icons {
|
||||
let input = if !item.icon_override.is_empty() {
|
||||
item.icon_override.clone()
|
||||
} else if item.app_id.is_empty() {
|
||||
let input = if item.app_id.is_empty() {
|
||||
item.name.clone()
|
||||
} else {
|
||||
item.app_id.clone()
|
||||
|
|
|
@ -30,17 +30,11 @@ impl Pagination {
|
|||
) -> Self {
|
||||
let scroll_box = gtk::Box::new(orientation, 0);
|
||||
|
||||
let scroll_back = IconButton::new(
|
||||
icon_context.back,
|
||||
icon_context.size,
|
||||
image_provider.clone(),
|
||||
);
|
||||
let scroll_back =
|
||||
IconButton::new(icon_context.back, icon_context.size, image_provider.clone());
|
||||
|
||||
let scroll_fwd = IconButton::new(
|
||||
icon_context.fwd,
|
||||
icon_context.size,
|
||||
image_provider.clone(),
|
||||
);
|
||||
let scroll_fwd =
|
||||
IconButton::new(icon_context.fwd, icon_context.size, image_provider.clone());
|
||||
|
||||
scroll_back.set_sensitive(false);
|
||||
scroll_fwd.set_sensitive(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue