Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly capture custom copy/paste commands with positional argument(s) #1769

Closed
vkuznet opened this issue Jan 7, 2025 · 1 comment

Comments

@vkuznet
Copy link

vkuznet commented Jan 7, 2025

Hi, I recently discovered this excellent tool and I would like to address particular security issue on macOS. The default copy/paste commands to copy and paste clipboard content can be easily sniffed by malware programs, see discussion over here. To address this issue I wrote my own secure clipboard manager application which provides scopy, spaste and shistory commands which I want to use instead of build-in macOS clipboard. For that I would like to remap Command-C/Command-V macOS commands to use my tools. I tried to use the config shown below but it does not work. What I'm looking for is how to not only to remap keys but also to pass to my shell command a positional argument, e.g.

# example how to copy some text to secure clipboard in a terminal
/usr/local/bin/scopy "some text"

In other words when I select some text elsewhere on my system I want to invoke Command-C keystroke and pass to my shell command selected text, etc.

I would appreciate any feedback from your dev team if it can be achieved through some configuration. Of course I want a full set of commands to copy, paste and show my history which will interact with stdin and stdout.

Here is configuration which I tried:

{
    "description": "Remap Command-C/V to scopy/spaste",
    "manipulators": [
        {
            "from": {
                "key_code": "c",
                "modifiers": {
                    "mandatory": ["command"],
                    "optional": ["any"]
                }
            },
            "to": [
                {
                    "shell_command": "/usr/local/bin/scopy"
                }
            ],
            "type": "basic"
        },
        {
            "from": {
                "key_code": "v",
                "modifiers": {
                    "mandatory": ["command"],
                    "optional": ["any"]
                }
            },
            "to": [
                {
                    "shell_command": "/usr/local/bin/spaste"
                }
            ],
            "type": "basic"
        }
    ]
}
@tekezo
Copy link
Member

tekezo commented Jan 22, 2025

In order to achieve this, the scopy command will need to obtain information such as the selected text.
Could this be implemented using something like kAXSelectedTextAttribute?

@tekezo tekezo closed this as completed Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants