I've created a script to empty my trash. I want to be able to execute it without having to use the terminal. Is there anyway I could do this?
1 Answers
A nice way to execute scripts by double clicking them is to make a .desktop file, which is essentially a shortcut. Aside from scripts, it can execute pretty much any executable, including .jar. Here's how to make one:
- Create a file and name it
<program name>.desktop Open it with GEdit and paste this text in:
[Desktop Entry] Version=1.0 Type=Application Name=<whatever you want the file name to be> Comment=<description of program> Exec=</path/to/script> Icon=</path/to/optional/icon.png>Edit the Name, Comment, Exec, and Icon fields to what you want. Having an Icon is optional and you can simply remove that line if you don't want to have one. Make sure to delete the surrounding
<>.Save the file and then go into its properties.
Go to Permissions and mark it as executable.
You should now be able to double click this file and it will execute your script. If you don't want a terminal window to be shown, add Terminal=false to the file. You can now add this file to the launcher for easy access, if you like. If you want to move your script, you'll have to update the Exec path in the .desktop file.
Any problems, just comment.
---Update---
Thanks to @kos, I now know the solution to your problem. Instead of having sudo rm -rf ~/.local/share/Trash/*, you want just rm -rf ~/.local/share/Trash/*. Since ~/.local/share/Trash is owned by you, you can do anything from your user account to edit it without sudo. After testing the non-sudo command out, I can confirm that it works.
- 19,525
- 12
- 52
- 65