# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021 Mikhail Morfikov
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/mediainfo-gui
profile mediainfo-gui @{exec_path} {
  include <abstractions/base>
  include <abstractions/dconf-write>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/fonts>
  include <abstractions/freedesktop.org>
  include <abstractions/gtk>
  include <abstractions/user-download-strict>

  @{exec_path} mr,

  @{bin}/xdg-open    rCx -> open,

  owner @{user_music_dirs}/** r,
  owner @{user_videos_dirs}/** r,

  profile open {
    include <abstractions/base>
    include <abstractions/xdg-open>

    @{bin}/xdg-open mr,

    @{sh_path}             rix,
    @{bin}/{m,g,}awk       rix,
    @{bin}/readlink        rix,
    @{bin}/basename        rix,

    @{lib}/firefox/firefox rPx,

    owner @{HOME}/ r,
    owner @{run}/user/@{uid}/ r,

    # file_inherit
    owner @{HOME}/.xsession-errors w,

  }

  include if exists <local/mediainfo-gui>
}
