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

[REQUEST] Custom order of window list. #1965

Open
2 tasks done
arakis opened this issue Mar 17, 2024 · 11 comments
Open
2 tasks done

[REQUEST] Custom order of window list. #1965

arakis opened this issue Mar 17, 2024 · 11 comments
Labels
Feature Request Incomplete Report - Please follow the guidelines Your report is incomplete and does not follow the guidelines, you may not expect an answer

Comments

@arakis
Copy link

arakis commented Mar 17, 2024

Before opening a feature request

  • I checked the next branch to see if the feature has already been implemented
  • I searched existing reports to see if it is already requested.

What is the user problem or growth opportunity you want to see solved?

I would like to have a custom order in the window list, specifically a MRU (Most Recently Used) list.

I already have an i3 IPC listener that tracks the MRU list. Now, I would like to pass the window IDs to Rofi, for example via a command like -window-ids 123,124,125,126. If a window ID is invalid, it should be ignored. If a window ID is missing, the rendering should be skipped - with this latter behavior, you also have control over whether the windows are workspace, screen, or otherwise scoped.

Another approach could be to add a sort script: Pass all entries as standard input to a script, and that script returns a list of indexes as standard output. In this case, the standard input should contain some metadata, like window IDs.

I have also considered using script mode or dmenu mode. However, I'm not sure how complicated it would be to track all icons of the active windows, retrieve the path of the icon files, and pass them to the script mode - and this process would have to be very efficient, of course.

How do you know that this problem exists today? Why is this important?

In i3, the order of the windows depends on the container layout.

Who will benefit from it?

Everybody who wishes a MRU based list.

Rofi version (rofi -v)

1.7.5

Configuration

Additional information

No response

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 17, 2024

Can't you implement this easily using script mode and i3's ipc?
I wonder if we can help with the icon for an application in a way.
(looking up icon for window class would be easy, I wonder if we can implement something to fetch icon for window id).

@DaveDavenport DaveDavenport added the Incomplete Report - Please follow the guidelines Your report is incomplete and does not follow the guidelines, you may not expect an answer label Mar 17, 2024
@arakis
Copy link
Author

arakis commented Mar 18, 2024

Implementing via script mode and IPC would work, but as you said, I need an efficient and safe way to show the icons.

@arakis
Copy link
Author

arakis commented Mar 18, 2024

By the way, I also see that the original window list has some additional features/columns: Workspace number, and separate columns for Process name and Window Title.

So, it might be challenging to mimic this list one-to-one, solely for custom order.

@arakis
Copy link
Author

arakis commented Mar 18, 2024

There might be another issue with script mode: it can be quite slow, especially when running in notebook power-saving mode.

#!/usr/bin/env bash

# https://gist.github.com/Atreyagaurav/2b70bb997fa5eff45c924e86095080e8

$(jq -r '.scripts | .["'$(jq -r '.scripts|keys[]' \
                             ~/.config/rofi/scripts/custom-menu.json \
                              | rofi -dmenu)'"] |.script' \
     ~/.config/rofi/scripts/custom-menu.json)
{
  "bgcolor": "black",
  "scripts": {
    "rdp-arakis": {
      "name": "RDP Arakis",
      "script": "/home/sebastian/.scripts/launch-rdp-arakis.sh",
      "tooltip": "RDP Arakis"
    }
  }
}

When launching the aforementioned script, rofi will be displayed immediately - but it can take up to 2 seconds until the list is filled (in this case, a single entry), when in power save mode. When plugged into power, the list will be filled immediately.

In contrast to the window list: This mode will always be rendered immediately, without noticing any delay, regardless of the power mode.

For a window switcher, any delay will kill the user experience.

So, passing the order of window-id's via command line may still be the most performant way.

@lbonn
Copy link
Collaborator

lbonn commented Mar 18, 2024

@arakis this may interest you: https://github.com/lbonn/i3-focus-last, it uses dmenu mode.

I am also working on a rofi plugin version (in the repo as well) which mostly works but still needs a bit of polish.

@DaveDavenport
Copy link
Collaborator

supprising that in power saving mode it is so slow.. I wonder why and if it has something to do with rofi's async loading in dmenu.

btw the above is not script mode? but dmenu mode. there is a (slight) difference.

@DaveDavenport
Copy link
Collaborator

~/.config/rofi/scripts/custom-menu.json

I am confused by this, rofi does not support json menus.
That directory should have script mode scripts.

@arakis
Copy link
Author

arakis commented Mar 25, 2024

You're right, rofi does not support json. It's just an input file for the jq tool. See https://gist.github.com/Atreyagaurav/2b70bb997fa5eff45c924e86095080e8

@DaveDavenport
Copy link
Collaborator

That directory is already 'used' by rofi to auto-load mode scripts. You might want to avoid using that.

@arakis
Copy link
Author

arakis commented Sep 19, 2024

My request is still up to date. Regardless of where I put scripts (locations to avoid), or how the data was fed (it's just a dynamic lookup via JSON via a script, to generate a valid Rofi list), there's still the problem with the window order.

If you give me a direction, I would implement that feature and make a PR. But for that, I need a direction from you. Should I implement the --window-ids approach, or should I go via the sort approach? Please check my initial post.

@lbonn
Copy link
Collaborator

lbonn commented Sep 19, 2024

@arakis

I think it is still out of scope for the main rofi project but if you are interested, you can have a look at the plugin in https://github.com/lbonn/i3-focus-last.

There are no docs but it can be built with cargo build -p rofi-window-i3, you'll get a .so file and it can be used with something like rofi -plugin-path ... -mode window-i3.
You'll have to run the i3-focus-last daemon as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Incomplete Report - Please follow the guidelines Your report is incomplete and does not follow the guidelines, you may not expect an answer
Projects
None yet
Development

No branches or pull requests

3 participants