I am very new to Linux. I want to do something I feel should be really simple, but hours of googling have left me frustrated and confused!
Specifically I want to be able to type a keyboard combination like ctrl+shift+h and have it enter a text string (say for a password) in a textbox in firefox. The string is 16 characters long and I don't want to type it every time I need to use it, which is many times each day. I think I need to use settings > keyboard > keyboard shortcuts > but I don't know what command to use. I have tried 'type' and 'echo' and I also installed xdotool but couldn't see exactly how to use these apps to produce the change I am looking ot make. Any assistance greatly appreciated!
Hey, welcome to the community!
So, I'm not entirely sure I know how to address your particular use case but I can think of a couple of quick workarounds that involve updating the clipboard with a predefined string somewhere, and then you can paste that real quick.
Anyway, is that random string of text a password by any chance? If yes, I'd highly encourage using a password manager such as KeePassXC. In fact, you can use this even if you don't plan on using it for passwords: it has an auto-type features that works exactly as you've described.
If it's for a password, definitely use a password manager instead of adding the text as a snippet. But if there will be multiple strings of text, consider using a snippets manager (like TextExpander, which is paid, but there are free alternatives).
You could check out these options:
They don't have the easiest of installation processes, but it seems you can set up keyboard shortcuts to expand snippets. (I use TextExpander at work, and I highly recommend using an abbreviation for snippets instead of shortcuts. If you have many snippets, you'll quickly run out of shortcuts to assign. )
I think it's worth pointing out that many of these tools are not going to work, at least not fully, while logged in under Wayland. Maybe that's one of the reasons why xdotool
didn't work earlier for @nickminnion.
Although it seems that Autokey does work fine, as per this thread:
Ah good find. Well, I found Wayland buggy so maybe it’s a good reason to switch back to X11 if that’s an option for OP.
Thanks for your kind answer. Does the clipboard retain text after shutdown?
I do use Dashlane for passwords, but for one or two sites I just can't get it to autofill. That's why I started thinking about some sort of macro.
Many thanks for the informative reply. I hadn't come across the text expander idea so I will look into that. I do use Dashlane for password management, but for one or two sites it doesn't work so well, which is why I started thinking of setting up a couple of macros. My system uses Wayland. Tried Autokey, but couldn't seem to get that to run. The post you copied above was what I was following, but got pretty confused about what to type into the command text box on the custom shortcut dialogue box. I can't figure out how to use the xdotool app together with the custom shortcut app.
Not sure what is entailed in 'switching back to X11', but I am here to learn, so will google that
No, the clipboard exists only in RAM. This can be worked around with some fancy footwork but when it comes to passwords, I wouldn't recommend it.
You'll have to try to see for yourself. There are a lot of things that don't work yet in Wayland but they do in X11. These are just different display servers. You can switch back and forth by logging out of your account and through the wheel button on the corner (see the last post from the thread that I linked to above).
This could be an issue with the sites, so you might want to reach out for support. If it's a multi-step form, check if Dashlane supports custom auto-type sequences. I use that for site that implement this type of useless login forms.
The Name field is just a label for you to remember what this shortcut does. The Command is what you actually want to run, exactly how you would type it in the terminal. For simple things like launching Firefox you can just type that.
I'm sure there's a way to achieve the same using xdotool
or a similar tool but I think it's best if you give Autokey a try. It has a graphical interface to set the commands that you want much more easily, and it seems to work fine — under X11, that is.
For example, I've just created a quick test to map "zorin" to "Zorin OS Core 17.2":
You can find Autokey in the software store, but don't install the Qt version:
Thanks, that is really useful information. Will give that a try.