Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-01-10 19:06:22

mzilikazi
Member
Registered: 2004-07-17
Posts: 5

[Solved] Print current time to focused window - kb shortcut - what's wrong?

Desired end result: Print the current time into the focused window by way of a keyboard shortcut.
Chosen tool for task: xdotool
Problem: xdotool output missing after pressing keyboard shortcut.

This works:

xdotool type $(date +"%H:%M")

This works:

#!/bin/sh
xdotool type $(date +"%H:%M")
touch /tmp/IT_WORKS
$ /usr/bin/timestamp
$ 11:28
$ file /tmp/IT_WORKS 
/tmp/IT_WORKS: empty

This also works:

ALT+F2

/usr/bin/timestamp

12:04 <- The current time is printed directly to the focused window and /tmp/IT_WORKS is created.

However, when calling /usr/bin/timestamp from a keyboard shortcut xdotool output is missing while /tmp/IT_WORKS is again created.

Suggestions?

Offline

#2 2016-01-10 19:49:18

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,996

Re: [Solved] Print current time to focused window - kb shortcut - what's wrong?

I think it has something to do with timing (activewindow doesn't have a chance to be set?). Try:

sleep .1s && xdotool type $(date +"%H:%M")

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2016-01-10 20:15:38

mzilikazi
Member
Registered: 2004-07-17
Posts: 5

Re: [Solved] Print current time to focused window - kb shortcut - what's wrong?

Sure enough a 1 second sleep did it.  Thanks!

Offline

Board footer

Powered by FluxBB