Skip to content

Instantly share code, notes, and snippets.

@ericdouglas
Last active April 27, 2024 05:08
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ericdouglas/74469cb97188751f71bfdcd7d28f75fd to your computer and use it in GitHub Desktop.
Save ericdouglas/74469cb97188751f71bfdcd7d28f75fd to your computer and use it in GitHub Desktop.
Cedilla under C (ç) in 'US international' keyboard layout in Linux

Add English (US, alt. intl.)

It's because the cedilla module isn't loaded by default when the locale is set to en, so you have to change the configuration files for gtk to add them:

  1. Edit configuration files:
sudo vim /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache

sudo vim /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache

On both, find the lines starting with "cedilla" "Cedilla" and add :en to the line. Something like this:

"cedilla" "Cedilla" "gtk30" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"
  1. Change the Compose file:
sudo sed -i /usr/share/X11/locale/en_US.UTF-8/Compose -e 's/ć/ç/g' -e 's/Ć/Ç/g'
  1. Instruct the system to load the cedilla module:

Add those lines to /etc/environment:

GTK_IM_MODULE=cedilla
QT_IM_MODULE=cedilla

Reboot and you are done.

source

@thiagobasilio-nanga
Copy link

Nicely done! Thanks for that. Today I needed this tip that I used to know by heart but I totally forgot about it, and then I found your gist.

This is still relevant for users that need the cedilla working with us-international keyboards as they do behave in other operating systems (e.g. Windows).

THe only thing that was left behind is that you will need to have "gtk2-immodules" and "gtk3-immodules" packages installed.

@renie
Copy link

renie commented Oct 26, 2022

Amazing. Works like a charm!

@eudennis
Copy link

I'm having some issues GTK4 apps. Anyone had any similar problem?

@cfgnunes
Copy link

cfgnunes commented Jun 17, 2023

Thanks @ericdouglas!
@eudennis, I have some alternative solutions that work with GTK4. I've tested on Ubuntu 22.04:

Alternative solution 2 (system-wide)

  1. Set the file /etc/default/locale with the content:
LANG=en_US.UTF-8
LANGUAGE=
LC_ADDRESS=pt_BR.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_PAPER=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8

Note: it is important LANGUAGE= to be empty.

  1. Remove the file ~/.pam_environment from the user directory (if there is the file):
rm ~/.pam_environment
  1. Restart the system.

Alternative solution 3 (user space)

  1. Create a ~/.XCompose file with the following content:
 # UTF-8 (Unicode) compose sequences

 # Overrides C acute with Ccedilla:
 <dead_acute> <C> : "Ç" "Ccedilla"
 <dead_acute> <c> : "ç" "ccedilla"
  1. Run the following command:
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule': <'ibus'>}"
  1. Restart the user session.

Extra: the double quote key (use " directly instead of ¨)

  1. Run the following command:
sed -i "s|dead_acute,[ ]*dead_diaeresis,[ ]*apostrophe,[ ]*quotedbl|dead_acute, quotedbl|" /usr/share/X11/xkb/symbols/us
  1. Restart the system.

References:

Copy link

ghost commented Aug 14, 2023

Despite the problem persists on Text Editor of Debian 12, it's gone everywhere else.
I'm brazilian and the ç is a necessitie.
Thanks a lot.
Now I can continue my studies, first steps, in coding.

In time: I used only the first tutorial, till now. And for now, as I know too little yet about Linux and coding, it's OK!

@vinaooo
Copy link

vinaooo commented Nov 13, 2023

Thanks @ericdouglas! @eudennis, I have some alternative solutions that work with GTK4. I've tested on Ubuntu 22.04:

Alternative solution 2 (system-wide)

  1. Set the file /etc/default/locale with the content:
LANG=en_US.UTF-8
LANGUAGE=
LC_ADDRESS=pt_BR.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_PAPER=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8

Note: it is important LANGUAGE= to be empty.

  1. Remove the file ~/.pam_environment from the user directory (if there is the file):
rm ~/.pam_environment
  1. Restart the system.

Alternative solution 3 (user space)

  1. Create a ~/.XCompose file with the following content:
 # UTF-8 (Unicode) compose sequences

 # Overrides C acute with Ccedilla:
 <dead_acute> <C> : "Ç" "Ccedilla"
 <dead_acute> <c> : "ç" "ccedilla"
  1. Run the following command:
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule': <'ibus'>}"
  1. Restart the user session.

Extra: the double quote key (use " directly instead of ¨)

  1. Run the following command:
sed -i "s|dead_acute,[ ]*dead_diaeresis,[ ]*apostrophe,[ ]*quotedbl|dead_acute, quotedbl|" /usr/share/X11/xkb/symbols/us
  1. Restart the system.

References:

Thank you, I used your method in Ubuntu 23.10 and it worked like a charm

Do you know how can I do the same for ' and ´ like you did in " and ¨ ?

@hideki2k02
Copy link

hideki2k02 commented Dec 28, 2023

Do you know how can I do the same for ' and ´ like you did in " and ¨ ?

Actually yes, here an example for both the "Console Key" ` and the ' apostrophe key (Credits to Levi H):

keycode 48 = dead_acute quotedbl apostrophe quotedbl apostrophe quotedbl (' á ")
keycode 49 = grave dead_tilde grave notsign brokenbar notsign brokenbar notsign (` or ~ or ã)

Just make a file in ~/.Xmodmap and add those in, if you want to test the changes beforehand just use xmodmap -e "keycode stuff"

Here is some more info if you want to tweak it yourself/understand what is going on

This was tweaked for my liking, that way i can use "double brackets" for programming without any hassle whilst maintaining the ability to write á é í ó ú when needed
` for games that require Console Access whilst maintaining the ability to use ã ẽ ĩ õ ũ to write words like não

@LucasMonteiroi
Copy link

Worked here, thanks buddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment