summarylogtreecommitdiffstats
path: root/apply-xdg-patch.sh
blob: a401b66198e6fac3b344beb34a9cf466ad71a72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

add_mime_type() {
  if ! grep -q -E "^MimeType=.*\b${1};" "$2"; then
    sed -i -E "s#^(MimeType=.*;)\$#\1${1};#" "$2"
  fi
}

# see https://github.com/microsoft/vscode/issues/15741
fix_15741() {
  add_mime_type 'inode/directory' "$1"
}

# see https://github.com/microsoft/vscode/issues/214741
fix_214741() {
  add_mime_type 'text/plain' "$1"
}

while read -r file; do
  case "${file}" in
    *.desktop)
      fix_214741 "${file}"
      fix_15741 "${file}"
      echo "patched ${file}"
      ;;
    *)
      echo "unexpected file: ${file}"
      ;;
  esac
done