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

Feature request: option to auto paste emoji after choosing it #11

Open
AXeL-dev opened this issue Sep 4, 2020 · 23 comments
Open

Feature request: option to auto paste emoji after choosing it #11

AXeL-dev opened this issue Sep 4, 2020 · 23 comments

Comments

@AXeL-dev
Copy link

AXeL-dev commented Sep 4, 2020

I would love to see an auto paste feature, like in many others emoji selectors.

@MyriaCore Could you help on implementing this feature on your fork please? I'm not sure if it's doable, what do you think?

@MyriaCore
Copy link
Contributor

I was thinking about this too. In the past, I've used xdotool for things like this. Maybe it'd be possible to use a shell subprocess and call it?

I could provide assistance, but I'm trying to pull back from open source and personal projects because of university, which gobbles up like 110% of my free time lol

@MyriaCore
Copy link
Contributor

Could also be possible to copy and then insert by putting the copy action and the insert action in an Action List.

Regardless, it's probably doable.

@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 4, 2020

I was thinking about this too. In the past, I've used xdotool for things like this. Maybe it'd be possible to use a shell subprocess and call it?

In fact i'm using a Clipboard Manager called Clipped which already has this feature. & from sources i think that it use fake events same as xdotool.

@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 4, 2020

I figured out that the XTest library used in Clipped is available on python too:

So we could maybe use it instead of calling xdotool using a subprocess?

@MyriaCore
Copy link
Contributor

Sure, if u think it'll be faster. xdotool was just the one I thought of, plus it does character encoding for typing simulations I think, so it's not JUST sending shift-insert.

Regardless, I think it'll just be cool that it's working lol. Lmk how it works out! I'll be here if u need help with the implementation

AXeL-dev added a commit to LinuxForGeeks/ulauncher-emoji that referenced this issue Sep 5, 2020
@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 5, 2020

@MyriaCore I think that creating a custom action didn't work since i'm getting the following error message:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/utils/SimpleWebSocketServer.py", line 574, in _parseMessage
    self._handlePacket()
  File "/usr/lib/python3/dist-packages/ulauncher/utils/SimpleWebSocketServer.py", line 245, in _handlePacket
    self.handleMessage()
  File "/usr/lib/python3/dist-packages/ulauncher/api/server/ExtensionController.py", line 70, in handleMessage
    response = pickle.loads(self.data)
AttributeError: Can't get attribute 'PasteAction' on <module '__main__' from '/usr/bin/ulauncher'>

Edit: I tested the key press simulation code in a separated python script & it did work so i don't think that the problem comes from there.

So, what do you suggest? have i done something wrong?

AXeL-dev added a commit to LinuxForGeeks/ulauncher-emoji that referenced this issue Sep 5, 2020
@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 5, 2020

Finally got it to work, based on code from ulauncher-kill extension.

@MyriaCore thanks for the help 😉

@MyriaCore
Copy link
Contributor

Sweet! Yeah, the custom actions seem kinda fiddly. Glad you figured it out!

@MyriaCore
Copy link
Contributor

There are still some users who might want to just copy the emoji, so it might be wise to add an action setting in the settings. Maybe the user could choose from "Auto-Insert" or "Copy".

AXeL-dev added a commit to LinuxForGeeks/ulauncher-emoji that referenced this issue Sep 5, 2020
@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 7, 2020

Just checked out your code. I think instead of sending Ctrl-V, u should send Shift-Insert, since some applications won't accept Ctrl-V (like terminals).

Didn't look too hard at it, but other than that, it looks good.

@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 22, 2020

any updates @AXeL-dev?

@AXeL-dev
Copy link
Author

any updates @AXeL-dev?

Well i didn't rework on this since the last time. I'll try to this night.

AXeL-dev added a commit to LinuxForGeeks/ulauncher-emoji that referenced this issue Sep 22, 2020
@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 23, 2020

@MyriaCore it seems like pasting emojis using Shift-Insert doesn't work on my terminal app (Tilix), it pastes only the last copied textual value, but it works weirdly using paste option of the mouse right click menu.

image

P.S.: pasting emojis doesn't either work with Ctrl-V as you said before.

@MyriaCore
Copy link
Contributor

