Giter VIP home page Giter VIP logo

magnet's Introduction


CI Release version OpenCollective OpenCollective

Clipy is a Clipboard extension app for macOS.


Requirement: macOS 10.10 Yosemite or higher

Distribution Site : https://clipy-app.com

Development Environment

  • macOS 10.15 Catalina
  • Xcode 12.2
  • Swift 5.3

How to Build

  1. Move to the project root directory
  2. bundle install --path=vendor/bundle && bundle exec pod install
  3. Open Clipy.xcworkspace on Xcode.
  4. build.

Contributing

  1. Fork it ( https://github.com/Clipy/Clipy/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

Localization Contributors

Clipy is looking for localization contributors.
If you can contribute, please see CONTRIBUTING.md

Distribution

If you distribute derived work, especially in the Mac App Store, I ask you to follow two rules:

  1. Don't use Clipy and ClipMenu as your product name.
  2. Follow the MIT license terms.

Thank you for your cooperation.

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

Licence

Clipy is available under the MIT license. See the LICENSE file for more info.

Icons are copyrighted by their respective authors.

Special Thanks

Thank you for @naotaka who have published ClipMenu as OSS.

magnet's People

Contributors

dependabot[bot] avatar divinedominion avatar econa avatar econa77 avatar jasonm23 avatar kphrx avatar sindresorhus avatar zaru avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magnet's Issues

keyEquivalent String should not produce the physical key of a QWERTY keyboard

KeyHolder uses Magnet's KeyCombo.keyEquivalent to show which key the user has pressed.

Take the C key, for example; the key cap of that key has "C" printed on a QWERTY keyboard. But when you switch keyboard layouts to DVORAK or NEO2 or similar, the actual typed character is different. Magnet's current logic is independent of the on-screen character and always shows the physical key.

For the NEO2 layout, the C key produces an "ä" character, for example:

image
image

Users have reported this to be confusing, because they want to see the character, not the key of their keyboard in the KeyHolder RecordView.

It gets confusing when you use Magnet and Sauce to record local keyboard shortcuts and show them in NSMenuItems like I do, because the NSMenuItem.keyEquivalent expects the "ä" character while the record view shows the "C" key. In general terms, the NSMenuItem's meaning of a 'key equivalent' is the actual typed character, not the physical key. So there's a mismatch.

I think the keyEquivalent property should be renamed, e.g. to keyLabel or keyCap.

Bug: HotKey translates the key code wrongly when using non-QWERTY layout

I noticed this in the KeyHolder example app with a keyboard layout switch as explained in #70:

  • Switch from QWERTY to NEO2 keyboard layout
  • Press modifier keys and the physical "C" key on my keyboard

Expected: the hotkey is triggered when I press the same physical keys again.

Actual: the hotkey is triggered when I press the same modifiers, but with a different character key (i.e. the one that corresponds to the character that's printed on the physical keyboard)


This is all very confusing to explain :)

So the C key on my keyboard corresponds to the character "C" with the QWERTY layout.

Changing the layout to NEO2, for example, the C key corresponds to the character "Ä". To type the character "C", I have to hit the R key on the keyboard.

The physical key combo ⌘⇧⌥⌃C with the NEO2 layout stores the key code for "C". But to triggerer the HotKey, I have to press different keys on the keybard than the one I used to record the hotkey, i.e. in this case ⌘⇧⌥⌃R on the physical keyboard, because the R key types the "C" character.

The translation of pressed keys into QWERTY key codes does work, but it's apparently not used to install the keyboard listener.

Unregister all hotkeys by default when the app terminates

I can't think of any scenario where I wouldn't want the shortcuts to be unregistered. Could also be an option, but if so, I think it should still default to true.

I don't want this boilerplate in my code:

func applicationWillTerminate(_ aNotification: Notification) {
	HotKeyCenter.shared.unregisterAll()
}

Magnet doesn't use full screen when menu bar is hidden

I have set my dock and menu bar to automatically hide (see system preferences -> Dock & Menu bar -> automatically hide and show ..) . Although Magnet uses the space the comes available by hiding the dock, it doesnt do this for the menu bar. How can magnet be changed that it also uses screen space of the hidden menu bar?

More doc and example? How to listen `Ctrl + 3` and `Space`?

Hi, first of all, Thanks for open source

Second, I am confused about the syntax

if let keyCombo = KeyCombo(keyCode: 11, carbonModifiers: 4352) {
   let hotKey = HotKey(identifier: "CommandControlB", keyCombo: keyCombo, target: self, action: #selector())
   hotKey.register() // or HotKeyCenter.shared.register(with: hotKey)
}

What keyCode: 11 mean?
Where carbonModifiers: 4352 come from?
Does identifier: "CommandControlB" matter? or it only used for unregister?

Third, What if I want listen Ctrl + 3 and Space?

if let keyCombo = KeyCombo(keyCode: [What should I put here?], carbonModifiers: [What should I put here?]) {
   let hotKey = HotKey(identifier: [What should I put here?], keyCombo: keyCombo, target: self, action: #selector())
   hotKey.register() // or HotKeyCenter.shared.register(with: hotKey)
}

Thank you very much!

add a NSMenuItem.keyEquivalent compatible string transformation

I suggest adding a convenience function next to KeyCodeTransformer.transformValue(_:carbonModifiers:) that outputs a NSMenuItem-compatible String. Because transformValue produces a printable, upper-case letter, using this as NSMenuItem.keyEquivalent will result in always adding the ⇧ (Shift) modifier key.

The proposed KeyCodeTransformer.keyEquivalent should behave like this for example:

  • ⌃⇧T should return "T"
  • ⌥T should return "t"
  • ⌘⌥⇧⌃1 should return "1"

What do you think?


It's basically a refactoring:

    fileprivate func transformValue(_ keyCode: Int, modifiers: Int) -> String {
        return keyEquivalent(keyCode, modifiers).uppercased
    }

    fileprivate func keyEquivalent(_ keyCode: Int, modifiers: Int) -> String {
        // Return Special KeyCode
        if let unmappedString = transformSpecialKeyCode(keyCode) {
            return unmappedString
        }

        let source = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()
        let layoutData = TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)
        let dataRef = unsafeBitCast(layoutData, to: CFData.self)

        let keyLayout = unsafeBitCast(CFDataGetBytePtr(dataRef), to: UnsafePointer<CoreServices.UCKeyboardLayout>.self)

        let keyTranslateOptions = OptionBits(CoreServices.kUCKeyTranslateNoDeadKeysBit)
        var deadKeyState: UInt32 = 0
        let maxChars = 256
        var chars = [UniChar](repeating: 0, count: maxChars)
        var length = 0

        let error = CoreServices.UCKeyTranslate(keyLayout,
                                                UInt16(keyCode),
                                                UInt16(CoreServices.kUCKeyActionDisplay),
                                                UInt32(modifiers),
                                                UInt32(LMGetKbdType()),
                                                keyTranslateOptions,
                                                &deadKeyState,
                                                maxChars,
                                                &length,
                                                &chars)

        if error != noErr { return "" }

        return NSString(characters: &chars, length: length)
    }

Memory leak with CGEvent

Hi! When using this library we've noticed some memory leaks related to a CGEvent. Not sure if it is just our usage of it, but it could be related to the event object being retained and never released here:

https://github.com/Clipy/Magnet/blob/master/Lib/Magnet/HotKeyCenter.swift#L111-L116

One solution that seems to have fixed it for me was to use passUnretained instead of passRetained here: https://github.com/Clipy/Magnet/blob/master/Lib/Magnet/HotKeyCenter.swift#L170. I'm not sure if that could have a negative impact, though.

Any insights are appreciated!

Publish 3.3.0 Release

Currently the library is not building when used as SPM 'up to next major version'. But it builds fine with master branch.

(Recent API changes in the Sauce 2.2.0 dependency are preventing Magnet 3.2.0 from building.)

We just need a Magnet 3.3.0 release and it should resolve this.

macOS Siri press and hold style shortcut

How difficult would it be to implement a press and hold concept like the latest macOS does by default to trigger Siri(hold option + space).

Where would be the proper place in the codebase to introduce this type of timer? I'd be happy to try my hand at it, but would love a pointer on a good starting point.

Thanks!

2.2.0 (or 2.1.1)?

The current version of Magnet is 2.1.0 that was released over half a year ago.
And this app has had 7 commits after that.
Do you have a plan to increase the version number?
(I hope so because the versioning with Git tags is quite useful for me who use Carthage.)

⌘1 Does not seem to work

Thanks for the great Framework! It's amazing!
However I ran into a problem that I could not solve by myself.
I'm trying to make a hotkey ⌘1 but it just does not work for me. I created a new test project, added Magnet package and in viewDidLoad implemented following:

override func viewDidLoad() {
        super.viewDidLoad()

        // Does not work
        if let keyCombo = KeyCombo(key: .one, cocoaModifiers: [.command]) {
            let cmdOne = HotKey(identifier: "CommandOne", keyCombo: keyCombo) { hotKey in
                print("CommandOne")
            }
            cmdOne.register()
        }

        // Works perfectly well
        if let keyCombo = KeyCombo(key: .a, cocoaModifiers: [.command]) {
            let cmdOne = HotKey(identifier: "CommandA", keyCombo: keyCombo) { hotKey in
                print("CommandA")
            }
            cmdOne.register()
        }
    }

If this makes any difference I'm testing this on Macbook Pro 15" Mojave 10.4.4

Can you please support with that?

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.