Libraryless. Click here for Pure Java version (2724L/18K).
1 | sS addAssociationToMimeAppsList(S key, S value) {
|
2 | File f = userDir(".local/share/applications/mimeapps.list");
|
3 | if (!fileExists(f)) ret f2s(f) + " not found"; |
4 | LS l = lines(loadTextFile(f)); |
5 | int i = indexOfTrim(l, "[Default Applications]"); |
6 | if (i < 0) ret "[Default Applications] not found in " + f2s(f); |
7 | |
8 | int j = indexOfStartingWith(l, key + "="); |
9 | if (j >= 0) ret "Association already there: " + l.get(j); |
10 | |
11 | S line = key + "=" + value; |
12 | l.add(i+1, line); |
13 | saveTextFile(f, lines(l)); |
14 | ret "Added " + quote(line) + " to " + f2s(f); |
15 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1026393 |
| Snippet name: | addAssociationToMimeAppsList |
| Eternal ID of this version: | #1026393/5 |
| Text MD5: | 528d92c787a6b5485d19aef6a9413362 |
| Transpilation MD5: | 521124f885387d3077f0f9041e4aa8c3 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-02 13:28:06 |
| Source code size: | 566 bytes / 15 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 426 / 574 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |