A script, perhaps? - GNU/Linux
Users browsing this thread: 8 Guest(s)
|
|||
Hey all,
I'm curious, as to anyone who knows of a script or something simular that can do this one simple thing: Move every item that gets placed on my desktop, to my ~/Documents folder. I'm running OS X. Basically, instead of changing and configuring twenty applications and features I didn't even know exist that automatically place shit in ~/Desktop, I want them to all place them in ~/Documents. But with ease (Script). |
|||
|
|||
I won't post a script but I can clear your mind about the process of writing it.
You have two options. Or you use a notifier, that will buzz the program when the directory changes, or you can run a daemon that will stay in the background and check the Desktop every x-minutes, which can be resource hungry (polling). I'm not sure if there's a notify library on OSX, on Linux there is the inotify API implemented in the kernel. Also, the notification of changes system might already be implemented in the language you will use to write the script. Then the rest should just be about checking if there's content on the desktop and moving it to the other directory. |
|||
|
|||
You can use a file watcher that moves to the place you want like this: https://github.com/howeyc/fsnotify
|
|||
|
|||
mv ~/Desktop/* ~/Documents/ in a crontab.
Uber milk. |
|||
|
|||
there is command in linux called inorifywait, you can use like:
inotifywait -emoved_to -emodify -ecreate -c desk/ and gives output in csv format: -c flag desk/,CREATE,a desk/,MODIFY,a (a is a file name) while true; do inotifywait -emoved_to -emodify -ecreate -cdesk/ | cut -d, -f3 | mv $(cat -) ~/doc; done will do your job |
|||
|
|||
I know I'm late, but the cleanest option would probably be to set up a folder action with applescript.
https://developer.apple.com/library/mac/...tions.html |
|||
|
|||
inotify is a good approach; I've used FAM for similar purposes on Linux, but it is quite processor intensive. That said, I have some FAM code that would work for what you're trying to do.
Code: #!/usr/bin/perl I should stress that instead of using chattr(), you would call something equiv to `mv`. I haven't done any of the research to see what the appropriate call would be in perl, but the example stands as a solid piece of production code I used on a logging server to make sure all files in a directory were append only. you can leverage the same event engine to ensure your desired behavior is followed. |
|||
|
|||
inotify is linux-specific, and seeing his (or her) avatar, we're probably searching a solution for Mac
|
|||
|
|||
(04-07-2014, 02:52 AM)z3bra Wrote: inotify is linux-specific, and seeing his (or her) avatar, we're probably searching a solution for Mac my solution relies on FAM (from SGI) -- you can get FAM on a variety of platforms, including *BSD, which makes me think it should be portable to OSX. Also, since his needs don't include changing attributes on files, you could strip-out `use Filesys::Ext2...`, and include whatever appropriate module would provide the useful bits for your application. Just thinking out loud here. Cheers, Soda |
|||
|
|||
I just noticed that this is posted in the GNU/Linux section and not in the OSX section.
|
|||
|
|||
Or you could symlink ~/Documents/ to ~/Desktop/ and not display icons. Even more milk.
|
|||