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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/plasma-keyboard
@{att} = /att/plasma-keyboard/
profile plasma-keyboard /{,usr/}bin/plasma-keyboard flags=(attach_disconnected,attach_disconnected.path=@{att},mediate_deleted) {
  include <abstractions/attached/base>
  include <abstractions/graphics>
  include <abstractions/kde-strict>

  signal receive set=term peer=kwin_wayland,

  @{exec_path} mr,

  @{bin}/ r,

  /usr/share/hunspell/* r,
  /usr/share/plasma/desktoptheme/** r,
  /usr/share/plasma/keyboard/{,**} r,

  owner @{sddm_cache_dirs}/fontconfig/* r,
  owner @{sddm_cache_dirs}/nvidia/ rw,
  owner @{sddm_cache_dirs}/nvidia/GLCache/ rw,
  owner @{sddm_cache_dirs}/nvidia/GLCache/** rwk,
  owner @{sddm_cache_dirs}/plasma-keyboard/ rw,
  owner @{sddm_cache_dirs}/plasma-keyboard/** rwlk,

  owner @{sddm_config_dirs}/fontconfig/fonts.conf r,
  owner @{sddm_config_dirs}/kcminputrc r,
  owner @{sddm_config_dirs}/kdedefaults/* r,
  owner @{sddm_config_dirs}/kdeglobals r,
  owner @{sddm_config_dirs}/plasmarc r,
  owner @{sddm_config_dirs}/qtvirtualkeyboard/ w,

  owner @{user_cache_dirs}/ksvg-elements rw,
  owner @{user_cache_dirs}/ksvg-elements.@{rand6} rw,
  owner @{user_cache_dirs}/ksvg-elements.lock rwk,
  owner link @{user_cache_dirs}/ksvg-elements.@{rand6} -> @{user_cache_dirs}/#@{int},
  owner @{user_cache_dirs}/plasma-keyboard/ rw,
  owner @{user_cache_dirs}/plasma-keyboard/** rwlk,
  owner link @{user_cache_dirs}/plasma-keyboard/qmlcache/@{hex}.qmlc.@{rand6} -> @{user_cache_dirs}/plasma-keyboard/qmlcache/#@{int},
  owner @{user_cache_dirs}/qtshadercache-@{arch}-little_endian-lp64/@{hex} r,
  owner @{user_cache_dirs}/*.kcache rw,

  owner @{user_config_dirs}/kdedefaults/plasmarc r,
  owner @{user_config_dirs}/plasmakeyboardrc r,
  owner @{user_config_dirs}/plasmarc r,

        @{PROC}/sys/kernel/random/boot_id r,
  owner @{PROC}/@{pid}/task/@{tid}/comm w,

  /dev/tty r,

  include if exists <local/plasma-keyboard>
}

# vim:syntax=apparmor