Maybe instead of copying into the clipboard, we should copy into the primary buffer? I think Shift-Insert might be for the primary buffer, although I'm not sure. Middle click also pastes the primary buffer.

@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 25, 2020

The CopyToClipboardAction is defined here.

After looking at relevant docs, it looks like maybe we could use the following to make Shift-Insert work:

class CopyToPrimarySelectionAction(CopyToClipboardAction):
    """
    Copy text to the clipboard
    :param str text: text to copy
    """
    def run(self):
        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
        clipboard.set_text(self.text, -1)
        clipboard.store()

@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 25, 2020

@AXeL-dev you can test this on your terminal by:

  1. selecting something in your terminal
  2. immediately Shift-insert
  3. See the thing you selected in your terminal

If we use the primary selection instead of the clipboard, shift-insert should basically work everywhere, since AFAIK it's accepted everywhere, since it's more of a system thing than a user-controllable clipboard thing.

@MyriaCore
Copy link
Contributor

I've implemented this in MyriaCore/auto-paste.

@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 25, 2020

HMMM, still not working. This is super weird. I get a completely different bug when trying to do both as well, so im not sure what to do here. Needless to say, for this to be useful for regular use, this will probably need to be debugged.

MyriaCore added a commit to MyriaCore/ulauncher-emoji that referenced this issue Sep 25, 2020
MyriaCore added a commit to MyriaCore/ulauncher-emoji that referenced this issue Sep 25, 2020
MyriaCore added a commit to MyriaCore/ulauncher-emoji that referenced this issue Sep 25, 2020
MyriaCore added a commit to MyriaCore/ulauncher-emoji that referenced this issue Sep 25, 2020
@MyriaCore
Copy link
Contributor

Maybe the primary clipboard is read only? How does xsel do it then, cause im pretty sure xsel can copy into the primary clipboard. I mean, the easy way out here could totally be just to subprocess out into xsel.

This is honestly pretty frustrating. Maybe it would've been better if we had just piped out at the beginning.

@AXeL-dev
Copy link
Author

AXeL-dev commented Sep 25, 2020

I guess there should be a way to achieve it, the most common problem in Linux (i mean the one i always face) is the lake of good documentation, especially on some low level libraries.. Anyway, i'll try to give it a look from my side once i get enough free time for.

By the way, xsel is open source? this one: https://github.com/kfish/xsel ?

@MyriaCore
Copy link
Contributor

MyriaCore commented Sep 27, 2020

Yeah. IDK, documentation is there, I guess I just don't know as much as I thought about the clipboard system.

Most of my experience comes from working on a fork of texpander. Here, Shift-Insert is used to paste, and the text content is placed into the primary buffer and into the clipboard buffer.

As I said, worst case we can use xsel to copy, and then use this XTest library to paste. IDK why the gtk clipboard stuff isn't working, but AFAIK that stuff is supposed to be used for implementing copy/paste in GUI apps, so I guess we'd be kinda abusing the feature a bit here.

@gerardbosch
Copy link

gerardbosch commented Mar 29, 2022

Hi there!

I'd love this feature is implemented ❤ Is there any update?

I give my two cents here on what I think is a common use case:
If I get it right from the discussion I understood that the choice is on which clipboard to copy the emoji; or if directly insert it without copying to a clipboard.

IMO, and for my use case, to be really useful it should do both: copy to the X clipboard (the one that pastes with Ctrl-v) + insert the emoji right after.

Reason: Many times you want to insert several times the same emoji, like 👏👏👏 - so you should be able to look for the emoji in the picker once, hit return to insert, and in the event you want to insert more press ctrl-vvv....

shift - insert is not very ergonomic, specially on laptop keyboards as involves more keys like fn that are far from home and wrist twisting 😬

What do you think? Hope this helps, cheers!!

@MyriaCore
Copy link
Contributor

MyriaCore commented Mar 31, 2022

I haven't worked on this since 2020 so no updates unfortunately. I don't remember if I got this to work or not in my fork. Commits look ok but I never merged it, so I have to assume it's at least somewhat not working

Again uni takes up a lot of my time so in general I've taken a step back from open source stuff. If you have experience with python why not take a stab at it yourself?

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

3 participants