On Ubuntu Mate 20.10 on a Lenovo T450 notebook, I have been trying to create a timestamp keyboard shortcut for quite a while. The intent is to be able to insert a time stamp into any sort of file as if I typed it, whether a text file, LibreOffice Write, Calc, draw or any other type of document.
The two closest questions similar to this one are:
Following the suggestions in the first link I created the following bash script file Timestamp.sh:
#!/bin/bash
sleep 0.3s && date +%Y.%m.%d' : '%H.%M.%S
which when executed produces a timestamp formatted to my needs and looks like this:
2021.07.11 : 21.10.26
Now using the keyboard shortcut app in Mate mate-keybinding-properties
, and tying the above script to F9 for testing purposes I've tried the following:
/home/xak/scripts/Timestamp.sh
xdotool keyup exec /home/xak/scripts/Timestamp.sh
xdotool keyup sleep 0.3s type `date +%Y.%m.%d' : '%H.%M.%S`
xdotool type "$(printf 'date\n\e ')"
bash -c 'xdotool type "`date +"%Y-%m-%d_%T`"'
bash -c 'xdotool type --clearmodifiers -delay 0 "`date +"%Y-%m-%d_%T`"'
None of these work. No matter how long I hack at this (in the old positive sense of hack) or how much I search I cannot fine how to make this relatively simple thing work.
Now some of the things above that I've tried were proposed by people with a lot more experience than me but when you put them for execution as a keyboard shortcut using mate-keybinding-properties
they don't seem to work. What am I missing?
To make this work would give all users the capacity to insert a timestamp into any application as needed.