International keyboard settings
To make your keyboard have the accents working for Brazilian Portuguese on Debian-like operating systems in the proper way that Brazilians are used to, you need to add a second Keyboard Layout which uses the English (US, alternative international) language. But then an annoying hack is required to fix the cedilla, because the apostrophe+C yields a C with an accent instead of a Cedilla!
I had included some solutions for various Debian-based OS's here, but they were sub-optimal because they were always failing edge cases. But fortunately I recently found this cool fix-cedilla script by Marco Paganini that seems to work across most versions and flavours of Linux and in most programs whether they're shell, Gnome, Cinnamon, QT or whatever! Thanks Marco :-)
Note: This script stops dead keys from working in Telegram, but this can be fixed by commenting out the line that says QT_IM_MODULE=cedilla in the /etc/environment file.