You are not logged in.

#1 2018-10-09 13:45:09

Sorky
Member
Registered: 2012-07-25
Posts: 20

[SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

I'd like to setup a hot-key [Ctrl-Shift-1] that pastes "me@domain" into the currently focused client

So far...

	awful.key({ "Control", "Shift" }, "1", function()	awful.spawn.with_shell("echo me@domain | xsel -i -b") end,
              {description = "Auto Typer - 1", group = "hotkeys"}),

That works but then I need to also press "Ctrl-V" but I'd rather not need the extra action

I've also tried many other ideas that seem to work in the shell but just don't from awful.key / xdotool seems close but often doesn't do the first chars)...

	awful.key({ "Control", "Shift" }, "2", function()	awful.spawn.with_shell("echo me@domain | xsel -i -b && xsel -o -b") end,

	awful.key({ "Control", "Shift" }, "3", function()	awful.spawn.with_shell("echo me@domain | xsel -i -b && xsel -o -b -n") end,

	awful.key({ "Control", "Shift" }, "4", function()	awful.spawn.with_shell("echo me@domain | xsel -i -b -n && xsel -o -b -n") end,

	awful.key({ "Control", "Shift" }, "5", function()	awful.spawn.with_shell("echo me@domain | xclip -selection c && xclip -o") end,

	awful.key({ "Control", "Shift" }, "6", function()	awful.spawn.with_shell("xdotool key --delay 100 m e shift+2 d o m a i n") end,

	awful.key({ "Control", "Shift" }, "7", function()	awful.spawn.with_shell("xdotool type --delay 100 me@domain") end,

	awful.key({ "Control", "Shift" }, "8",function()	awful.spawn.with_shell("(echo me@domain | xsel -n -i -b) & xdotool key control+v") end,

	awful.key({ "Control", "Shift" }, "9",function()	awful.spawn.with_shell("	echo me@domain | xsel -i -b")
												root.fake_input( "key_press", 37 )
												root.fake_input( "key_press", 55 )
												root.fake_input( "key_release", 55 )
												root.fake_input( "key_release", 37 )
								end,

Last edited by Sorky (2018-10-17 10:48:32)

Offline

#2 2018-10-16 07:54:36

Sorky
Member
Registered: 2012-07-25
Posts: 20

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

Bump...

Any comments on getting "root.fake_input" working?

Any comments on getting "xsel -o -b" working?

Any comments on getting "xdotool" working properly?

Offline

#3 2018-10-16 07:58:59

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2018-10-16 14:08:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,541
Website

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

Forget xsel, that will never do what you want it to.

Sorky wrote:

Any comments on getting "xsel -o -b" working?

It *is* most likely working.  That command prints the content of the clipboard selection to stdout - so it most likely when to the controlling tty or a xorg or awesomewm log.  Sending something to stdout doesn't emulate x11 key presses.

Xdotool should work, but I know nothing about awesomewm's key bindings.  Are you sure your key binding is even working?  Test that first.  Are you sure the input box or text field remains focused after awesomewm catches a grabbed key event?  Have you tested the xdotool command directly (e.g., from a terminal emulator)?

EDIT: ah, I see you noted that xdotool mostly works.  If it is missing the first characters, it may be due to awesomewm not returning focus to the input field soon enough.  Add a sleep command or even better xdotools equivalent delay before the keys are sent.

Last edited by Trilby (2018-10-16 14:11:44)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2018-10-17 10:42:23

Sorky
Member
Registered: 2012-07-25
Posts: 20

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

Trilby wrote:

EDIT: ah, I see you noted that xdotool mostly works.  If it is missing the first characters, it may be due to awesomewm not returning focus to the input field soon enough.  Add a sleep command or even better xdotools equivalent delay before the keys are sent.

Yeah - And I used the --delay

But you are a star!

Doing Sleep 0.1; then xdotool was perfect!

Last edited by Sorky (2018-10-17 10:50:12)

Offline

#6 2018-10-17 12:30:12

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,362

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

Depending what you're trying to do, keepass' autotype functionality has been useful for me (single key activation, and content depends on window title, multiple matches need to be selected by user before typing commences). That's mainly because I already use it for passwords, and have found it helpful for other repetitive typing.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2018-10-17 23:13:35

Sorky
Member
Registered: 2012-07-25
Posts: 20

Re: [SOLVED] Awesome WM - Auto Typer? xdotool needs a delayed start!

ngoonee wrote:

keepass' autotype functionality has been useful for me (single key activation, and content depends on window title

Nice suggestion! Particularly the "depends on windows title" - Might try that!

I found this note: KeePass — A cross-platform password manager that has autotype and clipboard support when respectively xdotool and xsel are installed.

Seems that xdotool was the right choice for autotype functionality ;-)

Offline

Board footer

Powered by FluxBB