Skip to content

Add "external script" paste method#638

Open
piec wants to merge 2 commits intocjpais:mainfrom
piec:main
Open

Add "external script" paste method#638
piec wants to merge 2 commits intocjpais:mainfrom
piec:main

Conversation

@piec
Copy link
Contributor

@piec piec commented Jan 21, 2026

Thanks for making Handy, I've only discovered a few days ago and it's awesome.
A few months ago I searched for something like this but couldn't find anything.

Before Submitting This PR

Please confirm you have done the following:

Human Written Description

Adds a new paste method that uses an external script.
That gives me the flexibility to post process the text as I want without adding complexity to Handy.
Examples:

  • when the focused window/tab is a chat I don't want capitals, or a final dot
  • depending on the language typography rules are not the same (space before "?")

Related Issues/Discussions

I'm noticing these after making the PR oops :)
But they complement each other:

Testing

I have tested it for a few days on an Arch Linux / xorg / i3 setup.
I think it should work on windows / macos too but cannot test on these platforms.

Simple external script example
#!/usr/bin/env python
import sys
import os
import subprocess

if len(sys.argv) <= 1:
        os.exit(1)

text = sys.argv[1]

# subprocess.run(['notify-send', '--', text])

# Make first character lowercase
if text:
    text = text[0].lower() + text[1:]

# Remove trailing period (but keep other punctuation)
if text.endswith('.'):
    text = text[:-1]

# French convention: add space before "?" and "!"
import re
text = re.sub(r'(?<! )([?!])', r' \1', text)

subprocess.run(['xdotool', 'type', '--', text], check=True)
I also have a more complex script where I change the behavior depending on the focused windows. With `xdotool getactivewindow getwindowname`.

Screenshots/Videos (if applicable)

image

AI Assistance

  • No AI was used in this PR
  • AI was used (please describe below)

If AI was used:

  • Tools used: Claude code
  • How extensively: Claude did the initial boilerplate for settings layout, which I simplified aferwards.

@cjpais
Copy link
Owner

cjpais commented Jan 21, 2026

Can we make this a Linux only thing?

@piec
Copy link
Contributor Author

piec commented Jan 21, 2026

Yes, but wouldn't it be useful to macos too?
Windows users probably aren't used to do stuff like this.

@cjpais
Copy link
Owner

cjpais commented Jan 21, 2026

I would rather keep options fairly slim where possible. For me everything works more or less perfect on MacOS. It's my primary machine and I have very few if any issues

@piec
Copy link
Contributor Author

piec commented Jan 21, 2026

@cjpais done
I only hid it in the UI, if in any case someone wants force it using the conf file

@gabenasci
Copy link

gabenasci commented Jan 22, 2026

Imo it would be nice to still be able to select one of the pre-existing paste methods but also run the script as well (for other use-cases other than just custom paste, like a custom post-transcription script that will run x y z commands). Lots of scripting possibilities here regardless of platform.

If the user were to use this script to handle only pasting, they could set the paste method to none + add their script that will run after transcription with their own custom pasting method.

Maybe this could be hidden inside "experimental features" instead? Just a thought!

@piec
Copy link
Contributor Author

piec commented Jan 22, 2026

Hi @gabenasci, maybe we need 2 things:

  • This PR: an "external script" paste method which can let users insert text with a custom tool. The intended usage is to insert text not to process text.
  • Another PR: an "external script" for post-processing, handy runs it, captures the command output and carries on with other post processing and pasting.

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

Successfully merging this pull request may close these issues.

3 participants