abenz1267 / walker

Application launcher similar to Rofi etc. . Wayland native.
MIT License
263 stars 12 forks source link

dmenu module? #47

Closed omnigenous closed 1 month ago

omnigenous commented 1 month ago

Is this already possible and I'm doing this wrong?

echo "hello\nworld" | walker

abenz1267 commented 1 month ago

No. Check the wiki on external modules/plugins.

If you tell me what exactly you want to achieve, i'll could tell you what to do with Walker.

omnigenous commented 1 month ago

Well I was looking for wofi replacements. I have huge list (1-2 thousands entries) of unicode symbols and I want to make searchable menu to select them, wofi takes like an entire minute to load that list.

flytaly commented 1 month ago

Actually I wanted to do something similar.

For OP, I assume that something like this should work.

    "external": [
         {
            "name": "symbols",
            "prefix": "s",
            "src": "cat /path/to/the/list",
            "cmd": "wl-copy"
        }
    ],

However, the downside is that it re-executes every time you type anything, which is terrible for performance. I would like to see an option to only execute a command once when entering an external module. For example, in my config I added following command

            "src": "zoxide query --list",
            "cmd": "kitty %RESULT%"

It works, but it also executes zoxide on the input and passes the input string through stdin, which is unnecessary. I only want to filter the initial entries inside the walker.

abenz1267 commented 1 month ago

Ah yes, I understand. I guess Walker needs a "src_once" for those cases.

abenz1267 commented 1 month ago

Ok, i've added 2 things: src_once and src_once_refresh. Feel free to try it out and report back. Example:

"external": [
         {
            "name": "symbols",
            "prefix": "s",
            "src_once": "cat /path/to/the/list",
            "src_once_refresh": false,
            "cmd": "wl-copy"
        }
    ],

src_once_refresh would be needed if you run Walker as a service and need to update the cached result when opening Walker in order to avoid stale data.

abenz1267 commented 1 month ago

I've tried this with a nearly 5k lines emoji list and it works fast. The slowest part is actually rendering the list in GTK, but i just introduced a variable max_entries that defaults to 50, so only max 50 entries will be rendered. Adjustable in config of course, i personally set it to 25.

abenz1267 commented 1 month ago

... i've just added an emoji module.

omnigenous commented 1 month ago

... i've just added an emoji module.

walker v0.0.94

walker -m emojis

walker is just blank


Okay, had to replace my config with default one: https://github.com/abenz1267/walker/blob/master/config/config.default.json

  "modules": [
    {
      "name": "runner",
      "prefix": ""
    },
    {
      "name": "applications",
      "prefix": ""
    },
+   {
+     "name": "emojis",
+     "switcher_exclusive": true
+   },
    {
      "name": "ssh",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "finder",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "commands",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "websearch",
      "prefix": "?"
    },
    {
      "name": "switcher",
      "prefix": "/"
    }
  ]
omnigenous commented 1 month ago

Okay, I have tried creating external module but I'm getting exit satus 1

Maybe something triggers it in my list?

list.txt

abenz1267 commented 1 month ago

I've added

    {
      "name": "gh",
      "prefix": "+",
      "src_once": "cat /home/andrej/Downloads/list.txt",
      "cmd": "notify-send \"%RESULT%\""
    }

To my config with your list and it works fine.

abenz1267 commented 1 month ago

... i've just added an emoji module.

walker v0.0.94

walker -m emojis

walker is just blank

Okay, had to replace my config with default one: https://github.com/abenz1267/walker/blob/master/config/config.default.json

  "modules": [
    {
      "name": "runner",
      "prefix": ""
    },
    {
      "name": "applications",
      "prefix": ""
    },
+   {
+     "name": "emojis",
+     "switcher_exclusive": true
+   },
    {
      "name": "ssh",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "finder",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "commands",
      "prefix": "",
      "switcher_exclusive": true
    },
    {
      "name": "websearch",
      "prefix": "?"
    },
    {
      "name": "switcher",
      "prefix": "/"
    }
  ]

Yeah, the module still needs to be configured!

omnigenous commented 1 month ago

I've added ... To my config with your list and it works fine.

cat ~/Downloads/list.txt won't work but cat /home/user/Downloads/list.txt or cat $HOME/Downloads/list.txt" will. Is there any reason it is that way? Can we fix it? $HOME is good enough just wondering if it can be more clear and flexible.

