Skip to content

add idle inhibitor and media player#6

Open
saiddis wants to merge 10 commits intopdf:mainfrom
saiddis:main
Open

add idle inhibitor and media player#6
saiddis wants to merge 10 commits intopdf:mainfrom
saiddis:main

Conversation

@saiddis
Copy link
Copy Markdown

@saiddis saiddis commented Dec 14, 2025

image

@saiddis saiddis changed the title Idle inhibitor add idle inhibitor Dec 14, 2025
@pdf
Copy link
Copy Markdown
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
Copy Markdown
Author

saiddis commented Dec 16, 2025

Great! Appreciate it.

@pdf
Copy link
Copy Markdown
Owner

pdf commented Dec 22, 2025

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

Comment thread internal/dbus/idle_inhibitor.go Outdated
Comment on lines +31 to +34
if i.fd == 0 {
return false
}
return true
Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nit: extra newline

Comment thread internal/dbus/idle_inhibitor.go Outdated
return err
}
return nil

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nit: extra newline

Comment thread cmd/hyprpanel-client/idle_inhibitor.go Outdated

}

func (i *idleInhibitor) toggle() error {
Copy link
Copy Markdown
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
Copy Markdown
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)

Comment thread internal/dbus/idle_inhibitor.go Outdated
return true
}

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

Choose a reason for hiding this comment

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

Unused?

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

Comment thread proto/hyprpanel/event/v1/event.proto Outdated
enum InhibitTarget {
INHIBIT_TARGET_UNSPECIFIED = 0;
INHIBIT_TARGET_IDLE = 1;
INHIBIT_TARGET_SUSPEND = 2;
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread style/style.go Outdated
// HudOverlayID element identifier.
HudOverlayID = `hudOverlay`
// IdleID element identifier.
IdleInhibitorID = `idle_inhibitor`
Copy link
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

ahh, sorry)

Comment thread cmd/hyprpanel/host.go Outdated
}

func (h *host) IdleInhibitorToggle(target eventv1.InhibitTarget) error {
if i := h.dbus.IdleInhibitor(); i.IsActive() {
Copy link
Copy Markdown
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
Copy Markdown
Author

saiddis commented Dec 22, 2025

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

@saiddis
Copy link
Copy Markdown
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.

@saiddis saiddis marked this pull request as ready for review February 22, 2026 04:39
@saiddis saiddis changed the title add idle inhibitor add idle inhibitor and media player Feb 22, 2026
@saiddis saiddis requested a review from pdf March 1, 2026 07:28
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