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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/lxqt-config-powermanagement
profile lxqt-config-powermanagement @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/lxqt>
  include <abstractions/nameservice-strict>

  @{exec_path} mr,

  /etc/machine-id r,

  owner @{user_config_dirs}/lxqt/#@{int} rw,
  owner @{user_config_dirs}/lxqt/lxqt-powermanagement.conf.lock rwk,
  owner @{user_config_dirs}/lxqt/lxqt-powermanagement.conf.@{rand6} rw,
  owner @{user_config_dirs}/lxqt/lxqt-powermanagement.conf.@{rand6} l -> @{user_config_dirs}/lxqt/#@{int},

  @{sys}/class/leds/ r,
  @{sys}/devices/@{pci}/backlight/**/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/backlight/**/{uevent,type,enabled} r,
  @{sys}/devices/@{pci}/backlight/**/brightness rw,
  @{sys}/devices/@{pci}/drm/card@{int}/**/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/drm/card@{int}/**/{uevent,type,enabled} r,
  @{sys}/devices/@{pci}/drm/card@{int}/**/brightness rw,
  @{sys}/devices/@{pci}/*_backlight/{,max_,actual_}brightness rw,
  @{sys}/devices/@{pci}/*_backlight/{uevent,type,enabled} r,

  owner /tmp/@{int} r,

  /dev/tty rw,

  include if exists <local/lxqt-config-powermanagement>
}

# vim:syntax=apparmor
