I'm an avid xmonad user, and I've recently switched over to conky + dzen as my status bar. A recent issue I had is with getting Dropbox status information into my conky.

I did some hacking and here's the result. I love the way it turned out:

This is a pretty generic approach on adding anything into conky + dzen. Here's the steps I took:

1. Write some scripts to produce the text you want

Conky has methods to run arbitrary scripts and echo their output. This abstraction makes it easy to get the text you want.

I started writing a couple shell scripts that get me the info I need:

Note: I used the Dropbox command line tool to get this info. You'll
need that installed. on arch, it's the 'dropbox-cli' package.
# drobox-down
# echos the Dropbox download speed
#!/usr/bin/env bash

status=`dropbox status | grep Downloading`
SYNC_REGEX="([0-9,]+) KB/sec"

[[ $status =~ $SYNC_REGEX ]]
download_speed="${BASH_REMATCH[1]}"
if [[ $download_speed != "" ]] ; then
  echo "$download_speed KB/sec"
fi
# drobox-up
# echos the Dropbox upload speed
#!/usr/bin/env bash

status=`dropbox status | grep Uploading`
SYNC_REGEX="([0-9,]+) KB/sec"

[[ $status =~ $SYNC_REGEX ]]
upload_speed="${BASH_REMATCH[1]}"
if [[ $upload_speed != "" ]] ; then
  echo "$upload_speed KB/sec"
fi
#!/usr/bin/env bash
# Dropbox-files
# lists a single filename if only a single file is being synced
# otherwise, echos the number of files synced

status=`dropbox status | grep Syncing`
SYNC_REGEX="([0-9,]+) files remaining"
FILENAME_REGEX='"(.*)"'

[[ $status =~ $SYNC_REGEX ]]
files_remaining="${BASH_REMATCH[1]}"
if [[ $files_remaining == "" ]]; then

    [[ $status =~ $FILENAME_REGEX ]]
    filename="${BASH_REMATCH[1]}"
    echo $filename

else
    echo "$files_remaining files"
fi

3. Add them to your conky script

Now that we have our shell scripts, and our icons, you can execute them in your conky script. I got the arrows from the nice icon set. If you're lazy you can also get them from my rc files.

Once you have all your assets, add in the relevant pieces into your conky:

out_to_console yes
out_to_x no
update_interval 1

lua_load $HOME/.xmonad/conky_scripts/conky_lua_scripts.lua

# note: Dropbox needed dropbox-cli on arch

TEXT
# ---- START DROPBOX STUFF ---
^fg(\#007ee5) ^i($HOME/.xmonad/icons/Dropbox.xbm) \
# ---- description of files changing ---
^fg(\#FFFF00) ${execi 6 $HOME/.xmonad/conky_scripts/Dropbox-files} ^fg()\
# ---- download speed info ---
^fg(\#8888FF) ^i($HOME/.xmonad/icons/net_down_03.xbm) ${execi 6 $HOME/.xmonad/conky_scripts/Dropbox-down} ^fg() / \
# ---- upload speed info ---
^fg(\#AA0000) ^i($HOME/.xmonad/icons/net_up_03.xbm) ${execi 6 $HOME/.xmonad/conky_scripts/Dropbox-up} ^fg() \

Notes:

  • I changed the colors with ^fg(#COLOR_HASH)
  • to split your conky on multiple lines, I use the delimiter '\'

And there you go! You have a nice, clean Dropbox activity bar.


Comments

comments powered by Disqus

About Yusuke Tsutsumi
I work at Zillow. I focus on tools and services for developer productivity, including build and testing.

My other interests include programming language design, game development, and learning languages (the non-programming ones).