返回资讯中心
外部精选
软件工程
#开发者实时流

Pressy is back from the dead (on the Mac, at least)

Your old Pressy button, alive again - on a Mac.

Hacker News 最新gufertum2026/10/17 · 2026/10/1730 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Your old Pressy button, alive again - on a Mac.

Pressy was a 2014 Kickstarter gadget: a tiny button that sits in the headphone jack and triggers actions on Android phones. The company and its app are long gone. pressy is a small macOS daemon that makes the button useful again: press patterns like ., .., - or .- run shell commands, Apple Shortcuts or built-in actions such as Spotify play/pause, next track or microphone mute.

pressy-demo.mp4

Sound on: a click plays and pauses Spotify, holding the button fires Raycast confetti.

Tested on a MacBook Pro M5 (Mac17,2) with macOS 27.0.1. It should work on any Apple silicon Mac whose 3.5 mm jack takes headsets.

Installer package. Download pressy-<version>.pkg from the latest release and open it. It is not notarized (that needs a paid Apple Developer ID), so the first time macOS refuses to open it: go to System Settings > Privacy & Security, click Open Anyway next to the pressy message, and run the installer.

curl -fsSL https://raw.githubusercontent.com/gufertum/pressy-resurrected/main/get-pressy.sh | bash

That downloads the latest release, checks its sha256, and installs ~/.local/bin/pressy, ~/Applications/Pressy.app and their LaunchAgents. Your config is left alone if you have one. Rather read before you pipe into a shell? Same thing in three steps:

curl -fsSLO https://raw.githubusercontent.com/gufertum/pressy-resurrected/main/get-pressy.sh less get-pressy.sh bash get-pressy.sh

Other ways to install Release zip by hand. Download pressy-<version>-macos-arm64.zip from the releases page, compare it with the .sha256 file, unpack it, then:

xattr -dr com.apple.quarantine pressy-/ # a browser download is quarantined, see below pressy-/scripts/install.sh

From source (needs the Command Line Tools: xcode-select --install):

git clone https://github.com/gufertum/pressy-resurrected.git cd pressy-resurrected make cert # once: local code-signing certificate, keeps permissions across rebuilds make install # tests, builds, signs, installs

About signing. The releases are signed with the maintainer's self-signed certificate. They are not notarized, because that needs a paid Apple Developer ID. curl does not mark downloads as quarantined, so Gatekeeper does not get involved. Files downloaded with a browser are marked; xattr above removes the mark. Every release carries the same signature, so macOS keeps your permissions across updates. To update, run the one-liner again.

The first Spotify press asks whether pressy may control Spotify: allow it.

Your sound stays on the speakers and your mic stays the built-in one, even though macOS thinks you just plugged in a headset.

Spotify play/pause, next, previous; only while Spotify runs, it never launches it

Apple Music play/pause, next, previous

Raycast any deeplink: confetti, clipboard history, window management, your own script commands and extensions

Apple Shortcuts run any Shortcut by name, the editor lists yours

any app key combinations (cmd+shift+4, ctrl+cmd+q, ...), shell commands and scripts

your Mac dark mode, lock, sleep, screen saver, mute, volume, microphone mute, keep awake

Buttons: the original Pressy, its clones (Klick, Mi Key, the unnamed AliExpress ones) and the center button of any wired headset with a 4-pole plug. They all work the same way electrically.

Menu bar app

Pressy.app puts a ◎ in the menu bar; it flashes on every press. Click it to see:

Edit… (⌘,) opens the editor: a page per pattern and one for the general settings. For each action, pick its type and then the value: built-ins from a grouped list, Shortcuts from your Shortcuts library, a script or sound file through a file picker, key combinations with Record (click, then press the keys), Raycast deeplinks from examples. Test now runs a pattern's actions once without saving. Save & apply validates everything, writes the config file (in its format, YAML or JSON) and restarts the daemon. The editor rewrites the file in its own tidy format, so comments you added by hand are lost.

