Array in dbus/gsettings has a format [element1, element2, element3, ...]
.
Gsettings
' interface allows only replacing existing array with another, so for instance, adding another item element can be achieved as follows:
#!/bin/bash
gsettings get ${schema} ${key} | grep -q \"${value}\" >/dev/null
if [ $? -ne 0 ]; then
gsettings set ${schema} ${key} \"`gsettings get ${schema} ${key} | sed s/.$//`, ${value}]\"
fi
Can anyone help me with a script, that checks whether at least one element exists that matches the regex, and if it does, it parses the gsettingsarray string, and removes all matching elements (and puts it back with
gsettings set`, but that is trivial).
I tried to find such tool, but I failed to find one. I cannot believe, that nobody yet had a need for such tool...
The question complements How to add element to the gsettings array at the specific location (given by index)?