Giter Site home page Giter Site logo

itspriddle / shotty Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 169 KB

Automatically copy screenshots to Dropbox and send a public URL to the clipboard on OS X

License: MIT License

Ruby 91.06% Shell 0.63% HTML 8.31%
dropbox ruby launchd screenshots

shotty's Introduction

shotty

This script makes it easier to share screenshots and files via Dropbox on OS X. If you hate the public landing page you get with these Dropbox features, read on.

Dropbox already has that!

Dropbox already provides Shared Links and Shared Screenshots. They point to an HTML landing page that allows the user to download or browse files (or bugs them to sign up for Dropbox). For some use cases this is fine, but most of the time I'd rather have a direct link to paste into Slack or GitHub Issues.

Shared Links can be edited manually to point directly to a file. But I hate doing things manually so I wrote a thing to save me seconds a week.

Gimme

shotty is written in Ruby. If you are a Rubyist, you may care to know the script uses OS X's system Ruby with standard library dependencies only. If you're not a Rubyist, that jargon means you don't need to install anything special to run shotty.

The script can be downloaded directly from GitHub. Run the following commands in Terminal.app.

Download the script:

curl -L https://github.com/itspriddle/shotty/raw/master/bin/shotty > /usr/local/bin/shotty

Make it executable:

chmod +x /usr/local/bin/shotty

Check that it works:

shotty -v

You should see output like "Shotty v0.1.0"

Authorization

To use shotty, you need a Dropbox OAuth2 key. To generate one, run shotty authorize and follow the instructions in your browser.

Note that shotty uses full Dropbox access so it can access all of your files. The shotty-server handles the OAuth flow.

Usage

You can now use shotty to work with your Dropbox account. If you only care about automatically copying Dropbox URLs when you take a screenshot, skip the next section.

The shotty script

The shotty script contains several subcommands for working with shared links. See shotty --help for a full overview. The most useful are:

  • shotty create-url <file>: Creates a Dropbox URL for the specifed file. This should be used with files that have never had a shared link generated. Otherwise it will fail.
  • shotty get-url <file>: Gets an existing Dropbox shared link for the specified file.
  • shotty url <file>: Gets or creates a Dropbox shared link for the given file. This is useful when it is not known ahead of time whether a file already has a shared link.

Automatically copy direct Dropbox URLs for screenshots

Do you want a direct Dropbox URL copied to your clipboard when you create a screenshot? Me too, here's how.

Since the screenshot sharing feature built into Dropbox doesn't support a direct link, turn it off. Option+Click on the Dropbox icon in the OS X menubar and click Preferences. Click the Import tab, then uncheck "Share screenshots using Dropbox".

A launchd.plist will be used to copy screenshots from ~/Desktop to ~/Dropbox/Shotty and copy a direct shared link to the clipboard.

To enable this behavior:

shotty plist > $(shotty plist-file)
launchctl load $(shotty plist-file)

To disable:

launchctl unload $(shotty plist-file)
rm $(shotty plist-file)

See the screenshot_directory configuration option below to customize the directory screenshots are copied to.

NOTE: If you used dropbox-screenshots-plist, make sure to disable that first:

launchctl unload ~/Library/LaunchAgents/net.nevercraft.dropbox-screenshots.plist
rm ~/Library/LaunchAgents/net.nevercraft.dropbox-screenshots.plist

Configuration

shotty configuration is stored in a JSON file at ~/.config/shotty.json. The following options are available:

  • token REQUIRED: Dropbox API OAuth2 access token.
  • dropbox_root OPTIONAL: Root Dropbox directory, by default ~/Dropbox. Useful if you have personal and business Dropbox folders on the same machine.
  • screenshot_directory OPTIONAL: Directory to store screenshots in, by default ~/Dropbox/Shotty. This must be a subdirectory of dropbox_root.

Full example configuration file:

{
  "token":                "MY-REDACTED-TOKEN",
  "dropbox_root":         "/Users/priddle/Dropbox (Personal)",
  "screenshot_directory": "/Users/priddle/Dropbox/Shotty"
}

Ugh, I hate you, make this all go away.

Visit Dropbox Account Security, and remove "shotty-cli" at the bottom of the page.

To remove shotty from your system:

launchctl unload $(shotty plist-file)
rm $(shotty plist-file)
rm $(shotty config-file)
rm /usr/local/bin/shotty

Development

  1. Fork it (https://github.com/itspriddle/shotty/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Released under the MIT License. See LICENSE.

shotty's People

Contributors

itspriddle avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shotty's Issues

Doesn't work with Personal & Business Dropbox folder

I loved dropbox-screenshots-plist, but after installing a new mac I found it is deprecated. So I tried shotty.

After installing it, it seems like it is not compatible with a Dropbox folder name that is not 'Dropbox. If you have an business account, your personal folder is no longer just "Dropbox" but "Dropbox (Personal)".

A symlink and changing the screenshot folder in the config, makes it work.

It might be an idea to either extend the install guide, or building support for other folder names.

Move multiple screenshots at once

launchd's WatchPaths does not include a way to indicate which file has just been updated. If a user creates multiple screenshots very quickly, this can result in shotty only moving the latest one to Dropbox.

A possible work around would be to have shotty try moving all pending screenshots. If this is done, shotty needs to move these files off of the Desktop (or rename them so they aren't considered a pending screenshot).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.