I have an application which does this:
#!/bin/bash
tmpfile=$(mktemp)
gedit $tmpfile && pkexec mv $tmpfile $1
Works great. It creates a temp file, opens it in a graphical editor, and it gets moved to a correct spot with elevated permissions using polkit when I'm done.
But... you need to have gedit installed. I'd prefer to use something which respects the user's desktop environment and preferences. xdg-open should work but I have a problem:
#!/bin/bash
tmpfile=$(mktemp)
xdg-open $tmpfile && pkexec mv $tmpfile $1
xdg-open is a forking process. It will launch the editor, then return immediately... causing the mv to be triggered before I've had a chance to work.
Is there a way for me to only trigger the pkexec mv ... after the editor completes?
xdg-open(1) doesn't offer any help. Am I going to need to write some kind of inotify tool to block until some event is read from an FD?