abenz1267 commented 1 month ago

I've added ... To my config with your list and it works fine.

cat ~/Downloads/list.txt won't work but cat /home/user/Downloads/list.txt or cat $HOME/Downloads/list.txt" will. Is there any reason it is that way? Can we fix it? $HOME is good enough just wondering if it can be more clear and flexible.

~ is a local shell expansion. Expanding it programmatically seems hacky to me...

Edit: i will expand it. Possible edge-case errors can be handled once they actually arrive. Otherwise using ~ seems rather "natural" to me....

abenz1267 commented 1 month ago

... can this be closed?

omnigenous commented 1 month ago

... can this be closed?

Yeah if you are not interested in implementing dmenu-like mode. I can make my stuff work with external modules now.

abenz1267 commented 1 month ago

I mean, if the use-cases can be solved by external modules i don't see the point of a special dmenu-mode, unless i'm missing something.

omnigenous commented 1 month ago

Personally I think dmenu-like mode where you can just pipe stuff into is simpler than setting up external module. For example I can write and test script in couple seconds to view clipboard history with wofi without having to edit configs and learning what that config can accept:

clipboard list | wofi -d -p "Clipboard" | wl-copy
abenz1267 commented 1 month ago

Hm, i'm kinda torn. On the one side i can see the argument in terms of testing and familiarity... on the other side it wouldn't solve anything that can't be solved already.

abenz1267 commented 1 month ago

Feel free to tryout clipboard list | walker -d | wl-copy

omnigenous commented 1 month ago

Awesome! I tried echo "c\nb\na\n100\n10\n44\n2" | walker -d and I notice it sorted alphabetically (numbers are sorted wrong). I couldn't find an entry in config that affects sorting. Also would be nice to expose sorting setting to walker flags.


Other small thing, using cliphist list | wofi -d works but with walker it doesn't remove index numbers. I haven't looked at wofi source code so not sure how it is done and if it is even a good idea to do. You can simply cliphist list | cut -f 2 | walker -d

omnigenous commented 1 month ago

How do I remove "Dmenu" at the bottom of each item in a list?

omnigenous commented 1 month ago

50 Is it possible to pass something through a pipe to signal that cmd_alt was used with dmenu mode?

abenz1267 commented 1 month ago
  1. Sorting: -k, --keepsort added => won't sort alphabetically
  2. Removing Index: -l, --labelcolumn define which column to use as the label. The output will still be the actual value => see cliphist why (short: cliphist decode needs the index)
  3. dmenu won't show sub anymore. kinda pointless
  4. for passing if alt+enter was used: could you show me how you'd use it? I'd pipe the result to f.e. stderr if alt+enter is being used... would that help?
omnigenous commented 1 month ago

for passing if alt+enter was used: could you show me how you'd use it?

I would use it for dirty one-liners, ex:

echo '1 hello\n2 world\n3 foo\n4 bar' | walker -d | isWalkerAltEnter && echo alt || echo normal

Not sure how it would look in bash, I'm not really competent :D

abenz1267 commented 1 month ago

yeah... that won't work...

maybe i'm missing something. i'm not sure how i'd forward the information about what kinda action happened, other than doing something like cmd <result> or cmd_alt <result> where you then have to further process that information.

omnigenous commented 1 month ago
  1. Removing Index:

Testing with cliphist list | walker -d -k | cliphist decode Walker will display just numbers, I do love new --labelcolumn flag and have couple ideas where I could use it already, but I think I liked where I could see cliphist index so I know when my clipboard history becomes too big. How do I make walker display all columns?

On a side note, I haven't played with --labelcolumn that much but do you think we might need --columnseparator flag.

abenz1267 commented 1 month ago

Ah fuck. I need to stop waking up and straight up fixing/adding things. I know whats happening.. will fix later today. Per default it should display everything. It's just buggy. Yeah, adding a separator would make sense.

omnigenous commented 1 month ago

No worries, thank you for your work <3

abenz1267 commented 1 month ago

Should be fixed. --separator, -t flag has been added. Example: -t 's' or -t "'\t'"

omnigenous commented 1 month ago

echo "c\nb\na" | walker -d -k