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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/gnome-tweaks
profile gnome-tweaks @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/common/gnome>
  include <abstractions/python>
  include <abstractions/thumbnails-cache-read>

  network netlink raw,

  @{exec_path} mr,

  @{bin}/ r,
  @{bin}/env r,
  @{bin}/ps rPx,
  @{bin}/python3.@{int} rix,

  @{open_path}  rPx -> child-open-help,

  @{lib}/python3.@{int}/site-packages/gtweak/{,*/,**/}__pycache__/*pyc* w,

  /etc/xdg/autostart/{,**} r,

  owner @{HOME}/@{XDG_WALLPAPERS_DIR}/{,**} r,

  owner @{user_config_dirs}/autostart/ rw,
  owner @{user_config_dirs}/autostart/*.desktop r,
  owner @{user_config_dirs}/gtk-{3,4}.0/settings.ini* rw,
  owner @{user_share_dirs}/backgrounds/{,**} r,
  owner @{user_share_dirs}/gnome-shell/extensions/**/schemas/* r,
  owner @{user_share_dirs}/recently-used.xbel* rw,

  @{run}/udev/data/+input:input@{int} r,  # for mouse, keyboard, touchpad
  @{run}/udev/data/c13:@{int}  r,         # for /dev/input/*

  @{sys}/bus/ r,
  @{sys}/class/input/ r,
  @{sys}/devices/**/uevent r,

  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/mounts r,

  deny owner @{user_share_dirs}/gvfs-metadata/{,*} r,

  include if exists <local/gnome-tweaks>
}

# vim:syntax=apparmor
