In Firefox, when I choose to open a file without saving it and without an internal plugin (like a pdf or a doc file) the default behavior is that the file is saved in /tmp as a temporary file and that the chosen application (like mupdf or libreoffice) is opened with the temporary file as input. The filename of the temporary file is usually the original name of the downloaded file, unless a file with the same name is already present in /tmp. In such case, a suffix is appended to the filename (-1, -2, -3, etc) before its extension. The temporary files are deleted from /tmp when Firefox is closed (unless the default behavior is changed).
I think it would be much more convenient to delete each temporary file when it is not needed anymore (i.e., when the application using it stops using it). Is there a way to implement this?
As an alternative, a better behavior for me would be to replace the existing file in /tmp with the new one in case a file with the same name already exists? (i.e., without changing the filename). Is this possible?