Skip to content
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

nixos/sway: workaround idle inhibit not working in Firefox #348792

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

teutat3s
Copy link
Member

@teutat3s teutat3s commented Oct 15, 2024

Things done

Related to #57602 (comment).

Source: https://www.reddit.com/r/swaywm/comments/1dqud2a/how_to_get_firefox_to_inhibit_idle_when_watching/

Firefox supports the Wayland inhibit protocol, but it attempts to use the DBus interfaces first. However, the gtk portal has an issue where it returns success even though the wlr portal/sway doesn't have an implementation for the inhibit method, see flatpak/xdg-desktop-portal-gtk#465.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Oct 15, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 15, 2024
@teutat3s
Copy link
Member Author

@ofborg test sway

@JohnRTitor
Copy link
Contributor

JohnRTitor commented Oct 19, 2024

Thanks for the review request, I do not use Sway as such I can not test it. This should get some attention from sway maintainers. @Synthetica9 @RicArch97

@RicArch97
Copy link
Contributor

So is this like a "hack" to make Firefox always inhibit idle when playing audio/video, regardless of the application window state?

Something like for_window [app_id="Firefox"] inhibit_idle fullscreen already works for me to inhibit idle when watching fullscreen video, without this fix.

I think we have to be careful, to no go beyond user expectations regarding idle behavior. If Firefox is supposed to always inhibit idle while playing video's (or even just audio) regardless of application windows state, and this PR fixes that, then i think it's an OK change. Otherwise, we might have to create an extra option to toggle this new behavior.

@teutat3s
Copy link
Member Author

teutat3s commented Oct 21, 2024

This PR makes idle inhibit work in Firefox like expected, e.g. the screen will not lock when playing a video.
I don't consider it a hack like other workarounds that exist (no lock when audio is playing).

After applying this PR, this can be tested by starting a video in a tab, switching to the terminal to enter the following command, then focus back to Firefox:

echo "mouse over a Firefox window!"; sleep 2; swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused)'

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/no-sleep-while-firefox-is-running/54755/5

in Firefox

Source:
https://www.reddit.com/r/swaywm/comments/1dqud2a/how_to_get_firefox_to_inhibit_idle_when_watching/
> Firefox supports the Wayaland inhibit protocol, but it attempts to use the DBus interfaces first. However, the gtk portal has an issue where it returns success even though the wlr portal/sway doesn't have an implementation for the inhibit method, see NixOS#465.
Copy link
Member

@fpletz fpletz left a comment

Choose a reason for hiding this comment

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

Tested that this works as intended.

@teutat3s teutat3s added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Oct 24, 2024
@JohnRTitor JohnRTitor merged commit c87f82b into NixOS:master Oct 24, 2024
26 checks passed
Copy link
Contributor

Successfully created backport PR for release-24.05:

@midirhee12
Copy link
Member

@teutat3s This is incorrect. xdg.portal.config.sway.default should still be lib.mkDefault [ "wlr" "gtk" ]. You cannot only have gtk; you also need wlr portal. Also, you should have added the mkDefault. Now users of the module cannot modify the portals when necessary.

@JohnRTitor
Copy link
Contributor

Yes, only apply it to xdg.portal.config.sway.default would have been appropiate, my mistake for not pointing that out!

@SuperSandro2000
Copy link
Member

Now users of the module cannot modify the portals when necessary.

What is the usecase to not have gtk and wlr without using mkForce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants