summarylogtreecommitdiffstats
path: root/signal-desktop-fix-sway-unpatch.sh
blob: 0768f7c2b81cd2568edfcbef4752224b5357f201 (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
#!/bin/bash

set -u

PATCHDIR=/usr/share/signal-desktop-fix-sway/reverse-patches
ASAR=/usr/lib/signal-desktop/resources/app.asar

if [[ ! -e "${PATCHDIR}" ]]; then
  printf >&2 'Not modifying %s because %s is not installed.' \
    "${ASAR}" "${PATCHDIR}"
  exit 0
fi

if [[ ! -e "${ASAR}" ]]; then
  printf >&2 'Not modifying %s because it is not installed.' "${ASAR}"
  exit 0
fi

# Patch the ASAR file
if ! patch-asar "${ASAR}" "${PATCHDIR}" "${ASAR}.undone"; then
  echo >&2 '[ERROR] Patch reversal failed, skipping.'
  rm -f "${ASAR}.undone"
  exit 1
fi

exec mv -f "${ASAR}.undone" "${ASAR}"