Giter Site home page Giter Site logo

cdef's Introduction

cdef is a handy command-line tool to mess with your default applications.

I currently use it to:

  • Change default browser to Chrome
  • Change .xml handling from Xcode to TextMate

It uses:

  • URL
  • UTI

Download it from the Releases page

Note: Please fork and Pull Request, or create an issue

What are UTI? (Uniform Type Identifiers)

Uniform type identifiers (UTIs) provide a unified way to identify data handled within the system, such as documents, pasteboard data, and bundles. This chapter describes the concepts behind UTIs and shows how to specify them in your application bundles.

Have more information on Apple's website

Examples

###Get the default application to open PNG files:

$ cdef -readdefaultuti public.png
public.png -> com.apple.Preview

###Get all applications that can open PNG files:

$ cdef -readalluti public.png
public.png -> com.pixelmatorteam.pixelmator
public.png -> com.tapbots.TweetbotMac
public.png -> com.omnigroup.OmniGraffle6.MacAppStore
public.png -> com.apple.ColorSyncUtility
public.png -> com.apple.Preview

###Get which application will open http:// URLs:

$ cdef -readdefaulturl http
http -> com.apple.Safari

###Change your default browser to Chrome:

$ cdef -writedefaulturl http com.google.chrome

###Get supported URL types for Apple Mail:

$ cdef -readURLTypes /Applications/Mail.app/
mailto
message

###Get supported Document types for Apple Mail:

√        -> Application is default for this type
x        -> Application supports but is not default for this type

(Viewer) -> Application can open these files in read-only
(Editor) -> Application can modify these files
(None)   -> Application does not support this files
$ cdef -readDocumentTypes /Applications/Mail.app/
√ com.apple.mail.email (Viewer)
√ com.apple.mail.emlx (Viewer)
x com.apple.mail.emlx.part (None)
√ com.apple.mail.mbox (Editor)
√ com.apple.mail.imapmbox (Editor)
√ com.apple.mail.ewsmbox (Editor)
√ com.apple.mail.stationery (Editor)

Note: This will prompt a dialog to ask the user to confirm the change to Chrome.

I use it in my deployments as a Casper policy that executes /usr/bin/sudo -u#501 /usr/local/bin/cdef -writedefaulturl http com.google.chrome

See the list of UTIs here: https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1

Developers

You're more than welcome to contribute to the code!

Everything needed to create a package is under cdef-Package/. Just run cdef-Package/build_pkg.sh !

You will need to change the Team ID & Certificate.

But... please PR so we can keep only one repository.

cdef's People

Contributors

ftiff avatar

Stargazers

Kevin M. Cox avatar Brian Goldstein avatar Luu123 avatar SVDE avatar lukecharters avatar Søren Theilgaard avatar Mike Matz avatar Moe Munyoki avatar Macninja avatar Jeket avatar Matin Sasaluxanon avatar Kenny Botelho avatar boB Rudis avatar J.D. Healy avatar  avatar Tadayuki Onishi avatar Brad Clare avatar Ryan Moon avatar  avatar Thomas avatar Aaron Burchfield avatar Ziyang "Zion" Yang avatar Rui Marinho avatar Mike Dillion avatar brock chapin avatar Elizabeth Hills avatar Joshua Briefman avatar Brian Murphy avatar Narcis Tesa avatar Aaron Polley avatar Phinehas Bynum avatar eg avatar Roberto Salas avatar Todd McDaniel avatar Tobias Morrison avatar AP Orlebeke avatar Mike Hendrickson avatar Sean Hansell avatar Raul Santos avatar Steve avatar  avatar Tyler Riti avatar Arthur avatar Zack McCauley avatar aysiu avatar geoff avatar Stephen Johnson avatar Jeppe Ernst avatar Jason Bush avatar  avatar Jeremy Reichman avatar Anders Tao avatar Richard Purves avatar  avatar Scott avatar Andy Semak avatar  avatar Jeremy Leggat avatar  avatar Clayton Burlison avatar Owen Hael avatar Shea Craig avatar Morgan Aldridge avatar  avatar

Watchers

James Cloos avatar  avatar Anders Tao avatar Mike Hendrickson avatar Matin Sasaluxanon avatar Moe Munyoki avatar

cdef's Issues

cdef hangs when a console user is not logged in

When run from say, a Jamf Pro extension attribute on a server that no one logs into, instead of quitting gracefully, the application hangs with the error:

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

and hangs... forever.

Found this out when recons wouldn't complete on my servers for a few months... 😊

Apple Silicon version

Hi there!

Thank you for a great tool!

Do you plan on releasing a new version, Universal build, and maybe not in beta anymore?

I don't know of a better solution for changing these settings on client machine, and it has been a great tool for me. I will be grateful!

Thanks!
Søren

Enhancement - man page

Hi,

I've written a suitable man page for cdef and attached it to this issue ticket. What you need to do is give it 755 permissions and copy it into /usr/local/share/man/man1 . It'll show up as expected when you "man cdef".

cdef.1.zip

Implement -v or -version flags that displays the version only

Please implement an option that displays the version that I may capture it in an extension attribute in Jamf to make sure what version I have installed across a given deployment. Currently using the following command which works, but if for any reason the format of the help message changes, this will break.

cdef | head -n2 | tail -n1 | awk '{print $2}' | sed 's/v//'

Add CSV support

application,compatibleUTIs,{Not Supported|Capable|Default}

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.