Tuesday, April 23, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 514  / 3 Years ago, sun, june 20, 2021, 10:43:46

Lubuntu 16.04 - Openbox session



I can use the terminal to open a time-stamped file with gedit:



gedit ~/$(date +%Y%m%d%H%M%S).txt


The command can also be used via a keyboard shortcut in Openbox.



<keybind key="W-4">        # gedit time-stamped file
<action name="Execute"><command>sh -c 'gedit ~/$(date +%Y%m%d%H%M%S).txt'</command></action>
</keybind>


But I can't do the same via the Exec= line of a .desktop file.



Exec=sh -c 'gedit ~/$(date +%Y%m%d%H%M%S).txt'


just creates a file called ~/.txt



So how do I get a .desktop file to do what I want?


More From » bash

 Answers
2

Unfortunately, .desktop files don't always call sub-shell $() commands the way we would like them to. One way to do this that I have found would be to create another script that contains the sub-shell command to open the file like that.



The Exec line would look like:



Exec=/path/to/script


then your script file would contain the command to open your new file:



#!/bin/sh

gedit ~/$(date +%Y%m%d%H%M%S).txt


the script would also have to be executable:



chmod +x /path/to/script


Hope this helps!


[#15060] Tuesday, June 22, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ndeecru

Total Points: 109
Total Questions: 128
Total Answers: 117

Location: Czech Republic
Member since Thu, Aug 11, 2022
2 Years ago
;