Important! : If you're a linux newbie, or unsure about the methods I'm using, then wait until someone replies with a post saying that it all worked for them. I've tested all this out on Ubuntu 9.10 (Karmic Koala) running Dropbox version 0.6.571. This tutorial assumes you have dropbox already installed from https://www.dropbox.com/install
I use dropbox to keep synced with my colleagues on projects we are working on. But I really don't like having the icon in the system-tray all the time. At the moment, there is no option to hide it - so I've written a script that starts dropbox and performs any syncing that needs to be done. Then it exits leaving your system-tray nice and tidy again!
I have this happen automatically at login, because I boot my machine regularly enough. But you can also have it happen more regularaly using cron. Below, I will describe how to install the script and set it to run at login as well as optional intervals using cron.
Installation
Just download the script attached at the end of this post and place it wherever you like. First of all, we need to make it executable:
Code:
chmod +x check-dropbox.sh
I like to keep the file 'hidden' in my home folder so I saved it there and renamed it with this command:
Code:
mv check-dropbox.sh .check-dropbox.sh
The dot in front of the name makes it hidden. So now the file is called .check-dropbox.sh
Making it run at login
Go to System -> Preferences -> Startup Applications.
Click the Add button.
Type in any name for this, and click Browse...
In the new dialog that appears, click the right mouse button and select 'Show Hidden Files' so that you can find the file if you used the Installation method I described earlier.
Then just click Add and also Close in the main window.
Making it run every fifteen minutes
Open a new terminal and backup the file /etc/crontab before we continue. We will be editing this file.
Next we want to add a single line to the correct location in this file to make our script run regularly. In the terminal type:
Code:
sudo gedit /etc/crontab
The file will look very like this in Ubuntu Karmic:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
We want to add this line, replacing the two instances of <username> with your username:
Code:
*/15 * * * * <username> /home/<username>/.check-dropbox.sh
Copy that line above and paste it just under where it says: "# m h dom mon dow user command". On my computer that portion of the file looks like this: (our new part is highlighted in red)
Code:
# m h dom mon dow user command
*/15 * * * * jarlath /home/jarlath/.check-dropbox.sh
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
Save and close. Enjoy!
Credits
Thanks to diesch for helping me with a coding problem I had.
The commands I use in this script can be found in the following:
Dropbox man page - type 'man dropbox' in a terminal (for the 'dropbox status' command)
Newbies intro to cron - (for information on editing the crontab file to automate script or command execution)
And Advanced Bash Scripting guide - (for all the rest! script programming in general is covered here.)
Bookmarks