Score:2

How do I create a desktop icon which launches a terminal program in Ubuntu 20.04?

us flag

I am working on a desktop shortcut for my users that will ask for a password and decrypt all files in a specific directory. I am using Ubuntu 20.04. I have a .desktop file written:

[Desktop Entry]
Name=Decrypt Files
Exec=gnome-terminal --working-directory="/home/user/Desktop/Encrypted Files" -- ccrypt -d `ls`
Terminal=False
Icon=utilities-terminal

The .desktop file is located in the users' ~/Desktop directory, and has been made executable with chmod +x decryptfiles.desktop. But this file does nothing when clicked on. There is no option to 'allow launching' when right clicked.

How do I create a desktop icon which launches a terminal program in Ubuntu 20.04?

I have a test environment that I can use graphical applications to test, but for the final product I can only work in a terminal. This is because I am using Cubic to create a custom .iso.

Terrance avatar
id flag
Change your line of `Terminal=False` to `Terminal=True` to have it run in the terminal.
ambitiose_sed_ineptum avatar
us flag
@Terrance [This](https://askubuntu.com/questions/436891/create-a-desktop-file-that-opens-and-execute-a-command-in-a-terminal) answer says different. ```gnome-terminal``` takes care of that.
Terrance avatar
id flag
Fair enough, but it appears as you have missed adding `;$SHELL` to the end of your command to keep the terminal open.
ambitiose_sed_ineptum avatar
us flag
@Terrance Thank you for your concern, but I am well aware of how the commands I have are supposed to run. My only question is in regards to how to get the .desktop file to run when clicked.
Terrance avatar
id flag
Doing the chmod +x will make it run. It probably is running, but happening so fast it closes and doesn't appear to do anything. You will need to maybe add a second command at the end that maybe echos out the date and time to a log file so that you know that it ran. Also, adding the `;$SHELL` will allow you to see if it actually ran properly.
ambitiose_sed_ineptum avatar
us flag
@Terrance. I tried your solution, it did not work. Again, I know how the commands I am using work. If I run the command directly in terminal, a new terminal window opens, prompts the user for the password to decrypt the files, then decrypts them and closes. The desktop file does not run at all, that is my only question.
Terrance avatar
id flag
Actually, I think that you are missing some stuff in your desktop file. I just created one and have a couple of lines that you are missing. I removed them from mine as a test and it did not run until the lines were added back. You are missing `Version=1.0` and `Type=Application`, which if you look in your linked answer those lines are there as well.
us flag
Did @Terrance’s solution work for you? If so, please let us know, and Terrance should post his solution as an “Answer” which you can accept. If it didn’t work, please edit your question and include what you tired, so folks can suggest a different approach.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.