Skip to content

Drarig29/auto-paste-emoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

auto-paste-emoji

A script which automatically pastes an emoji if you just selected it from KDE Plasma's emoji picker.

You can tweak it to meet your needs.

Dependencies:

Usage

Download this script or clone the repository.

Then, symlink it somewhere like /usr/bin/auto-paste-emoji:

ln -s ~/path/to/auto-paste-emoji.sh /usr/bin/auto-paste-emoji

To run this script at startup, you need to put it somewhere which is loaded after X server starts, so forget systemd. Otherwise you'll get a Unable to connect to X server error.

You can use files like .xinitrc, .xsession or .xprofile. Keep in mind that by default, .xinitrc is only loaded when we use the startx command. So this file won't be loaded if you use a desktop environment.

Warning: this file contains an infinite loop, so you need to run the command in the background with &, otherwise your desktop environment is likely to freeze when you log in.

I personally used ~/.xprofile, here is its content:

#!/bin/bash
exec /usr/bin/auto-paste-emoji &

How it works?

  • It uses clipnotify, so no polling is involved
  • Any existing instance of the script is killed
  • All errors are ignored so that the program doesn't stop unexpectedly
  • When the selection changes, it checks if the emoji picker is open and a single emoji is in the clipboard
  • If it's the case, we assume the emoji was just selected: so the picker is closed and the emoji is pasted
  • A small delay is added between closing the picker and pasting the emoji to let the emoji picker's window disappear and let the focus change
  • To close the window we don't use xdotool windowclose but we simulate pressing EscEsc instead
    • For some reason, closing the window kills the whole process and the shortcut to open the picker won't respond afterwards
    • We simulate pressing Esc twice because if you used the search feature in the picker, pressing Esc will clear the search string, so we need a second key stroke

You can view the logs using journalctl:

journalctl -b | grep -E "\[$(pidof -x /usr/bin/auto-paste-emoji)\]"

About

A script which automatically pastes an emoji if you just selected it from KDE Plasma's emoji picker

Topics

Resources

Stars

Watchers

Forks

Languages