# 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} = @{lib}/kf6/kameleon-qmk-helper
@{att} = ""
profile kameleon-qmk-helper /{,usr/}lib{,exec,32,64}/kf6/kameleon-qmk-helper {
  include <abstractions/base-strict>
  include <abstractions/bus-system>
  include <abstractions/devices-usb-read>

  #aa/dbus own bus=system name==org.kde.kameleon.qmk.helper
  include <abstractions/bus/system/own>
  dbus bind bus=system name={,.*},
  dbus receive bus=system path=/{,/**}
       interface={,.*}
       peer=(name="@{busname}"),
  dbus send bus=system path=/{,/**}
       interface={,.*}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  # DBus.Properties: reply to properties request from anyone
  dbus (send receive) bus=system path=/{,/**}
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  # DBus.Introspectable: allow clients to introspect the service
  dbus receive bus=system path=/{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="@{busname}"),
  # DBus.ObjectManager: allow clients to enumerate sources
  dbus receive bus=system path=/{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},{,.*}}"),
  dbus send bus=system path=/{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.freedesktop.DBus}"),


  @{exec_path} mr,

  include if exists <local/kameleon-qmk-helper>
}

# vim:syntax=apparmor
