-
Notifications
You must be signed in to change notification settings - Fork 6
add idle inhibitor #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi, thanks for this, I will find some time to review on the weekend, but looks pretty good at a glance. |
|
Great! Appreciate it. |
|
Please split the taskbar fix off to a separate PR, other comments inline. |
internal/dbus/idle_inhibitor.go
Outdated
| if i.fd == 0 { | ||
| return false | ||
| } | ||
| return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if i.fd == 0 { | |
| return false | |
| } | |
| return true | |
| return i.fd != 0 |
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra newline
internal/dbus/idle_inhibitor.go
Outdated
| return err | ||
| } | ||
| return nil | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra newline
|
|
||
| } | ||
|
|
||
| func (i *idleInhibitor) toggle() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This widget may exist multiple times, or on multiple panels. Rather than toggling based local state for each widget instance, state should be propagated to the widget via an event on state update (push to the internal event bus from the dbus module would be easiest, see the Power or Audio modules for examples), otherwise widgets will be out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think about that, I will fix it)
internal/dbus/idle_inhibitor.go
Outdated
| return true | ||
| } | ||
|
|
||
| func (i *idleInhibitor) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to make a menu with options for each target for inhibiting, but didn't have enough time.
|
|
||
| func (i *idleInhibitor) Inhibit(target eventv1.InhibitTarget) error { | ||
| var what string | ||
| switch target { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the difference in string values between these cases and the previous String() method?
Also, prefer const declarations for these string values, rather than inline value declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I thought it would be interesting if I add all possible inhibit targets: shutdown, sleep and idle. "idle" option prevents from locking and suspending, "sleep" from suspend only, and "shutdown" is the strongest option, which as I read, doesn't let to poweroff and reboot.
The String() method I thought would serve as a label for the options of inhibitor, and also use as arguments for org.freedesktop.ScreenSaver.Inhibit method, which as it turned out, doesn't affect hypridle.
| eventCh: eventCh, | ||
| signals: make(chan *dbus.Signal), | ||
| readyCh: make(chan struct{}), | ||
| quitCh: make(chan struct{}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have an fd to clean up, this will need to be closed if the dbus manager is closed. I'm afraid you may have inherited the lack of cleanup behaviour from one of the other dbus modules in this codebase since a number of of those do not handle close correctly (I have a change on my local dev branch to clean up how this is managed, but for now check statusNotifierWatcher#close() for an example of how this might be done currently).
proto/hyprpanel/event/v1/event.proto
Outdated
| enum InhibitTarget { | ||
| INHIBIT_TARGET_UNSPECIFIED = 0; | ||
| INHIBIT_TARGET_IDLE = 1; | ||
| INHIBIT_TARGET_SUSPEND = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names should probably match the DBUS targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they matched values for org.freedesktop.ScreenSaver.Inhibit which did not work
style/style.go
Outdated
| // HudOverlayID element identifier. | ||
| HudOverlayID = `hudOverlay` | ||
| // IdleID element identifier. | ||
| IdleInhibitorID = `idle_inhibitor` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase not snake_case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, sorry)
cmd/hyprpanel/host.go
Outdated
| } | ||
|
|
||
| func (h *host) IdleInhibitorToggle(target eventv1.InhibitTarget) error { | ||
| if i := h.dbus.IdleInhibitor(); i.IsActive() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs nil check.
|
Your feedback was very helpful, I will fix the issues you mentioned and comeback. Thanks! |
|
Hi! I fixed the issues with state propagation and added a popup menu to choose any of the available inhibit targets |
Uh oh!
There was an error while loading. Please reload this page.