Directory size changes
hello all,
I currently have a Feh script that points to a folder that is shared via Windows (Samba) share. I currently have the capability to drag and drop images from windows to my Debian shared folder and they show up in the Feh slide show. My issue is that I would like for Feh to restart when ever changes are made (IE: images are added) to the directory. Anyone know how to do this? |
I'm not familiar with Feh, but you could simply create a script that checks the modified time of the folder and restarts Feh if it has changed and place the script into Cron, running once every couple minutes. It won't update it immediately, but that's probably a good thing. It would be a simple script to write: if you are not familiar with scripts or cron, I can help if you would like.
|
OK, I was bored, so I wrote up a quick script anyways. I'm not exactly a programmer, so be nice. :)
Code:
#!/bin/bash Code:
chmod +x /path/to/script.sh Code:
* * * * * /path/to/script.sh >/dev/null 2>&1 |
1 Attachment(s)
Thank you! I have been playing with bourne shell scripts myself and sometimes it aint easy to program what you want. I will have to give your script a try. Additionally, I found an application called incron in the Debian Squeeze repository. It is very simular to the crontab file but instead of watching for time it watches for changes in directories and executes commands. The main issue that I have is that when I write multiple files to the watched directory by incron , incron launches several instances of Feh (slide show app). The really interesting thing is that I am executing a script called slide_show with incron. The script by itself works perfectly by first checking for any instance of Feh or mplayer and then launching Feh if no instance(s) are found. But with incron the only thing that seems to be executed properly is the part that launches Feh with all of the parameters.
|
by the way, I took a closer look at your script and you read my mind. I was thinking of the same concept of script.
|
Doesn't the slideshow script need to terminate any existing Feh instances if they're found? Oh, by the way, one issue with my script is that it will not detect if an image changes--only if one is added or removed. If you wanted to test for modifications, it wouldn't be very hard, actually. I was thinking about it more and probably the easiest way to do that would be to do an ls -l of your image directory and hash it with something like md5sum. Store that instead of the UNIX time of the last modification. It would look something like:
Code:
#!/bin/bash |
Quote:
as for your original script, I tried it out and it works great for only the root directory that it is monitoring. I placed another folder inside of the root dir and then removed a few files from the directory inside of the root dir. the application did not start as anticipated. |
Yeah, that would be anticipated. If you wanted to scan all the directories, change both instances of the ls -l command to ls -lR in the most recent script that I posted (the one that uses hashing rather than date).
|
I have had mixed results with impletmenting the second script. When I use the new script, my slide show takes FOREVER! I suspect that since hashing is taking place it may take my application longer to launch. The more photos/movies I have the longer it will take. I may end up going with the first script.
|
That is odd. Md5 hashing even a very long directory tree should still take less than a second.
|
All times are GMT -5. The time now is 02:06 AM. |