mirror of
https://github.com/JakeStanger/ironbar.git
synced 2026-07-11 08:15:21 +01:00
[PR #831] [MERGED] feat(sysinfo): overhaul to add aggregate/unit/formatting support #975
Labels
No labels
A:Build
A:CI
A:Client
A:Config
A:Core
A:Documentation
A:Documentation
A:IPC
A:Testing
A:UX/UI
blocked
BREAKING CHANGE
duplicate
good first issue
GTK4
help wanted
invalid
M:Battery
M:Battery
M:Bindmode
M:Bluetooth
M:Brightness
M:Cairo
M:Clipboard
M:Clock
M:Clock
M:Custom
M:Focused
M:Keyboard
M:Launcher
M:Menu
M:Music
M:Music
M:Music
M:Network Manager
M:Notifications
M:SysInfo
M:Tray
M:Volume
M:Workspaces
partially resolved
P:Critical
P:High
P:Low
P:Medium
pull-request
T:Bug
T:Bug
T:Core Enhancement
T:Module Enhancement
T:New Module
T:Question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JakeStanger/ironbar#975
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/JakeStanger/ironbar/pull/831
Author: @JakeStanger
Created: 1/4/2025
Status: ✅ Merged
Merged: 2/15/2025
Merged by: @JakeStanger
Base:
master← Head:feat/sysinfo-overhaul📝 Commits (1)
01de0acfeat(sysinfo): overhaul to add aggregate/unit/formatting support📊 Changes
14 files changed (+1635 additions, -591 deletions)
View changed files
📝
Cargo.lock(+68 -37)📝
Cargo.toml(+6 -6)📝
docs/modules/Sys-Info.md(+208 -70)📝
examples/config.corn(+6 -7)📝
examples/config.json(+5 -7)📝
examples/config.toml(+5 -6)📝
examples/config.yaml(+5 -7)📝
src/clients/mod.rs(+11 -0)➕
src/clients/sysinfo.rs(+390 -0)➖
src/modules/sysinfo.rs(+0 -451)➕
src/modules/sysinfo/mod.rs(+314 -0)➕
src/modules/sysinfo/parser.rs(+460 -0)➕
src/modules/sysinfo/renderer.rs(+91 -0)➕
src/modules/sysinfo/token.rs(+66 -0)📄 Description
This completely reworks the sysinfo module to add support for aggregate functions, better support for working with individual devices, the ability to specify units, and some string formatting support.
Several new tokens have also been added, and performance should be marginally improved.
BREAKING CHANGE: Use of the
sys_infomodule in your config will need to be updated to use the new token format. See the wiki page for more info.Resolves #149.
Resolves #364.
New wiki page is below for full details:
Displays one or more labels containing system information.
Separating information across several labels allows for styling each one independently.
Pango markup is supported.
Options can be provided in a token to specify operations, units and formatting.
Configuration
formatstring[]nullintervalintegerorMap5interval.memoryinteger5interval.cpuinteger5interval.tempsinteger5interval.disksinteger5interval.networkinteger5orientation'horizontal'or'vertical'(shorthand:'h'or'v')'horizontal'direction'horizontal'or'vertical'(shorthand:'h'or'v')'horizontal'JSON
TOML
YAML
Corn
Formatting Tokens
The below table lists the tokens which can be used in the
formatconfiguration option.More information about each of these and the additional options can be found further below.
{cpu_frequency[#core]}mean.2{cpu_percent[#core]}mean0<2{memory_free}0<4.1{memory_available}0<4.1{memory_used}0<4.1{memory_total}0<4.1{memory_percent}0<4.1{swap_free}0<4.1{swap_used}0<4.1{swap_total}0<4.1{swap_percent}0<4.1{temp_c[#sensor]}max{temp_f[#sensor]}max{disk_free[#mount]}sum{disk_used[#mount]}sum{disk_total[#mount]}sum{disk_percent[#mount]}sum{disk_read[#mount]}sum{disk_write[#mount]}sum{net_down[#adapter]}sum{net_up[#adapter]}sum{load_average_1}.2{load_average_5}.2{load_average_15}.2{uptime}Functions and names
Many of the tokens operate on a value set, as opposed to an individual value:
By default, these will apply a function to the full set to reduce them down to a single value.
The list of available functions is shown below:
It is also possible to get only a single value from the set by specifying a name instead of a function.
cpu0,cpu1, ...CPUTIN. These line up with the output ofsensors./,/home, ...eth0orenp30s0.To specify a name or function, use a
@. For example, to show disk percent for/home:To show total CPU utilization where each core represents 100% (like
htopetc):Prefixes and units
For tokens which return an appropriate unit, you can specify the SI prefix (or unit in some special cases).
The following options can be supplied:
kMGTPkiMiGiTiPikbMbGbTo specify a prefix or unit, use a
#. For example, to show free total disk space in terabytes:Formatting
To control the formatting of the resultant number,
a subset of Rust's string formatting is implemented. This includes:
Formatting is specified with a
:and MUST be the last part of a token.Width
The width controls the minimum string length of the value.
Specifying just a width will left-pad the value with
0until the value reaches the target length.The width can be any value from
1-9. Larger values are not supported.For example, to render CPU usage as
045%:Fill/Alignment
These options can be used to control the
widthproperty.To specify the fill and alignment, prefix the width with a character and a direction.
Fill characters can be any single UTF-8 character EXCEPT 1-9. Alignment must be one of:
<- Left fill^- Center fill>- Right fillFor example, to render CPU usage as
45%:Precision
The number of decimal places a value is shown to can be controlled using precision.
Any value is supported.
To specify precision, include a
.followed by the value. If other options are supplied, this MUST come after.For example, to render used disk space to 2dp:
Combining Options
Each of the token options can be combined to create more complex solutions.
Putting it all together, you could show the free disk space on your
/homepartition in terabytes,left-padded with spaces to a min width of 5, and shown to 2dp as follows:
Styling
.sysinfo.sysinfo .itemFor more information on styling, please see the styling guide.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.