Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a bash script to automatically decrypt file for editing and encrypt it back after file is closed. File type could be any: plain-text, office document, etc. I am on Linux Mint with Mate.

I'm stuck: can't reliably detect if file was closed in application so that script can proceed to encrypting it back and removing decrypted version.

The first version of the script simply used vim with text files. Script was calling it directly and hadn't been going any further until vim was closed. Now as I want to be able to do so with other files, I tried the following things:

xdg-open: exits immediately after calling the application associated with file type. Thus script continues and does no good.

xdg-open's modified function for calling an associated app: runs it inside the current script so now I see program exit. Works only if the application hasn't been running already. If it has, then new process is finished and script continues.

So what I am trying to do now is to watch somehow that file was closed in already running application. Currently experimenting with pluma/gedit and inotifywait. It doesn't work either - instantly after file was opened it detects CLOSE_NOWRITE,CLOSE event.

Is it at all possible to detect this without specific hooks for different applications? Possibly some X hooks?

Thank you.

share|improve this question

1 Answer 1

No, there are no X hooks for something like this. You would need to do something specific for each application as they will all handle file access differently from each other.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.