The app is optional: it only edits the config file and listens to the daemon. It starts at login (LaunchAgent li.sudo.pressy.bar); Quit Pressy menu in its ⋯ menu stops it until the next login.

A pattern is a sequence of up to 5 presses: . is a short press, - a long one (held at least longPressMs, default 500 ms).

A pattern fires after sequenceGapMs (400 ms) without a new press. When no configured pattern can still follow, it fires at once on release. With only . and - mapped, every press reacts instantly. Mapping .. as well makes . wait those 400 ms to see whether a second click follows.

To see what your fingers actually produce, stop the agent and watch:

launchctl bootout gui/$(id -u)/li.sudo.pressy pressy watch # prints every press with its duration and the recognised pattern; Ctrl-C to stop launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/li.sudo.pressy.plist

Configure

The config lives in ~/.config/pressy/config.yaml (or wherever $PRESSY_CONFIG points). make install creates it from config.example.yaml. After editing:

pressy reload # validates the config first, then restarts the agent

A broken config is rejected with the exact spot (patterns[".."]: unknown key "shorcut"), and the running daemon keeps going.

longPressMs: 500 sequenceGapMs: 400 restoreAudioRoute: true actionTimeoutSeconds: 30

patterns: ".": { builtin: spotify.playpause } "..": { shortcut: Toggle Focus } "-": { builtin: input.togglemute } ".-": { run: "open -a 'Visual Studio Code'" } "--": { script: ~/bin/pressy-hook.sh }

Always quote the patterns. A bare - starts a YAML list, and pressy then tells you so. Values with :, # or quotes in them need quotes too; the menu bar editor writes every value quoted.

Prefer JSON? Name the file config.json (or point $PRESSY_CONFIG at any .json file); same keys, same validation:

{ "longPressMs": 500, "patterns": { ".": { "builtin": "spotify.playpause" }, "-": [{ "sound": "Tink" }, { "builtin": "input.togglemute" }] } }

pressy uses the first existing of config.yaml, config.yml, config.json. pressy convert config.json config.yaml converts between the formats; make install does that once for an old config.json (kept as config.json.bak).

Unknown keys are errors, so typos fail loudly instead of being silently ignored.

Each action has exactly one of these keys:

script and run get the pattern in PRESSY_PATTERN. pressy check verifies that Shortcuts, scripts and sounds exist and that an app handles raycast://.

Several actions per pattern. Use a list; the actions run one after another. A sound only starts, so it never delays what follows:

"-":

  • sound: Tink
  • builtin: input.togglemute "--":
  • keys: cmd+c
  • keys: cmd+tab
  • keys: cmd+v

Key combinations. Modifiers cmd, shift, ctrl, opt (or alt), fn, joined with +. The last part is a character (a, 4, /, written plus for +) or a named key: return, tab, space, escape, delete, forwarddelete, left, right, up, down, home, end, pageup, pagedown, f1 to f20. Characters follow your current keyboard layout, so cmd+z is undo on QWERTZ as well. Any macOS or app shortcut works this way.

Built-in actions (pressy actions lists them):

Focus / Do Not Disturb and Wi-Fi have no stable command-line interface; build a Shortcut for them and use shortcut. Adding a built-in yourself: one case in BuiltinAction.swift and one line in its definition table (a process, an AppleScript or a key combination).

".-": { run: "osascript -e 'display notification "Pressy pressed" with title "pressy"'" } "---": { run: "curl -fsS -m 5 -X POST http://homeassistant.local:8123/api/webhook/pressy" } "--": { script: ~/bin/pressy-hook.sh }

One script for everything, switching on the pattern:

#!/bin/zsh

~/bin/pressy-hook.sh - called by pressy, PRESSY_PATTERN is ".", "..", "-", ...

case "$PRESSY_PATTERN" in --) open -a Terminal ;; *) say "pattern $PRESSY_PATTERN" ;; esac

Commands

