-
-
Notifications
You must be signed in to change notification settings - Fork 968
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
Feat: Add new optional "default command" for auto-launching apps on new workspaces #3559
Feat: Add new optional "default command" for auto-launching apps on new workspaces #3559
Conversation
you can already open programs on a workspace at start with that being said, the option of doing this as a workspace rule, despite giving less freedom, might be worth considering |
I don't think that's a realitic comparison to this feature. I personally work with low-memory devices and can't afford to keep apps open just for the convenience of access. Not to mention even idle apps can be hogs to a laptop's battery.
I'm curious about what you mean by "giving less freedom". The implementation specifically levarages from the same function that handles the |
With current implementation you can chose to open the workspace with, without or even with different commands |
I'm sorry, I still didn't get it 😅 ! I'm not sure if this is the adequate answer to your point, but if it helps: the new parameter is optional, so you can still move to workspaces without triggering a command, like the following:
|
To me it sounds like something niche enough that it would be better off as a plugin or a script, not part of the main project. |
i mean something like
instead of
the workspace rule implementation would not allow for this separate behavior |
I hope it doesn't come off as me being rude or overprotective of this PR, but I do think this could be said about a lot of features Hyprland offers when compared to other compositors such as Sway. However, I believe that it's exactly because Hyprland does a lot that it's such a blast to use; it magically seems to fit to everyone's needs. With that being said, while you believe this is niche enough to be a plugin, I think it would be quite the overkill to make a plugin specifically for this functionality. After all, the changes only add a couple extra operations to the process of moving to a new workspace, which can pretty much be considered negligible both in performance and maintenance costs. Would love to hear your opinion on this, though. |
Oh, gotcha! I initially misunderstood it when you said "workspace rule"; I had completely forgotten about these. That said, I'm also unsure of where this feature would be better implemented at. I'm still leaning towards the behavior implemented in this PR because the syntax the new parameter follows is the same as |
I'd just like to point out that it is pretty common to see in r/unixporn, for instance, setups in which each workspace is represented as an icon to a specific purpose, such as web browsing, as suggested by @Syndelis, or coding/programming, instant messaging, reading, content creation, so forth and so on. This feature would allow for a more out-of-the-box configuration experience, in which one could lean on a highly efficient implementation (as opposed to the vast majority of alternative solutions) and not have to write their own scripts for quality of life functionality. I agree with @MightyPlaza on whether it is worth considering to implement this feature as a workspace rule, as it does make sense to couple this kind of behavior to the workspace itself. On the other hand, I'd also take into consideration that by coupling it to a workspace switch bind instead, one could use different binds to open different applications with the same overall purpose in the same specific workspace, if so desired. One use case I have in mind is having mutiple browsers to open on a workspace specific for web app testing purposes. |
I am in favor of this being in a workspace rule. Also I was thinking, on a tangent, maybe we should allow mixing workspace rules? 🤔 |
Based on the feedback initially given by @MightyPlaza and supported by @GabrielFoxDev and @vaxerski, commit 0bbad21 removes the optional parameters from the dispatchers and introduces a new workspace rule that serves the same purpose. The PR's description has been slightly altered to match the new implementation, and a new demo video reflecting the change has been linked. As a sidenote, a cool side effect this change introduced is that switching to a workspace using relative IDs (r+1, e+1, etc) also trigger the effect, which would previously not be possible. Thanks again for the feedback, @MightyPlaza! |
Wouldn't it be better to take a dispatcher, so you could do other things separate from starting a new program?
|
|
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.
rest is lgtm, except it needs a clang-format
I'd hesitated to use it at first because it touched a few lines that I hadn't changed myself. Eitherway, I've ran it and committed the changes in 1c3746f |
I know, for some reason clang-format on my desktop behaves a bit weirdly. |
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.
lgtm, thanks!
soulja.boy.mp4
we just need a wiki mr |
Sure thing, will open it and link it here! Thanks Edit: I've opened the PR in hyprwm/hyprland-wiki#375 |
the new workspace rule is being introduced in hyprwm/Hyprland#3559
the new workspace rule is being introduced in hyprwm/Hyprland#3559
the new workspace rule is being introduced in hyprwm/Hyprland#3559
Describe your PR, what does it fix/add?
Update 13/10/2023
The PR has been updated to introduce a workspace rule as suggested below, rather than an additional parameter to the
workspace
andtogglespecialworkspace
dispatchers.About this PR
This PR introduces a new workspace rule that allows the user to define a command to be run when switching to a new workspace.
The command gets passed to
spawn()
, which is virtually equivalent to callinghyprctl dispatch exec "<your_command>"
. This means that you can also use the same execution rules thatexec
supports. It's worth noting that the execution ruleworkspace <workspacename>
is explicitly overwritten to the workspace the rule has been attributed to. Even if you didn't set it, it will be set automatically.This required two new methods to be added to
VarList
:append
andmap
.The Motivation
My biggest use case for special workspaces is to quickly use and hide a terminal, and I absolutely adore Hyprland for having those. However, the setup requires me to 1) launch a terminal and 2) move it to the special workspace. With this feature, I can always press the special workspace shortcut and launch a terminal if there wasn't one already.
I can also see
more organizedother people use this to auto-launch their favorite browser when switching to their designated "Browser" workspace."But you can achieve the same with a script/other shortcut"
Indeed, but the beauty of Hyprland (to me, at least) is how much convenience it brings out-of-the-box, with key manager, device settings and (of course) animations. I believe this is one more convenience most would find useful.
Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Nothing that comes to mind.
Is it ready for merging, or does it need work?
Ready for merging.
Demo Video
hyprland_workspace_rule_cmd_h264.mp4
Configuration used in the video