Giter VIP home page Giter VIP logo

newicon's Introduction

NewIcon

NewIcon is a command line tool to modify and manage icons for applicatons, files, and directories on macOS.

Features

  • A quick way to overlay some text over an icon
  • Reset to the original icon
  • Use any SwiftUI View as a template

Installation

Install using Mint.

$ mint install auramagi/NewIcon

Usage

Overlay text over the original icon

$ new-icon text FILE TEXT

# Add version number to Xcode app icon
$ new-icon text /Applications/Xcode.app 13.4.1
  • Tip: when changing Xcode icon, don't forget about the Simulator icon! It's located inside the Xcode bundle: /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

Revert an icon to the original

$ new-icon reset FILE

Usage with SwiftUI template files

Use a SwiftUI template to modify an icon

$ new-icon template icon TEMPLATE FILE CONTENT

See SampleTemplates folder for some inspiration.

File Command Output
NewHue.swift new-icon template icon NewHue.swift /Applications/Xcode.app red
Trash.swift new-icon template icon Trash.swift /Applications/Xcode.app

Create a sample template file

If you need a place to start with writing your own SwiftUI template files, run this command to get a sample template.

$ new-icon template init

Open a template file in Xcode

NewIcon allows you to edit a template file with Xcode by creating and opening a temporary SwiftPM package. Edit Template/Sources/Template/Template.swift inside, and any changes will be synced to the original file. After you are done editing close Xcode and press return to delete this temporary package.

$ new-icon template edit TEMPLATE
  • Tip: Make sure My Mac is selected as build destination.

Editing the sample template

Clear build cache for templates

Template files need to be built before they can be used. At the very least, this takes several seconds, so NewIcon caches build products inside ~/.new-icon/cache to speed up any subsequent use of the same template. There is a simple command to clear this cache.

$ new-icon template cache clear

Detailed command info

Run new-icon help to see all options.

newicon's People

Contributors

auramagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

newicon's Issues

Support for dark mode OFF

Unreadable when dark mode is disabled.


as is:
text is difficult to read

image


to be:
text can be read


environment:
Dark mode OFF

Mac OS 12.3.1(21E258)

❯ mint run auramagi/NewIcon -h
🌱 Finding latest version of NewIcon
🌱 Running new-icon 0.1.1...
OVERVIEW: macOS icon customization

❯ mint version
Version: 0.17.1

❯ swift --version
swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
Target: arm64-apple-macosx12.0


to reproduce:

❯ mint run auramagi/NewIcon text /Applications/Xcode-13.3.1.app 13.3.1 
🌱 Finding latest version of NewIcon
🌱 Running new-icon 0.1.1...

workaround:
Dark mode ON
Rerun!

Taking View capture with cacheDisplay is buggy

These are current view capture steps:

  1. Add template View to NSHostingController
  2. Add it to a custom NSWindow
  3. Save as image with cacheDisplay(in:to:)

However, using cacheDisplay produces some side-effects and the resulting image does not exactly match View as displayed.

To get around some display issues, we tell SwiftUI to first flatten view hierarchy by itself using the drawingGroup modifier.

But even this has some weirdness, especially with blend modes. First of all, it loses all transparency, but that part is at least consistent with previews/actual rendering after using drawingGroup.

Using .overlay(Color.mint.blendMode(.hue)):

We can get around that by masking the result with the initial view:

@ViewBuilder public func hue(_ color: Color) -> some View {

But this still leaves us with incorrectly blended color in some parts.

Compare to how this looks in previews and when displayed in a window.

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.