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

Sort by recently used Windows #5

Closed
aloispichler opened this issue Nov 20, 2023 · 19 comments · Fixed by #6 or #13
Closed

Sort by recently used Windows #5

aloispichler opened this issue Nov 20, 2023 · 19 comments · Fixed by #6 or #13
Assignees

Comments

@aloispichler
Copy link

aloispichler commented Nov 20, 2023

Instead of sorting, is it possible to toggle along the history of activated windows (back, and forward); that is, in most-recently-used order?
This is actually the default behavior in most other alttabs (cf. https://github.com/sagb/alttab).

@H3rmt
Copy link
Owner

H3rmt commented Nov 24, 2023

I'm not entirely sure if Hyprland has the capability to return a list of recently visited windows, i'll get back to you once I've gathered more information on this.

@aloispichler
Copy link
Author

aloispichler commented Nov 25, 2023

Thank you. If this information is not provided by hyprland itself, then it would be a good escape to just use the windowswitcher’s most-recently-used order. Thank you for this useful app!

@H3rmt H3rmt changed the title alt+tab Sort by recently used Windows Nov 28, 2023
@H3rmt

This comment has been minimized.

@aloispichler
Copy link
Author

I would desperately need this functionality.

@aloispichler
Copy link
Author

aloispichler commented Dec 9, 2023

The last property in hyprctrl clients is focusHistoryID and it does the job. This is exactly how windows should get sorted. I hope this will help!

@H3rmt H3rmt self-assigned this Dec 15, 2023
@H3rmt
Copy link
Owner

H3rmt commented Dec 15, 2023

The problem with implementing this feature is that hyprland-rs (the library used to interface with Hyprland) currently doesn't support focusHistoryID in the latest release.
There is a commit that adds support for it (hyprland-community/hyprland-rs@00505b0). However, a previous commit in version 0.3.12 breaks Client::get_active() (hyprland-community/hyprland-rs#124), preventing me from using this newer version.

@aloispichler
Copy link
Author

Seems that you are working on this option, which I really appreciate. Thank you.

The role model is of course the option ’Ctrl+Tab cycles through tabs in recently used order’ in firefox,
which enables ‘Ctrl+Tab’ and ‘Ctrl+Shift+Tab’.

@H3rmt H3rmt closed this as completed in #6 Feb 3, 2024
H3rmt added a commit that referenced this issue Feb 3, 2024
adding args to allow for sorting by recent windows (#5)
@H3rmt H3rmt reopened this Feb 3, 2024
@H3rmt
Copy link
Owner

H3rmt commented Feb 3, 2024

sorting by recently used windows is now supported, but using it will just cycle through the current and last used window, as the order of focused windows changes on first execution

@H3rmt
Copy link
Owner

H3rmt commented Feb 5, 2024

@aloispichler there might be the a better solution available when running in daemon-mode.
The Daemon could load the order in which windows were selected on start, so you could switch to e.g. the 3. most recently used window.
I don't see a possibility for implementing this in CLI mode because the script wouldn't know whether to use the previous or the current order.
However, you could use the --offset option to directly switch to the 3rd element, but this doesn't seem practical to me.

(the --offset option and daemon/gui mode will be available in the next release)

@H3rmt H3rmt closed this as completed in #13 Feb 25, 2024
H3rmt added a commit that referenced this issue Feb 25, 2024
added Sort by recently used Windows (#5)
@aloispichler
Copy link
Author

Seems to be some excellent work which I will try soon. Look forward to seeing the Arch package!

@H3rmt
Copy link
Owner

H3rmt commented Feb 25, 2024

added in latest release

@aloispichler
Copy link
Author

aloispichler commented Feb 26, 2024

I was working with your app today. Nice experience, indeed! Thank you. I used the AUR-version.
Here are few points:

  • If --sort-recent is selected, then the GUI should --sort-recent as well.
  • Cycling (i.e., $mod+key) should NOT reveal the window: the window should reveal only after being finally selected and the daemon stops.
  • It would be desirable to select the next window by $mod+$key+…+$key$ at key release. Now, this is $mod+key$, …, $mod+key$ and $mod$ (extra release) to stop the deamon.

All three points above are the default behavior of Ctrl-Tab in Firefox (with setting 'Ctrl+Tab cycles through tabs in recently used order').
Overall: very pleasant experience, thanks again!

@H3rmt
Copy link
Owner

H3rmt commented Feb 26, 2024

Cycling (i.e., $mod+key) should NOT reveal the window: the window should reveal only after being finally selected and the daemon stops.

adding a --switch-on-close flag that executes the switch when closing the daemon would solve this.
But as this should most likely be the default so we would need a flag to trigger a switch on every received command (TODO find good name)

@H3rmt
Copy link
Owner

H3rmt commented Feb 26, 2024

It would be desirable to select the next window by $mod+$key+…+$key$ at key release. Now, this is $mod+key$, …, $mod+key$ and $mod$ (extra release) to stop the deamon.

If i understand this correctly you currently use the GUI Config.
Repeated switching without releasing the $mod key / holding $key is possible with the GUI + Keyboard Config. (This however stops the daemon after releasing the $mod key, so you $mod+$key+…+$key-$mod to switch and close) (This currently switches at every command and not after the daemon exits)

@H3rmt
Copy link
Owner

H3rmt commented Feb 26, 2024

Could you provide the part of your hyprland config that calls hyprswitch?
This would allow me to debug the first Problem you mentioned

@aloispichler
Copy link
Author

I use:

# open hyprswitch
$key = TAB
$modifier = SUPER
$switch_release = SUPER_L
$reverse = SHIFT

# open hyprswitch
bind=$modifier, $key, exec, hyprswitch --ignore-workspaces --sort-recent --do-initial-execute --daemon
bind=$modifier $reverse, $key, exec, hyprswitch --ignore-workspaces --sort-recent --do-initial-execute --daemon -r

# close hyprswitch
bindr=$modifier, $switch_release, exec, hyprswitch --stop-daemon

@H3rmt
Copy link
Owner

H3rmt commented Feb 26, 2024

This config is intended to be used if you want to click on the windows in the GUI

If you want to want a config with more default keyboard shortcuts you could try the GUI + Keyboard Config. (GIU + Keyboard uses the GUI to visualise what window has which offset and what window would be released in Exit, whereas the GUI Config should function more like the window Overview of Gnome/Windows/etc.)

If you just want to be able to hold down the $key key to continue switching windows without pressing the $modifier key every time you, should use binde=$modifier, $key, ... (the e repeats the command)

@aloispichler
Copy link
Author

aloispichler commented Feb 26, 2024

Aaaah, yes indeed, amazing!
I use the GUI + Keyboard Config and it has the desired behavior.
I am sorry I have misunderstood the usage in the read.me, my fault.
I really like this app.

@H3rmt
Copy link
Owner

H3rmt commented Feb 26, 2024

If --sort-recent is selected, then the GUI should --sort-recent as well.

Could you try to try to give more detailed explanation on what you did, what happened and what you expected to happen (maybe in a new issue?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants