# 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
@{att} = /att/gnome-tweaks/
profile gnome-tweaks /{,usr/}bin/gnome-tweaks  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/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,
  @{python_path} rix,

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

  @{lib}/@{python_name}/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 rw,
  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,

  @{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
