13

The keyboard layout indicator in GNOME, which appears in the panel after adding more than one layouts, shows preassigned abbreviations for layouts. Is there a way to rename this abbreviations? For example I want to change en to Eng here:

enter image description here

If I'm not mistaken it can be done pretty easily in KDE.

Distro: Ubuntu GNOME 17.04

pomsky
  • 68,507

1 Answers1

11

This method only works with Xorg*

(* Update from the original asker: It seems the changes made in an Xorg session persist after rebooting to a Wayland session.)


Introduction

Basically, GNOME-Shell seem to be obtaining the abbreviations of the keyboard layouts from a configuration file ( /usr/share/X11/xkb/rules/evdev.xml). So to change them, we first need to open the configuration file in a text editor and then change them to whatever we want!

There are two different ways to do it. Though the graphical interface which includes the mouse or the command line interface which is only the keyboard.


Common first step

First open a terminal.

There is many way to do this. This method is the simplistic. Press Alt + F2 on your keyboard. You will see a dialog box come up and type in gnome-terminal or the name of your terminal. It should look like this now.

Dialog1

Now, press Enter. It should close and bring up an terminal.

Blank Terminal

Form here there are two ways: First the graphical way, or the Command interface.


Graphical Method

  1. Now type in

    sudo -i gedit /usr/share/X11/xkb/rules/evdev.xml
    

    This is how it should look.

    Terminal with filename1

  2. Now, press Enter and it should open the file in which we need to edit. This is how it should look:

    Gedit_1

  3. Now click on the bottom with the three dots. Highlighted in blue, then find and click on "Find and Replace..." Highlighted in lighter gray.

    enter image description here

    Now it should bring up an dialog

    Dialog_2

  4. Now we can edit this file to change "en" to "Eng". This will change all of the layouts that uses "en"

    Now, type into the text-box with "Find" to the left of it with this <shortDescription>en</shortDescription> Next, with the textbook below it and text to the left that says "Replace with", type this in it <shortDescription>Eng</shortDescription>. Now it should look like this.

    Dialog 2

    However, if you only want to change one layout then you will need to find it individually instead of changing all of them. I would just used the Find function to search for the name of it which needs to be spell exactly to find it.

  5. Now click on the button that says "Replace all" now that dialog box should disappeared with it saying it's found and replace 9 or so occurrences.

    Gedit_2

  6. Now save it by clicking on the save button highlighted in light gray.

    Gedit_4

    Now, notice that the asterisk in the title should go away like this. If it didn't then it didn't save.

    Gedit_1

  7. Restart your PC. Now it should look like this. Notice, that I did it with "eng" instead of "Eng"

    enter image description here


Command line interface

  1. Type in

    sudo sed -i -e 's/<shortDescription>en</shortDescription>/<shortDescription>Eng</shortDescription>/g' /usr/share/X11/xkb/rules/evdev.xml
    
  2. Press Enter on your keyboard.

  3. Type in your password.

  4. Press Enter on your keyboard.

  5. Restart your PC.

pomsky
  • 68,507
MathCubes
  • 5,666
  • 1
    First I made a change (en to Eng) by the graphical method described in the answer in an Xorg session, and it worked. Then I rebooted and started a GNOME on Wayland session and the change I made still applied there (it showed Eng instead of en)! – pomsky Sep 19 '17 at 14:05
  • 3
    It’s really hard to see what is actually going on with all these screenshots put in between the facts. The OP has 18k points here, it may just be possible he knows how to open a shell. – MPi Jun 22 '18 at 07:10
  • @MPi I made it for anyone. Anyone that uses Ubuntu with Gnome at the time. Even the newbies. If you don't like the graphical way then you can do it by the Command line way. I left two options for a reason. – MathCubes Jun 27 '18 at 03:46
  • @MPi Also when he asked the question and when I answer it. He only had 5 points. – MathCubes Jun 27 '18 at 03:48
  • @MPi Proof https://i.imgur.com/rr0c9tn.png – MathCubes Jun 27 '18 at 03:51
  • Incredible – how did the OP do that in such a short time?

    As to your answer: Even the command-line version contains the instructions to press the enter key. You got your upvote anyway.

    – MPi Jun 27 '18 at 11:11
  • @MPi Because it's still an step? – MathCubes Jun 28 '18 at 00:25
  • @MathCubes: I see you absolutely and continually fail to see my point. That’s OK. Different people have different needs. – MPi Jun 29 '18 at 07:25
  • @MPi To include a summary in the beginning of the post? I never thought about doing that before. If you want to edit my post to do that then go ahead. – MathCubes Jun 30 '18 at 00:20
  • @MPi When someone ask for a solution for a problem that involves some understand of the technical background of how its works. It's means it's beyond their skill set or to their understanding. Which is why I include step by step instructions with pictures because I don't want them to get confuse or mess something up.

    The asker was lucky because I been using Gnome-Shell for years and I had an idea on how it works. I knew it must be store in a conf file and I figure that Gnome was getting it from a global file and it's just accord to me that X dealt with these things. So I just look...

    – MathCubes Jun 30 '18 at 00:33
  • .. up the X conf files for the keyboard. It took me around 30 minutes, if I remember right. The only thing that I did not realized was it would work with Wayland as well. Its probably it's from Xwayland.. – MathCubes Jun 30 '18 at 00:33
  • @MPi Better now? – MathCubes Jun 30 '18 at 00:46