Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 3575  / 1 Year ago, thu, february 16, 2023, 9:58:14

While editing text documents I need to put time stamps frequently. I thought of automating it in 2 different ways. None of these seem to be working.




  1. Using nautilus-actions



I set up a new right-context action which runs the command date|xclip



enter image description here



This right-context doesn't show up when I right click in other applications (such as terminal, or browser). Moreover when it appears, and I click on it, it doesn't do anything.




  1. Using keyboard shortcut



I setup a new keyboard shortcut which is supposed to execute date command but doesn't.



enter image description here



Any pointers?



Thanks.


More From » 12.04

 Answers
6

GNOME keyboard shortcuts should work.



Here's why what you tried didn't work: Your keyboard shortcut runs the date command, but does nothing with the output (which just gets discarded). You should pipe it to xclip, as date | xclip to copy it to the X selection (not clipboard). Then you can paste it into your document by middle-clicking. If you want to be able to use Ctrl-V, instead use date | xclip -selection c to copy it to the actual clipboard.



Another alternative is to use xdotool to type the date directly into your document. Assign to your shortcut



xdotool type "$(date)"


Then, when you press the shortcut key, it will calculate the current date and type the characters it into your document.



For ISO 8601 format, use xdotool type "$(date --rfc-3339=s)".






If it doesn't work: Because these are shell commands (as opposed to executables), you might have to pass the command to bash when specifying them in your shortcut. Your command would then be:



bash -c 'xdotool type "$(date --rfc-3339=s)"'

[#33320] Thursday, February 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingwhin

Total Points: 332
Total Questions: 112
Total Answers: 115

Location: Burkina Faso
Member since Tue, Apr 26, 2022
2 Years ago
ingwhin questions
Sat, Jul 17, 21, 21:33, 3 Years ago
Mon, Oct 10, 22, 12:09, 2 Years ago
Tue, Jun 15, 21, 05:43, 3 Years ago
Mon, Oct 18, 21, 23:34, 3 Years ago
;