mirror of
https://github.com/JakeStanger/ironbar.git
synced 2026-07-11 08:15:21 +01:00
[GH-ISSUE #82] upower module #46
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#46
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?
Originally created by @dchinmay2 on GitHub (Mar 17, 2023).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/82
upower: https://upower.freedesktop.org/
can be used to listen to device events like charger connected/battery level changed instead of polling.
I want to implement this feature and am planning to use the
upower-dbuscrate@JakeStanger commented on GitHub (Mar 17, 2023):
That'd be fantastic, a battery module is something I've been meaning to add to the backlog for some time. Go for it!
@dchinmay2 commented on GitHub (Mar 17, 2023):
Thanks, this is what I have now: https://paste.sr.ht/~p00f/7061bf6067959b1c9b61f405665c9f377baed807
When I connect/disconnect the charger, the properties get printed on the terminal
This is a HashMap which has properties of the battery like percentage, time to full/empty, whether it is charging, etc
I'm having trouble implementing
into_widget, can you help me here?@dchinmay2 commented on GitHub (Mar 17, 2023):
What are the associated types
SendMessageandReceiveMessagein theModuletrait? I believeSendMessageis what the controller sends to the bar to draw? And theninto_widgetdraws from the message whenever there is a message? Is that correct?@JakeStanger commented on GitHub (Mar 17, 2023):
So the separation of controller/widget is really there for organisation, rather than functionality (at the moment at least anyway). With the current implementation, you could actually technically get away with doing all the rendering in the controller, or all the logic in
into_widget.SendMessageis pretty much what you described. The idea is the controller sends data to the widget/popup, and this is the type used to denote that.into_widgetisn't called every time you send a message, instead you need to usecontext.widget_rxand attach a callback to that. You can then do the necessary UI updates when you receive an update.ReceiveMessageis used to send events from the UI back to the controller, for example when a button is clicked. The controller can listen to itsrxto receive these and fire off any necessary logic (ie send command to client, run script...)I'd recommend having a look at the
clockmodule implementation as the simplest example. Although from your current implementation, it looks like you're pretty much there :)@dchinmay2 commented on GitHub (Mar 17, 2023):
Should the initial setup in spawn_controller be blocking or nonblocking (lines 36-44)?
I tried making everything nonblocking:
https://paste.sr.ht/~p00f/b6d7aa744218ae9466a5f96a2d89213db0c76a5c
but it crashed:
https://paste.sr.ht/~p00f/d373ae7c7fdaad64fdf1919534e05a80b009b7ca
@JakeStanger commented on GitHub (Mar 17, 2023):
Non-blocking/async is preferable, as the controller runs on the main GTK thread, so will otherwise block the UI for all bars/widgets.
The channels will error if you try to send but there is no open receiver. If you stick:
inside
into_widget, it should resolve that error (I think). And then you can obvs add your logic inside the callback.@dchinmay2 commented on GitHub (Mar 17, 2023):
Nice, thanks
@yavko commented on GitHub (May 1, 2023):
I can't use the module and the docs don't appear on the wiki, I don't know why, and I'm on latest commit.

@JakeStanger commented on GitHub (May 1, 2023):
I forgot to add the sidebar link on the wiki, that's there now. There's only two reasons I can see that it wouldn't show up there for you:
a) You're not actually on the latest commit
b) The feature flag is not enabled (it is by default, but I also forgot to stick this in the docs)
@yavko commented on GitHub (May 1, 2023):
Wait, yeah that would be why...