[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

fix: don't type character "0" to check if wtype works #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gilbsgilbs
Copy link
Contributor
@gilbsgilbs gilbsgilbs commented Jun 8, 2022

87e5582 (#9) added a fallback to
wl-clipboard when wtype isn't supported in the current environment. To
do so, they invoked "wtype 0" to check whether wtype works.
Unfortunately, this leads to inconsistent and buggy behaviors: sometimes
the character "0" gets typed, and sometimes the current window loses
focus (at least on my config).

As there doesn't seem to be a way to know in advance if wtype will work
without invoking it, this commit workarounds this issue by adopting the
"EAFP" principle, trying to use wtype with the emoji directly, and only
if it didn't work, invoke wl-copy.

@gilbsgilbs
Copy link
Contributor Author

Reading #8 and #9 more carefully, I don't think this PR should be merged as is. They do wtype 0 because wtype is actually installed but fails to type anything. Not sure what to do here, this is rather annoying.

FYI @PotHix .

@gilbsgilbs gilbsgilbs marked this pull request as draft June 9, 2022 23:22
@gilbsgilbs
Copy link
Contributor Author
gilbsgilbs commented Jun 9, 2022

Maybe we could do wtype "", but I fear it doesn't fix random unfocus issue.

Another solution could be to let the user override the command explicitly (e.g. wofi-emoji --mode copy or WOFI_EMOJI_MODE=copy wofi-emoji). Not only this would provide an easy and elegant workaround for #8, but it would also allow wtype users to choose between "type" and "copy" depending on their preference.

@PotHix
Copy link
Contributor
PotHix commented Jun 10, 2022

@gilbsgilbs I can't even test it because wtype doesn't work for me at all. 😕

e.g. wofi-emoji --mode copy

That would work well for me 👍

@gilbsgilbs gilbsgilbs force-pushed the fix-wtype-0 branch 2 times, most recently from 01c206b to a820a75 Compare June 11, 2022 11:23
@gilbsgilbs gilbsgilbs marked this pull request as ready for review June 11, 2022 11:23
@gilbsgilbs
Copy link
Contributor Author
gilbsgilbs commented Jun 11, 2022

I had another idea that should be feature-even with #9 and just fix my issue with "wtype 0". Rather than testing if wtype works in an preliminary step, I just try to wtype the emoji directly and if it doesn't work fallback to wl-copy. If I understood the problem correctly, this should also work for you @PotHix .

AFAIAC, wofi-emoji shouldn't bother copying or typing the emoji at all and should just print it to standard output (letting the user pick the tool they want to consume it with). This would better embrace the unix philosophy and be easier to maintain. Otherwise, providing a "mode" as I suggested previously could still turn out handy: even users for whom wtype works fine might not want wofi-emoji to wtype it.

@gilbsgilbs gilbsgilbs changed the title fix "wtype 0" typing the character "0" fix: don't type character "0" to check if wtype works Jun 11, 2022
87e5582 (dln#9) added a fallback to
wl-clipboard when wtype isn't supported in the current environment. To
do so, they invoked "wtype 0" to check whether wtype works.
Unfortunately, this leads to inconsistent and buggy behaviors: sometimes
the character "0" gets typed, and sometimes the current window loses
focus (at least on my config).

As there doesn't seem to be a way to know in advance if wtype will work
without invoking it, this commit workarounds this issue by adopting the
"EAFP" principle, trying to use wtype with the emoji directly, and only
if it didn't work, invoke wl-copy.
@PotHix
Copy link
Contributor
PotHix commented Jun 13, 2022

That's a great idea, @gilbsgilbs! Just tried it and it works for me too. Let's wait for @dln to merge this in. :)

@paulodiovani
Copy link

I would rather have an explicit way to decide between type or copy, but for now this change is very much welcome.

@paulodiovani
Copy link

Copy is working for me, but not typing.

Zeioth referenced this pull request in Zeioth/wofi-emoji Dec 14, 2022
Seems the original creator doesn't have time, so i'm gonna do it myself.
Fixes bug when copy pasting emojis.
gilbsgilbs referenced this pull request in Zeioth/wofi-emoji Apr 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants