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

Implement launch filters #369

Merged
merged 2 commits into from
Dec 29, 2024
Merged

Conversation

pol-rivero
Copy link
Contributor

@pol-rivero pol-rivero commented Dec 23, 2024

I recently installed hyprland on my laptop and realized that nwg-panel doesn't have any way to define screen "layouts". For example:

  • If I have the laptop docked, I want to have one panel/bar on each display.
    • Example: Show panel A on display A and panel B on display B.
  • When I unplug the external screens, I want to "move" some modules that were previously on the external displays "into" the bar in my laptop screen.
    • Example: Show panel C on display A. Panel C is similar to panel A, but has more modules.

The simplest way I found to allow this was to add some filters that determine if a panel will be launched, based on the displays that are currently connected.
I added 2 new panel settings:

  • "Run if outputs exist": Comma-separated list of outputs which must all be connected in order for this panel to be launched.

    • Example: On panels A and B, add the condition that display B must be connected.
  • "Run if outputs absent": Comma-separated list of outputs which must all be disconnected in order for this panel to be launched

    • Example: On panel C, add the condition that display B must be disconnected.

Since the two conditions can be combined and each allow a list of displays, I think this system is flexible enough for complex situations. Perhaps in the future it could be extended to consider monitor names instead of output (port) names.

I placed the new settings next to the Output selector:
image

Feel free to change the presentation and translations (I used ChatGPT) as you see fit.

I've seen there is a setting called "Restart on display connected" which would work nicely with this filtering feature, but it doesn't seem to work on my end, and I currently need to manually relaunch nwg-panel when I plug or unplug a monitor. Tomorrow I will investigate and see if I discover why.

@nwg-piotr
Copy link
Owner

I'll take a look as soon as I can.

@pol-rivero
Copy link
Contributor Author

No worries, take as much time as you need.

I've taken a look at "Restart on display connected" and it seems that it's only implemented on sway (on_i3ipc_event). I'll try to implement a hyprland check when I have some time.

@nwg-piotr
Copy link
Owner

it seems that it's only implemented on sway

Yes, I don't remember doing this on Hyprland.

@pol-rivero
Copy link
Contributor Author

I have added the missing "Restart on display connected" for Hyprland. It seemed suspiciously easy, so let me know any mistakes I may have made.
This PR is now ready for review. I'm especially interested in your opinion on how to best present this setting to the user, since my current solution (2 textboxes of comma-separated display names) doesn't seem all that intuitive.

@nwg-piotr
Copy link
Owner

nwg-piotr commented Dec 27, 2024

Actually I think that you may be the one and only user of these settings. It would be not bad to invent a more intuitive way to do what you want. However, I have no better idea, at least at the time. Let me play with it as is for now.

Copy link
Owner

@nwg-piotr nwg-piotr left a comment

Choose a reason for hiding this comment

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

OK, let's leave it as is, apart from one change: as this feature does not support monitor names, but only output names, and it most probably won't be used by 99% of users, I'd like the fields "Run in output exists" and "Run if outputs absent" to go the the very bottom of the config form. It would be also not bad if you could add some info on the Configuration Wiki page.

"Run if outputs exist": Comma-separated list of outputs which must all be connected in order for this panel to be launched

"Run if outputs absent": Comma-separated list of outputs which must all be disconnected in order for this panel to be launched
Implement restart on display connected/disconnected in hyprland (previously only worked in sway)
@pol-rivero
Copy link
Contributor Author

pol-rivero commented Dec 28, 2024

No problem. I've moved the new text fields to the bottom of the form and rebased the branch with the new commits from master.
Now I'll edit the wiki page.

@pol-rivero pol-rivero requested a review from nwg-piotr December 28, 2024 13:05
@nwg-piotr nwg-piotr merged commit 1a58fe3 into nwg-piotr:master Dec 29, 2024
@pol-rivero pol-rivero deleted the launch-filters branch December 29, 2024 11:52
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