Insert Date

I wanted a hotkey to insert the current date at the cursor in ALL programs. Turns out this is rather tricky, because there is (of course) no common API to “insert text” in all X programs (open standards means you can get it to work with slightly less Perl than proprietary standards. Or more Perl and less wireshark).

The best solution (not so great) I have so far is to use xmacro. The input to xmacro would look something like this:

Delay 1
String 2006-03-27

Where “Delay 1” gives you 1 second to take your fingers off the keys.

So a handy script can generate this macro for any desired string:


echo Delay 1
while read line ; do
        echo "String $line"

Then a handy script can feed it into xmacroplay:


type-gen-macro | xmacroplay $DISPLAY

And a shortcut can be assigned to

date +'%F' | xtype

Hacky and slow, but it works.

This entry was posted in X. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s