Code Monkey home page Code Monkey logo

karabiner.ts's People

Contributors

evan-liu avatar napisani avatar paradox460 avatar willpuckett 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

Watchers

 avatar  avatar  avatar

karabiner.ts's Issues

[Bug] if layer has optionalAny, keys should allow optionalAny as well

This code above enforces layers with modifiers do not allow keymaps to have modifiers but does not handle the case when both need to have optional any modifiers

This code produces valid configuration for example and is required to allow common shortcuts like command + left_arrow etc for the remapped keys

layer('semicolon', 'semicolon-down')
    .modifiers({ optional: 'any' })
    .manipulators([
      withModifier({ optional: 'any'})([
        map('l').toAfterKeyUp('right_arrow'),
        withMapper({
          j: 'left_arrow',
          k: 'down_arrow',
          l: 'right_arrow',
          i: 'up_arrow',
        })((k, v) => map(k).to(v as ToKeyCode)),
      ]),
    ]),

error: `manipulators` is missing or empty

[error] [console_user_server] parse error in ~/.config/karabiner/karabiner.json: `complex_modifications` error: `manipulators` is missing or empty in {"description":"","manipulators":[]}

Need to check empty manipulators when build.

Doesn’t seem to work with yabai

Hi,

Recently installed karabiner.ts and I want to use it in place of skhd for yabai. skhd binds shortcuts to shell commands and I thought I could do the same using karabiner.ts as well. But it doesn’t work. Can anyone help me understand if there's anything wrong with it. My config looks like this.

import { to$ } from 'karabiner.ts'

export const yabai = {
  j: to$('yabai -m window --focus south'),
  k: to$('yabai -m window --focus north'),
  h: to$('yabai -m window --focus west'),
  l: to$('yabai -m window --focus east'),
  y: to$('yabai -m space --mirror y-axis'),
  x: to$('yabai -m space --mirror x-axis'),
  o: to$('yabai -m config focus_follows_mouse autofocus'),
  t: to$('yabai -m window --toggle float --grid 4:4:1:1:2:2'),
  m: to$('yabai -m window --toggle zoom-fullscreen'),
  e: to$('yabai -m space --balance'),
  p: to$('yabai -m window --space prev'),
  n: to$('yabai -m window --space next'),
  r: to$('yabai --restart-service'),
  s: to$('yabai --start-service'),
  c: to$('yabai --stop-service'),
}

and then in index.ts as

const rules = [
  duoLayer('q', 'w')
    .manipulators(yabai)
    .notification('yabai mode')
    .toIfActivated(toLocalSound('pop')),
]

writeToProfile('Default', rules, {
  'basic.simultaneous_threshold_milliseconds': 100,
  'duo_layer.threshold_milliseconds': 200,
  'duo_layer.notification': true,
})

Utility method withMapper()

Map a group of manipulators in the same way with a mapper function.

withMapper((k) => map(k).to(''))(['a', 'b', 'c'])

Looks like Deno setup doesn't work

Maybe I'm holding it wrong, but I thought I'd report this

deno run  --allow-env --allow-read --allow-write main.ts         
error: Uncaught ReferenceError: require is not defined
    return require('node:path').join(
    ^
    at Object.karabinerConfigFile (https://deno.land/x/[email protected]/output.ts:16:5)
    at writeToProfile (https://deno.land/x/[email protected]/output.ts:61:51)
    at file:///Users/kai/projects/karabiner/main.ts:13:1

looks like the output thing tries to import node:path and barfs. everything else seem working

console.log(rule("stuff").manipulators([...]).build())

this works fine

typeSequence() to type a string of keys

typeSequence('console.log()←')

Support single-character key_code, key alias, and shifted punctuations.

It is currently impossible to express it in TypeScript. So the parameter will only be able to be string; and a runtime/build-time error instead of complier error for unsupported characters.

There can be a mapper parameter to support mapping customised characters to ToEvent.

typeSequence('❌❌', {
  '❌': toKey('βŽ‹', '⌘'),
})

Help needed

First of all, thank you for the effort you put into making this tool!

I need help as I thought I had understood this tool but I haven't, or rather I just can't set up what I need, and here's what I need:

  1. when I press "command" twice, I want to get F16
  2. when I press "command" once, I want to get F15
  3. I want the "command" key to still work normally as a modifier in any combination with other keys.

I tried this code:

mapDoubleTap('left_command', 'optionalAny').to('f16').singleTap(toKey('f15'))

The first and second requirements work. The third - which is the most important one - doesn't.

What am I doing wrong?

Playground uses old version?

I had played around a bit in the Playground and wondered why one feature wasn't working. Could it be that the Playground is not using the latest version? When I run the ts script locally it works as expected.

Request: DelayedLayer

First off thanks for this amazing DSL for karabiner! Havent used it for a few years cause I bought a moonlander, but recently got a macbook so its nice to see how much nicer karabiner itself got and how nice it is to configure with this project.

I find myself wanting a layer modifier that I think is not currently covered by the options that exist, but I think should be possible with the karabiner spec. Essentially my problem is typing fast and it not recognizing the key as a press because it is still down when I hit the next key.

SimLayers do the opposite of what I want, they make me type fast to get the layer, but I want the layer only when I am going slow and to be the normal key when fast. So after XXX ms of holding a key down I want to set the layer var to 1, if I release before that it should still be 0. I think this should be possible with to_delayed_action. I might try adding this manually first and then can maybe try to make a PR unless this is something it would be easy for you to add, or if you have any other ideas for this.

layer(): passing through modifier keys

Amazing project!

I created a layer with arrow keys that I activate with F, so I have:

    layer('f', 'f-arrow-mode').manipulators([
      map('i').to('↑'),
      map('j').to('←'),
      map('l').to('β†’'),
      map('k').to('↓'),
    ])

Is there a way to let these mappings work orthogonally with modifiers such as Shift or Option? Would I even be able to remap such modifiers to D, S etc? Would be awesome to be able to hold down S+D+F then hit J to select words backwards just with the homerow keys.

Modifier Key Layers

First off, thank you so much for all the work you've done. I've been using a different Karabiner config generator for a bit over a year but yours has dramatically reduced the amount of code I had and made it easier to read.

In my current config, I use both the "left_option" and "right_option" keys as layer keys themselves, without any additional keys. From what I've gathered this isn't really possible although I've kinda made it work

Can't map to Backspace

Thanks in advanced for the help!
So basically, I want to map fn+backspace to option+backspace.
Dug around in the types and found that the symbol ⌫ represents backspace.
But when I try to use it, it doesn't recognize and i get a type error, and also when I build, it doesn't seem to work.
That is my code currently:

  rule('fn delete word').manipulators([
    // config key mappings
    map('fn', '⌫').to('right_option', '⌫'),
  ]),

How would I go about doing this?

Simplify left_ / right_ modifiers

Right now, there are 2 options to have sides in modifiers:

  • ['left_command', 'right_option']
  • { left: '⌘', right: 'βŒ₯' }

Both are too verbose compared to '⌘βŒ₯'.

There is an issue on Goku discussing the idea of < and > for left_ and right_, so it could be

  • <⌘>βŒ₯ or >⌘βŒ₯>

However, it is too hard to express in TypeScript.

I am thinking about the first character instead

  • <⌘βŒ₯ for left_command, left_option
  • >⌘βŒ₯ for right_command, right_option
  • ['<⌘', '>βŒ₯'] for left_command, right_option

Or use the letter l and r instead of < and >

  • l⌘βŒ₯ for left_command, left_option
  • r⌘βŒ₯ for right_command, right_option
  • ['l⌘', 'rβŒ₯'] for left_command, right_option

Or maybe is { l: '⌘', r: 'βŒ₯' } good enough if not used often?

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.