This subreddit is for any question pertaining to Linux from beginner to advanced. For general Linux news and info, see /r/linux.

If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!

One of the things I miss the most from Windows is a very small program called Srpskey. This software allows the speakers of Serbian language (and the likes of it) to seamlessly type the letters šćčđž.

The way it normally works on Windows (and Linux for that matter) is that you have to add a Serbian keyboard layout and these letters replace the brackets, semicolon, and apostrophe letters on the keyboard. That's all nice and good, but since I use both English and Serbian constantly, I find the need to switch keyboard layouts (even with shortcuts) tiresome.

Now, the way Srpskey does it is that it automatically replaces sx with š, cx with č, cq with ć and zx with ž. Since there are no words in Serbian that start with any of those two letters, and barely any in English, this works out beautifully. Replacing is fast and seamless, so I don't even pay attention to it.

So does anyone know how would I write a small script-like program that automatically replaces e.g. zx with ž as I type?

The standard way to type things like that without changing your keyboard layout would be the Compose Key I guess; it wouldn't be the same sequences you're used to with that windows program, so not sure how nice you'd find it, but it's something that should work with little fuss.

The compose key codes are Compose+c+[c,s,z] → [č,š,ž] and Compose+c+' → ć. I currently have my caps lock key set to compose and have many nifty custom things like Compose+l+o+d → ಠ_ಠ or Compose+-+> gives →. The settings for which key is composed shouldn't be far from the international keyboard switching. However, this introduces an extra keystroke, from two to three.

When I forget a combo or need to find a new one, I have two aliases set in bash to make it really quick, although you have to type in all caps if you want to find something like ALPHA to get the code for α.
alias xcompose-list='cat ~/.XCompose | grep '
alias xcompose-list-default'cat /usr/share/X11/locale/en_US.UTF-8/Compose |