abi <abi/4.0>,

#
# This profile is for the element-desktop/electron package in obs://network:im:signal
#

include <tunables/global>

@{BROWSER} = element
@{APPNAME} = @{BROWSER}
@{APPDIR} = /usr/share/@{APPNAME}
@{BINARY_NAME} = @{BROWSER}
@{BINARY_PATH} = @{APPDIR}/@{BINARY_NAME}
@{SOCKET_PATH} = .org.chromium.Chromium
@{CONFIG_SUBDIR} = Element
@{chromium_profile_name} = element-desktop

profile element-desktop-wrapper /usr/bin/element-desktop {
  include <abstractions/base>
  include <abstractions/bash>
  include <abstractions/consoles>

  /usr/bin/element-desktop r,
  /{usr/,}bin/bash rm,

  # can not clear env as we need that NODE_ENV variable
  /usr/bin/electron px -> element-desktop-electron,
}

profile element-desktop-electron {
  include <abstractions/electron-shell-wrapper>

  # TODO: if we get this to work we can move it to the abstraction
  #  /usr/lib{64,}/electron/electron px -> @{chromium_profile_name}
  /usr/lib{64,}/electron/electron px -> element-desktop,
}

profile element-desktop {
  include <abstractions/electron>

  /usr/lib{64,}/electron/electron px -> element-desktop,

  audit deny /usr/bin/xdg-open x,

  audit /{usr/,}bin/xdg-settings px -> chromium-xdg-settings,

  /usr/share/webapps/element/** r,
  /etc/element/config.json r,
  /etc/webapps/element/config.json r,

  include if exists <local/element-desktop>
}
