What you're describing is an accent Dead Key. These are in the Colemak layout, but not in good positions for Portuguese. As you say, AltGr is a sucky solution for languages with many accents as for instance the A key should ideally have all of the letters ÁáÀàÂâÃã on it and that won't fit!
In the BigBag, I've made locale solutions with accessible dead keys for many languages. Hope you like it! The Forum XKB topic has the best explanations for Linux so far.
Another method is to use the Compose key. You can set it in Ubuntu. Then you hit Compose and type for instance e' for é, or you can have the actual acute accent somewhere and auto-compose with that like a dead key.
( Θώθ) ~( See "DreymaR's Big Bag Of Keyboard Tricks" )
https://dreymar.colemak.org
Last edited by DreymaR (23-Sep-2021 10:02:07)