sS addAssociationToMimeAppsList(S key, S value) { File f = userDir(".local/share/applications/mimeapps.list"); if (!fileExists(f)) ret f2s(f) + " not found"; LS l = lines(loadTextFile(f)); int i = indexOfTrim(l, "[Default Applications]"); if (i < 0) ret "[Default Applications] not found in " + f2s(f); int j = indexOfStartingWith(l, key + "="); if (j >= 0) ret "Association already there: " + l.get(j); S line = key + "=" + value; l.add(i+1, line); saveTextFile(f, lines(l)); ret "Added " + quote(line) + " to " + f2s(f); }