I was sad I got no help but I can understand gedit is a bit frustrating on this topic. I tried several things...with no luck, thus increasing my frustration. However, today I realised that even if when running gedit like in:
gedit test.sh &
and I did not get any errors, when saving files or opening new files from the GUI I did get some:
(gedit:46958): GLib-GIO-CRITICAL **: XX:YY:ZZ.382: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
(gedit:46958): dconf-WARNING **: XX:YY:ZZ.403: failed to commit changes to dconf: No s'ha pogut executar el procés fill «dbus-launch» (El fitxer o directori no existeix)
(gedit:46958): dconf-WARNING **: XX:YY:ZZ.572: failed to commit changes to dconf: No s'ha pogut executar el procés fill «dbus-launch» (El fitxer o directori no existeix)
(gedit:46958): dconf-WARNING **: XX:YY:ZZ.461: failed to commit changes to dconf: No s'ha pogut executar el procés fill «dbus-launch» (El fitxer o directori no existeix)
(gedit:46958): dconf-WARNING **: XX:YY:ZZ.462: failed to commit changes to dconf: No s'ha pogut executar el procés fill «dbus-launch» (El fitxer o directori no existeix)
(gedit:46958): dconf-WARNING **: XX:YY:ZZ.462: failed to commit changes to dconf: No s'ha pogut executar el procés fill «dbus-launch» (El fitxer o directori no existeix)
I could save or open files as I needed but I wondered if these messages had any connection with the problem posted above and it did. Searching on how to get rid off the messages above:
sudo apt install dbus-x11
seems to have solved the problem and I do not get those annoying messages anymore. Two birds with on stone! Problem solved!