Are you running the script as the same user and within the same DBus session (i.e. using the same DBUS_* environment variables as the GNOME session you want to change this for)?
When I removed everything from ~/.bashrc, following commands when executed from terminal do nothing
$ gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
$ gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
Also is it because of the following
$ ls -a -l ~/.config/dconf
lrwxrwxrwx. 1 lamy lamy 23 May 13 2023 /home/lamy/.config/dconf -> /mnt/Data/.config/dconf
Creating Alias works
Gsetting="org.gnome.Terminal.ProfilesList"
TerminalDarkProfile="b1dcc9dd-5262-4d8d-a863-c897e6d979b9" # Theme is stored in dconf; get existing profiles by: `dconf dump /org/gnome/terminal/legacy/profiles:/`
TerminalLightProfile="3dd28c15-6ba4-4ba0-8289-ab023e6c88fc" # Theme is stored in dconf; get existing profiles by: `dconf dump /org/gnome/terminal/legacy/profiles:/`
alias tl="gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' && gsettings set "${Gsetting}" default "${TerminalLightProfile}""
alias td="gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' && gsettings set "${Gsetting}" default "${TerminalDarkProfile}""
So why alias works but not function or separate bashscript?
Maybe if gsettings are handled asynchronously and a mounted resource extremly slow or broken, a result can depend on order of operations and so on. I’d try to test out that with double sync between set/get.
Could you please give the commands to execute for double sync? I am not sure what you mean as it doesn’t happen even after several minutes. I am using latest laptop with Gen 4 SSD and plenty of RAM (32 GB).
That was about /mnt/Data/.config… Is that resource on “latest laptop” or network resource somewhere? If that’s a remote resource, try to reproduce it with data on your local computer.
If it’s not connected with asynchronous operations, then remained cause it’s different shell environment inside of script and outside. For example different XDG_CONFIG_HOME and/or DCONF_PROFILE. You can echo them inside and out of script to test it out. If not, I have no more suggestions what that is.
I ran the bash script and checked the audio daemon status and queried the Audit logs (here I show, the difference of log immediately after executing the bash script and immediately before executing the bash script from cwd: /mnt/Documents/Git/Project/Debug/Theme)
I am inexperienced but I don’t think there is a SELinux denial as per the logs. Am I correct?
$ bash ./Theme.sh
'prefer-light'
$ gsettings get org.gnome.desktop.interface color-scheme
'prefer-dark'