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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/jgmenu{,_run}
profile jgmenu @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/gtk>
  include <abstractions/fonts>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/freedesktop.org>
  include <abstractions/nameservice-strict>
  include <abstractions/app-launcher-user>

  @{exec_path} mrix,

  @{sh_path}        rix,
  @{bin}/zsh        rix,
  @{bin}/mkdir      rix,
  @{bin}/find       rix,
  @{bin}/wc         rix,
  @{bin}/cat        rix,

  @{lib}/jgmenu/jgmenu-*    rix,

  owner @{HOME}/ r,
  owner @{HOME}/.jgmenu-lockfile rwk,

  owner @{user_config_dirs}/tint2/* r,

  owner @{user_config_dirs}/jgmenu/ rw,
  owner @{user_config_dirs}/jgmenu/** rw,

  owner @{user_cache_dirs}/ rw,
  owner @{user_cache_dirs}/jgmenu/ rw,
  owner @{user_cache_dirs}/jgmenu/** rw,

  owner @{HOME}/.Xauthority r,

  owner @{PROC}/@{pid}/loginuid r,

  # For zsh shell
  /etc/zsh/zshenv r,

  # For missing apps icon and desktop files
  /usr/share/**.png r,
  /usr/share/**.desktop r,

  # file_inherit
  owner /dev/tty@{int} rw,

  include if exists <local/jgmenu>
}
