Skip to content

Conversation

@saiddis
Copy link

@saiddis saiddis commented Dec 14, 2025

image

@saiddis saiddis changed the title Idle inhibitor add idle inhibitor Dec 14, 2025
@pdf
Copy link
Owner

pdf commented Dec 16, 2025

Hi, thanks for this, I will find some time to review on the weekend, but looks pretty good at a glance.

@saiddis
Copy link
Author

saiddis commented Dec 16, 2025

Great! Appreciate it.

@pdf
Copy link
Owner

pdf commented Dec 22, 2025

Please split the taskbar fix off to a separate PR, other comments inline.

Comment on lines 31 to 34
if i.fd == 0 {
return false
}
return true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if i.fd == 0 {
return false
}
return true
return i.fd != 0

}
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline

return err
}
return nil

Copy link
Owner

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 {
Copy link
Owner

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.

Copy link
Author

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)

return true
}

func (i *idleInhibitor) String() string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Copy link
Author

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 {
Copy link
Owner

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.

Copy link
Author

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{}),
Copy link
Owner

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).

enum InhibitTarget {
INHIBIT_TARGET_UNSPECIFIED = 0;
INHIBIT_TARGET_IDLE = 1;
INHIBIT_TARGET_SUSPEND = 2;
Copy link
Owner

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?

Copy link
Author

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`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase not snake_case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, sorry)

}

func (h *host) IdleInhibitorToggle(target eventv1.InhibitTarget) error {
if i := h.dbus.IdleInhibitor(); i.IsActive() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs nil check.

@saiddis saiddis marked this pull request as draft December 22, 2025 18:43
@saiddis
Copy link
Author

saiddis commented Dec 22, 2025

Your feedback was very helpful, I will fix the issues you mentioned and comeback. Thanks!

@saiddis
Copy link
Author

saiddis commented Jan 1, 2026

Hi! I fixed the issues with state propagation and added a popup menu to choose any of the available inhibit targets Lock, Suspend, Shutdown. Right click shows up the menu and the left click toggles between default target turning on and all other targets turning off. The default target can be changed in config, which by default is set to Lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants