Git Product home page Git Product logo

Comments (19)

fdw avatar fdw commented on August 17, 2024

You can already customize the actions a bit, but Enter and delays are currently not supported. It's an interesting idea, but at the same time, it might be too complex for what rofi-rbw is trying to do...

No promises, but I'll think about it. If you want to write a PR, I'd definitely look at it 🙂

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Hey @f0rdprefect!

It took a while, but I've just pushed the first draft for this feature on the branch feature/low-level-typing-actions. You can for example add delay to the targets in --keybindings, like --keybindings "Alt+1:type:username:enter:delay:password"

Could you please test it and report back?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

Hey @fdw,

tried to see what happens when I follow your example.

I do not know how to make it work. I tried delay in seconds and milliseconds (5 or 5000) and also changed the position betwwen enter and delay no difference.

rofi-rbw --keybindings  "Alt+1:type:username:enter:10000:password"

gives me <username>None<password>

No delay, no newline. Btw I use 'dotool' in a Wayland session...
I used poetry to enter a shell to call rofi-rbw and double checked that I am on the right branch:

git status
On branch feature/low-level-typing-actions
Your branch is up to date with 'origin/feature/low-level-typing-actions'.
which rofi-rbw
/home/matt/.cache/pypoetry/virtualenvs/rofi-rbw-Xcs6rh1C-py3.11/bin/rofi-rbw

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Sorry for the misunderstanding; delay is meant as this exact word - it's hardcoded for five seconds.
Does it work then?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

I see.

The delay works. enter does not. I am starting rofi with a terminal in focus, so I would expect some commands not found error messages.

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Yep, my approach was a bit too naive. Can you try again please?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

Hmm, not looking good:

poetry run rofi-rbw --keybindings  "Alt+1:type:username:enter:delay:password" 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/__main__.py", line 5, in main
    RofiRbw().main()
    ^^^^^^^^^
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/rofi_rbw.py", line 19, in __init__
    self.typer = Typer.best_option(self.args.typer)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/typer/typer.py", line 17, in best_option
    return next(typer for typer in available_typers if typer.name() == name)()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Can't instantiate abstract class DotoolTyper with abstract method press_key

Btw dotool is version 1.3...

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Sorry, I forgot dotool. Can you please try again? I'm quite confident now 😉

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

Well:

poetry run rofi-rbw --keybindings  "Alt+1:type:username:enter:delay:password" 
dotool: WARNING: invalid delay: typedelay 0 type [email protected]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/__main__.py", line 5, in main
    RofiRbw().main()
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/rofi_rbw.py", line 73, in main
    self.__execute_action(credential)
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/rofi_rbw.py", line 90, in __execute_action
    self.__type_targets(cred)
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/rofi_rbw.py", line 104, in __type_targets
    self.typer.press_key(Key.ENTER)
  File "/home/matt/src/rofi-rbw/src/rofi_rbw/typer/dotool.py", line 30, in press_key
    run(["dotool"], input=f"key {key_name}")
  File "/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/subprocess.py", line 550, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/subprocess.py", line 1194, in communicate
    self._stdin_write(input)
  File "/nix/store/w4fvvhkzb0ssv0fw5j34pw09f0qw84w8-python3-3.11.7/lib/python3.11/subprocess.py", line 1143, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Sorry for this, but I don't have dotool working currently (in fact, I'm still mostly on X), so I can't really test it. Hopefully it's better now.

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

It is better. But dotool is still unhappy:

poetry run rofi-rbw --keybindings  "Alt+1:type:username:enter:delay:password" 
dotool: WARNING: invalid delay: typedelay 0 type [email protected]
dotool: WARNING: invalid delay: typedelay 0 type super-secret-password

There is a 5 seconds delay between the 2 dotool warnings.

Also there is no text output on the command line (because of the warning maybe).

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

The delay sounds good. But I can only guess what dotool's problem is 😕

Can you please try again?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

It works!!!

No more warnings. Behavior as described:

<username><enter>
<delay><password><enter>

Now of course it would be nice to configure the delay or even better come up with a convention similar to pass

Turns out that this is a pass plugin: https://github.com/wosc/pass-autotype

They way this is used could be really add benefit to rofi-rbw in my opinion. If you would parse the notes field for a autotype line and act accordingly!

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

It works!!!

🎉

Now of course it would be nice to configure the delay

I was hoping to avoid that complexity, especially for the syntax. Do you think it's important to have it configurable?

Turns out that this is a pass plugin: https://github.com/wosc/pass-autotype

They way this is used could be really add benefit to rofi-rbw in my opinion. If you would parse the notes field for a autotype line and act accordingly!

I've also thought about reading it from an entry's field, but I wanted to make the simple case work first 😉
There doesn't yet seem to be a common field name for it, and I wouldn't want to come into conflict with other apps, so I'm thinking of _rofi_rbw_autotype. What do you think?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

They delay flexibility is already fixed. One can call multiple delays. Now set it to 1s as default and this should be good,

Regarding the field name: I do not like leading underscores for names but I can see that coming from "private" variables in python. That is personal taste of course.

However it will be a save choice. I believe it would be rather strange if it was used for anything else than rofi-rbw

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

They delay flexibility is already fixed. One can call multiple delays.

I've reduced the delay, but if it's a common problem that one second is too short, I'd rather revisit the topic than to force everyone to use multiple delays.

Regarding the field name: I do not like leading underscores for names but I can see that coming from "private" variables in python. That is personal taste of course.

I think I wanted to additionally represent that this is not a "user-facing" field, but something that is only used programmatically. But maybe rofi_rbw_* is already enough? I'm really not sure.

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

I've just added support for reading from a field called _autotype. Could you please try it?

from rofi-rbw.

f0rdprefect avatar f0rdprefect commented on August 17, 2024

It Works!

swappy-20240419-124638

Entered the data shown in the screenshot. Started with a terminal focused it will execute the two commands with a delay between them. Note the second enter...

from rofi-rbw.

fdw avatar fdw commented on August 17, 2024

Perfect, thank you!

from rofi-rbw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.