1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-02 03:01:04 +02:00

Merge branch 'JakeStanger:master' into feat/networkmanager

This commit is contained in:
Reinout Meliesie 2024-02-13 15:55:16 +01:00 committed by GitHub
commit 3e9cf85c2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 125 additions and 54 deletions

View file

@ -4,6 +4,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v0.14.1] - 2024-02-10
### :bug: Bug Fixes
- [`1c9c9bb`](https://github.com/JakeStanger/ironbar/commit/1c9c9bbece878286939abacfaec0daaecc559243) - **cli**: error when launched via `swaybar_command` *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`976dd6c`](https://github.com/JakeStanger/ironbar/commit/976dd6c55a5881b2b3c60c6d7e13b0e7d4301599) - **style**: file watcher not working for relative paths *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`4d9d78f`](https://github.com/JakeStanger/ironbar/commit/4d9d78f4caa998b4817de2d77c0f7362de318c52) - **dynamic string**: ironvar parser being too greedy *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`63304a9`](https://github.com/JakeStanger/ironbar/commit/63304a9ddd76b2274b8336eba7e1e5ef7c5d66e6) - **dynamic string**: always sending partial string on initialization *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`8016ec2`](https://github.com/JakeStanger/ironbar/commit/8016ec256de0c3d2290d1446cda45a769a3c5284) - **tray**: crash caused by excess updates *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`b3a70ce`](https://github.com/JakeStanger/ironbar/commit/b3a70ce8fa76b0ae8b06f423e7d5955c6d5d6920) - **tray**: not handling checkbox items *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`0616633`](https://github.com/JakeStanger/ironbar/commit/061663392e01503448fb44a064d172dbf10dc770) - do not panic on full channels *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`133632d`](https://github.com/JakeStanger/ironbar/commit/133632d1ad0778bb93e398e6d2bacf28c364f6c4) - **tray**: vastly improve rendering performance *(commit by [@JakeStanger](https://github.com/JakeStanger))*
### :recycle: Refactors
- [`996ad7e`](https://github.com/JakeStanger/ironbar/commit/996ad7e27f3a397f4650a6a746155cd22d6ccdb7) - **desktop file**: simplify some none-type handling *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`aaef3bf`](https://github.com/JakeStanger/ironbar/commit/aaef3bf96cebb3540b3b020891f88d3c5515034b) - fix new strict clippy warnings *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`f3687c5`](https://github.com/JakeStanger/ironbar/commit/f3687c5f9e69452bbc9c1fa87089f3a8afd9bfc0) - replace deprecated indexmap method *(commit by [@JakeStanger](https://github.com/JakeStanger))*
### :white_check_mark: Tests
- [`af7e037`](https://github.com/JakeStanger/ironbar/commit/af7e037dd5a24cff0959e2fd5f04e3eb49418b23) - **dynamic string**: test pango attributes with ironvars *(commit by [@JakeStanger](https://github.com/JakeStanger))*
### :memo: Documentation Changes
- [`7d51155`](https://github.com/JakeStanger/ironbar/commit/7d51155a3e6e6e1d77f2e3d2b8e6c73831b15c0e) - update CHANGELOG.md for v0.14.0 [skip ci] *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`754e339`](https://github.com/JakeStanger/ironbar/commit/754e33952eaf7794d00c831c46aab007684ff0b2) - add info on speeding up compilation time *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`cb2f9b0`](https://github.com/JakeStanger/ironbar/commit/cb2f9b0aaff1519516664ab04a3a195d29983b4e) - **examples**: fix issues with example css *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`1b54276`](https://github.com/JakeStanger/ironbar/commit/1b54276bea6268131fca7c3f453284ca0aee4b9b) - **compilation**: add sccache section *(commit by [@JakeStanger](https://github.com/JakeStanger))*
- [`9d7cb08`](https://github.com/JakeStanger/ironbar/commit/9d7cb08f41e7290959e17ccd725aeb6ccaeef1a7) - **ironvars**: correct allowed chars in keys *(commit by [@JakeStanger](https://github.com/JakeStanger))*
## [v0.14.0] - 2024-01-20
### :sparkles: New Features
- [`25c490b`](https://github.com/JakeStanger/ironbar/commit/25c490b8b426176c1a4c9d402aafd6783c9b6d48) - **workspaces**: visible CSS selector *(commit by [@malicean](https://github.com/malicean))*
@ -477,3 +504,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[v0.12.1]: https://github.com/JakeStanger/ironbar/compare/v0.12.0...v0.12.1
[v0.13.0]: https://github.com/JakeStanger/ironbar/compare/v0.12.1...v0.13.0
[v0.14.0]: https://github.com/JakeStanger/ironbar/compare/v0.13.0...v0.14.0
[v0.14.1]: https://github.com/JakeStanger/ironbar/compare/v0.14.0...v0.14.1

56
Cargo.lock generated
View file

@ -429,9 +429,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.31"
version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -439,14 +439,14 @@ dependencies = [
"num-traits",
"pure-rust-locales",
"wasm-bindgen",
"windows-targets 0.48.0",
"windows-targets 0.52.0",
]
[[package]]
name = "clap"
version = "4.4.18"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c"
checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f"
dependencies = [
"clap_builder",
"clap_derive",
@ -454,21 +454,21 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.18"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7"
checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
"strsim 0.11.0",
]
[[package]]
name = "clap_derive"
version = "4.4.7"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47"
dependencies = [
"heck 0.4.1",
"proc-macro2",
@ -478,9 +478,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
name = "codespan-reporting"
@ -698,7 +698,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote 1.0.35",
"strsim",
"strsim 0.10.0",
"syn 1.0.109",
]
@ -1579,9 +1579,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.2.1"
version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
dependencies = [
"equivalent",
"hashbrown 0.14.1",
@ -1635,7 +1635,7 @@ checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f"
[[package]]
name = "ironbar"
version = "0.14.1-pre"
version = "0.15.0-pre"
dependencies = [
"cfg-if",
"chrono",
@ -1649,7 +1649,7 @@ dependencies = [
"gtk",
"gtk-layer-shell",
"hyprland",
"indexmap 2.2.1",
"indexmap 2.2.3",
"mpd-utils",
"mpris",
"nix 0.27.1",
@ -2334,9 +2334,9 @@ dependencies = [
[[package]]
name = "pure-rust-locales"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed02a829e62dc2715ceb8afb4f80e298148e1345749ceb369540fe0eb3368432"
checksum = "1190fd18ae6ce9e137184f207593877e70f39b015040156b1e05081cdfe3733a"
[[package]]
name = "quick-xml"
@ -2688,9 +2688,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.111"
version = "1.0.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4"
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
dependencies = [
"itoa",
"ryu",
@ -2809,9 +2809,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "smithay-client-toolkit"
version = "0.18.0"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f"
checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a"
dependencies = [
"bitflags 2.4.0",
"calloop",
@ -2873,6 +2873,12 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strsim"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
[[package]]
name = "strum"
version = "0.26.1"
@ -3222,7 +3228,7 @@ version = "0.19.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
dependencies = [
"indexmap 2.2.1",
"indexmap 2.2.3",
"serde",
"serde_spanned",
"toml_datetime",
@ -3235,7 +3241,7 @@ version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
dependencies = [
"indexmap 2.2.1",
"indexmap 2.2.3",
"toml_datetime",
"winnow",
]

View file

@ -1,6 +1,6 @@
[package]
name = "ironbar"
version = "0.14.1-pre"
version = "0.15.0-pre"
edition = "2021"
license = "MIT"
description = "Customisable GTK Layer Shell wlroots/sway bar"
@ -88,14 +88,14 @@ tracing-appender = "0.2.3"
strip-ansi-escapes = "0.2.0"
color-eyre = "0.6.2"
serde = { version = "1.0.196", features = ["derive"] }
indexmap = "2.2.1"
indexmap = "2.2.3"
dirs = "5.0.1"
walkdir = "2.4.0"
notify = { version = "6.1.1", default-features = false }
wayland-client = "0.31.1"
wayland-protocols = { version = "0.31.0", features = ["unstable", "client"] }
wayland-protocols-wlr = { version = "0.2.0", features = ["client"] }
smithay-client-toolkit = { version = "0.18.0", default-features = false, features = [
smithay-client-toolkit = { version = "0.18.1", default-features = false, features = [
"calloop",
] }
universal-config = { version = "0.4.3", default_features = false }
@ -103,10 +103,10 @@ ctrlc = "3.4.2"
cfg-if = "1.0.0"
# cli
clap = { version = "4.4.18", optional = true, features = ["derive"] }
clap = { version = "4.5.0", optional = true, features = ["derive"] }
# ipc
serde_json = { version = "1.0.111", optional = true }
serde_json = { version = "1.0.113", optional = true }
# http
reqwest = { version = "0.11.24", optional = true }
@ -115,7 +115,7 @@ reqwest = { version = "0.11.24", optional = true }
nix = { version = "0.27.1", optional = true, features = ["event"] }
# clock
chrono = { version = "0.4.31", optional = true, features = ["unstable-locales"] }
chrono = { version = "0.4.34", optional = true, features = ["unstable-locales"] }
# music
mpd-utils = { version = "0.2.0", optional = true }

View file

@ -10,8 +10,8 @@ Clicking on the widget opens a popup with the time and a calendar.
| Name | Type | Default | Description |
|----------------|----------|------------------------------------|-------------------------------------------------------------------------------------|
| `format` | `string` | `%d/%m/%Y %H:%M` | Date/time format string. |
| `format_popup` | `string` | `%H:%M:%S` | Date/time format string to display in the popup header. |
| `format` | `string` | `%d/%m/%Y %H:%M` | Date/time format string. Pango markup is supported. |
| `format_popup` | `string` | `%H:%M:%S` | Date/time format string to display in the popup header. Pango markup is supported. |
| `locale` | `string` | `$LC_TIME` or `$LANG` or `'POSIX'` | Locale to use (eg `en_GB`). Defaults to the system language (reading from env var). |
> Detail on available tokens can be found here: <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>

View file

@ -69,6 +69,17 @@ end:
</details>
### Formatting Tokens
The following tokens can be used in the `format` config option,
and will be replaced with values from the current battery state:
| Token | Description |
|----------------|------------------------------------------|
| `{percentage}` | The battery charge percentage. |
| `{state}` | The current battery (dis)charging state. |
| `{remaining}` | The ETA to battery empty or full. |
## Styling
| Selector | Description |

View file

@ -99,8 +99,10 @@ impl Module<Button> for ClockModule {
info: &ModuleInfo,
) -> Result<ModuleParts<Button>> {
let button = Button::new();
let label = Label::new(None);
label.set_angle(info.bar_position.get_angle());
let label = Label::builder()
.angle(info.bar_position.get_angle())
.use_markup(true)
.build();
button.add(&label);
let tx = context.tx.clone();
@ -132,7 +134,10 @@ impl Module<Button> for ClockModule {
) -> Option<gtk::Box> {
let container = gtk::Box::new(Orientation::Vertical, 0);
let clock = Label::builder().halign(Align::Center).build();
let clock = Label::builder()
.halign(Align::Center)
.use_markup(true)
.build();
clock.add_class("calendar-clock");
container.add(&clock);

View file

@ -15,7 +15,7 @@ use crate::modules::PopupButton;
use crate::modules::{
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, WidgetContext,
};
use crate::{error, glib_recv, send_async, spawn, try_send};
use crate::{glib_recv, send_async, spawn, try_send};
const DAY: i64 = 24 * 60 * 60;
const HOUR: i64 = 60 * 60;
@ -45,7 +45,7 @@ const fn default_icon_size() -> i32 {
pub struct UpowerProperties {
percentage: f64,
icon_name: String,
state: u32,
state: BatteryState,
time_to_full: i64,
time_to_empty: i64,
}
@ -84,9 +84,12 @@ impl Module<gtk::Button> for UpowerModule {
.downcast_ref::<str>()
.expect("expected IconName: str in HashMap of all properties")
.to_string();
let state = *properties["State"]
.downcast_ref::<u32>()
.expect("expected State: u32 in HashMap of all properties");
let state = u32_to_battery_state(
*properties["State"]
.downcast_ref::<u32>()
.expect("expected State: u32 in HashMap of all properties"),
)
.unwrap_or(BatteryState::Unknown);
let time_to_full = *properties["TimeToFull"]
.downcast_ref::<i64>()
.expect("expected TimeToFull: i64 in HashMap of all properties");
@ -123,9 +126,9 @@ impl Module<gtk::Button> for UpowerModule {
.to_string();
}
"State" => {
properties.state = changed_value
.downcast::<u32>()
.expect("expected State to be u32");
properties.state =
u32_to_battery_state(changed_value.downcast::<u32>().unwrap_or(0))
.expect("expected State to be BatteryState");
}
"TimeToFull" => {
properties.time_to_full = changed_value
@ -185,7 +188,17 @@ impl Module<gtk::Button> for UpowerModule {
let rx = context.subscribe();
glib_recv!(rx, properties => {
let format = format.replace("{percentage}", &properties.percentage.to_string());
let state = properties.state;
let is_charging = state == BatteryState::Charging || state == BatteryState::PendingCharge;
let time_remaining = if is_charging {
seconds_to_string(properties.time_to_full)
}
else {
seconds_to_string(properties.time_to_empty)
};
let format = format.replace("{percentage}", &properties.percentage.to_string())
.replace("{time_remaining}", &time_remaining)
.replace("{state}", battery_state_to_string(state));
let icon_name = String::from("icon:") + &properties.icon_name;
ImageProvider::parse(&icon_name, &icon_theme, false, self.icon_size)
@ -220,9 +233,9 @@ impl Module<gtk::Button> for UpowerModule {
container.add(&label);
glib_recv!(rx, properties => {
let state = u32_to_battery_state(properties.state);
let state = properties.state;
let format = match state {
Ok(BatteryState::Charging | BatteryState::PendingCharge) => {
BatteryState::Charging | BatteryState::PendingCharge => {
let ttf = properties.time_to_full;
if ttf > 0 {
format!("Full in {}", seconds_to_string(ttf))
@ -230,7 +243,7 @@ impl Module<gtk::Button> for UpowerModule {
String::new()
}
}
Ok(BatteryState::Discharging | BatteryState::PendingDischarge) => {
BatteryState::Discharging | BatteryState::PendingDischarge => {
let tte = properties.time_to_empty;
if tte > 0 {
format!("Empty in {}", seconds_to_string(tte))
@ -238,10 +251,6 @@ impl Module<gtk::Button> for UpowerModule {
String::new()
}
}
Err(state) => {
error!("Invalid battery state: {state}");
String::new()
}
_ => String::new(),
};
@ -290,3 +299,15 @@ const fn u32_to_battery_state(number: u32) -> Result<BatteryState, u32> {
Err(number)
}
}
fn battery_state_to_string(state: BatteryState) -> &'static str {
match state {
BatteryState::Unknown => "Unknown",
BatteryState::Charging => "Charging",
BatteryState::Discharging => "Discharging",
BatteryState::Empty => "Empty",
BatteryState::FullyCharged => "Fully charged",
BatteryState::PendingCharge => "Pending charge",
BatteryState::PendingDischarge => "Pending discharge",
}
}