mijorus / smile

An emoji picker for linux, with custom tags support and localization. I'll also put some random emojis here πŸ¦πŸΎπŸ¦”πŸ¦‡
https://mijorus.it/projects/smile
GNU General Public License v3.0
237 stars 13 forks source link

[Feature] Add option to print emoji directly without copy-paste #12

Closed daudix closed 1 year ago

mijorus commented 2 years ago

this feature is not coming any time soon, unfortunately. Here is why:

  1. there is no way on wayland (afaik) to paste something in an input field, it's a limitation of the protocol, and wayland is becoming the default for the most popular distros except maybe ElementaryOS
  2. on X11, I've seen people doing hacks with xdotool, which is possible but, in my experience, very unreliable and potentially dangerous, as you are emulating a keyboard shortcut.

Until I find a "clean" way to do it, auto-paste will not be available

mijorus commented 2 years ago

But I am open to suggestions

different55 commented 2 years ago

I think the cool thing to do is to dive a layer even lower and go over Wayland's head with a virtual input device? I think it'd be done at the uinput level. Quick look through input.h and some other things, I don't see any way to push through arbitrary text so would still be emulating a keyboard shortcut.

Another way, though, might be ibus? Either by emulating its shortcut with uinput and dialing in a codepoint, or maybe there's a way to communicate to it to ask it what you want directly, it seems to hang out on dbus.

daudix commented 2 years ago

@different55 It would be amazing !!!

mijorus commented 2 years ago

I think the cool thing to do is to dive a layer even lower and go over Wayland's head with a virtual input device? I think it'd be done at the uinput level. Quick look through input.h and some other things, I don't see any way to push through arbitrary text so would still be emulating a keyboard shortcut.

Another way, though, might be ibus? Either by emulating its shortcut with uinput and dialing in a codepoint, or maybe there's a way to communicate to it to ask it what you want directly, it seems to hang out on dbus.

I have absolutely no idea what you are talking about πŸ˜…, feel free to open a PR if you have some POC implementation

AFAIK the only possible way to do it is the ibus-typing-booster's way, which shows up as an ibus input method

different55 commented 2 years ago

lol unfortunately that just probably means I have no idea what I'm talking about, but I'll see if I can coerce anything into working.

mijorus commented 2 years ago

@different55 do you have any experience with ibus input methods?

different55 commented 2 years ago

None at all from a development perspective, some (very) limited experience from the user's PoV

mijorus commented 2 years ago

@different55 I'm analyzing that project.

It looks very interesting and probably the only way to pull it off. Unfortunately, at the moment ibus-typing-booster is barely usable for me: it is trying to do too much, resulting in a base user experience IMO.

different55 commented 2 years ago

Ah that's a shame, but you figure if ibus-typing-booster can get with ibus to get emojis inserted, smile oughta be able to sweet talk ibus the same way itself.

Just a quick glance at the DBus API it exposes pointed me in this direction which seems very promising:

https://valadoc.org/ibus-1.0/IBus.InputContext.html which led to https://ibus.github.io/docs/ibus-1.5/IBusEngine.html

But can check that out more later.

daudix commented 2 years ago

Is there any dev can do this?

different55 commented 2 years ago

there is, but they're not typically summoned and coerced so easily

mijorus commented 2 years ago

this kind of stuff, which is completely undocumented, requires a deeper knowledge of the platform, which I don't have ATM (or lot of free time, which is lacking as well)

different55 commented 2 years ago

On second glance, process_key_event() might be everything we need already. I'm still flying blind on the inner workings of IBus but I do know the Ctrl+Shift+U keyboard shortcut for unicode input is handled by IBus, so assuming it's possible to yell at whatever engine is handling that behind the scenes through process_key_event() then that oughta be fairly reliable. It'd still technically be a keyboard shortcut, but a highly targeted one.

Only concerns that come to mind w/ this is whether or not the user has configured the shortcut to something else, and how many of the massive assumptions and guesses I'm making might be about to collapse.

mijorus commented 2 years ago

Both Ctrl+Shift+U and Ctrl+Shift+E enable some sort of "special characters" mode which allows you to enter emojis and other stuff.

There are both TERRIBLE imo, and should be removed (or at least, give me an option to turn them off).

Why? Because if you hit them accidentally your keyboard stops typing! Seriously, who thought that was a good idea? One day I activated Ctrl+Shift+E without realizing it and I couldn't understand what was going on. I ended up closing the program I was using because I thought it had crashed or something.

different55 commented 2 years ago

I mean valid complaints lol. They can be turned off, check out the IBus Preferences app, although GNOME has it hidden so check out ibus-setup. Under the Emoji tab you can reassign or unassign those keyboard shortcuts. But hitting Esc at most a few times or Enter once also dispels them if they're called by accident. I personally have the hotkey set to include Super because Ctrl-y and Shift-y hotkeys are really dominated by applications anyway.

Hopefully though it's possible to ignore all that and somehow call up that functionality directly. I think I'm starting to wrap my head around things finally but still not sure what the best/any way is to actually go about this. Current thoughts: Custom IBus engine, switch to it when dumping an emoji out, switch back after?

mijorus commented 2 years ago

OMG thanks

mijorus commented 1 year ago

There is nothing I can do about this feature. Any possible solution goes far beyond my skills RN.