Command Does

pressy run the daemon itself (what the LaunchAgent starts)

pressy watch prints presses and patterns, runs nothing

pressy check validates the config and the Shortcut names

pressy reload check, then restarts the LaunchAgent

pressy trigger <pattern> runs the mapped action once without pressing; exit code = result

pressy actions lists the built-in actions

pressy convert <in> <out> rewrites a config in the format of <out>'s extension

All commands take --config PATH. Exit codes: 0 ok, 1 action or check failed, 64 usage, 69 Headset device missing or held by another pressy, 75 restart requested (new permission), 78 config error.

make install / make uninstall (keeps config, logs and certificate) / make logs (tail -f on the log) / make cert.

Remove everything, including the certificate and the privacy entries:

make uninstall && rm -rf ~/.config/pressy ~/Library/Logs/pressy*.log security delete-identity -c "pressy local signing" # only if you ran make cert

Installed with the one-liner or the package, without a checkout:

curl -fsSL https://raw.githubusercontent.com/gufertum/pressy-resurrected/main/scripts/uninstall.sh | bash sudo rm -rf "/Library/Application Support/pressy" && sudo pkgutil --forget li.sudo.pressy # only after the .pkg

Then remove pressy with − under System Settings > Privacy & Security > Input Monitoring (and Accessibility, if you used media.*).

macOS asks once per permission. All entries are called pressy and live in System Settings > Privacy & Security.

Input Monitoring (required). pressy can hold the button without it, but macOS never delivers a single press.

On the first start macOS shows "pressy" would like to receive keystrokes from any application. Click Open System Settings.

Under Input Monitoring, switch pressy on. If it is not listed, click +, press ⌘⇧G, enter ~/.local/bin/pressy, add it and switch it on.

Presses work right away. Within about a minute pressy also notices the grant and restarts itself, so its state and log are clean:

INFO input monitoring granted, restarting exit=75 INFO start version=0.1.0 ... input_monitoring=granted

Impatient? pressy reload does the same at once.

Check the current state any time: grep input_monitoring ~/Library/Logs/pressy.log | tail -1.

Automation (Spotify, Music). The first spotify.* press shows "pressy" wants access to control "Spotify": click Allow. Clicked Don't Allow by accident? Privacy & Security > Automation > pressy > Spotify, switch it on.

Accessibility (keys, media.*). Switch pressy on under Privacy & Security > Accessibility, then pressy reload.

Updates and the signing certificate. macOS ties every grant to the code signature of the binary.

To fix a stale switch (also needed once when moving from ad-hoc to the certificate):

tccutil reset cannot do this for pressy: it only knows apps registered with Launch Services, and pressy is a bare binary.

make cert runs scripts/make-signing-cert.sh. It creates the self-signed identity "pressy local signing" in your login keychain (valid 10 years). The certificate is not added to any trust settings, and only codesign may use its key.

~/Library/Logs/pressy.log, one line per event:

2026-10-17T12:27:17.816+0200 INFO audio route restored role=output from="External Headphones" to="MacBook Pro Speakers" 2026-10-17T12:30:02.114+0200 INFO press ms=182 2026-10-17T12:30:02.517+0200 INFO pattern pattern=. action="builtin spotify.playpause" 2026-10-17T12:30:02.601+0200 INFO action done pattern=. action="builtin spotify.playpause" ms=84 output="" 2026-10-17T12:31:10.020+0200 ERROR action failed pattern=-- action="run "~/bin/pressy-hook.sh"" ms=12 exit=127 output="zsh:1: no such file or directory: /Users/you/bin/pressy-hook.sh"

Troubleshooting (Don't Panic)

Symptom Fix

Presses do nothing, log says input monitoring not granted allow pressy under Privacy & Security > Input Monitoring, see Permissions

Switch for pressy is on, but presses do nothing, log says input_monitoring=denied the grant belongs to an older build: remove pressy with − and add it again, see Permissi

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →