After a bit of digging, I managed to get it working with inotify-tools. Here is what I had to do.
sudo apt-get install inotify-tools
inotify is one of the facilities in Linux that I adore. Very scalable; have used it extensively in production environment that fires a few thousand events per second (it is capable of doing a lot more).
For our purpose, we need to setup an event monitor and make the event do something; which is in our case monitor for write+close event, and ask gnome (in my case) to open the file. The best we can do is to run a background script on gnome session startup.
The script as below; make sure you set execute permission on the file.
#!/bin/bash
if [ "$1" != "-nohup-" ]; then
nohup $0 "-nohup-" </dev/null &>/dev/null &
exit 0;
fi
inotifywait -e close_write -m -r --format '%f' $HOME/PDF |
while read f; do
nohup gnome-open $HOME/PDF/$f </dev/null &>/dev/null &
done
Comments
Post a Comment