# Maintainer: Daniel Langbein <daniel@systemli.org>
_pkgname=xfce4
_reponame=arch
pkgname="de-p1st-$_pkgname"
pkgver=0.1.4
pkgrel=1
pkgdesc="XFCE4 with configuration"
arch=('any')
url="https://codeberg.org/privacy1st/${_reponame}"
license=('MIT')
makedepends=('git')
makedepends+=('rsync')  # to merge two directories
backup=('etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml') # de-p1st-xfce4-hidpi changes this file through holo
install='.install'
source=("git+${url}.git" "git+https://codeberg.org/privacy1st/md-to-pdf.git")
sha256sums=('SKIP' 'SKIP')


depends=()

# ============== base, drivers and xorg ==============
depends+=('de-p1st-base')
depends+=('de-p1st-gpu')
depends+=('xorg-meta')

# ============== XFCE4 ==============
#
# xfce4 group except thunar, thunar-volman, tumbler
# -> pacman -Sg xfce4 | sed 's|^xfce4 |depends+=(|; s|$|)|'
depends+=(exo)
depends+=(garcon)
depends+=(xfce4-appfinder)
depends+=(xfce4-panel)
depends+=(xfce4-power-manager)
depends+=(xfce4-session)
depends+=(xfce4-settings)
depends+=(xfce4-terminal)
depends+=(xfconf)
depends+=(xfdesktop)
depends+=(xfwm4)
depends+=(xfwm4-themes)
#
# some pkgs from xfce4-goodies group, except e.g.
# -> ristretto (image viewer)
# -> xfce4-artwork
# -> xfce4-time-out-plugin (take breaks)
# -> xfce4-timer-plugin
# -> xfce4-xkb-plugin (keyboard layouts)
# -> thunar-media-tags-plugin
depends+=(mousepad xfce4-genmon-plugin xfce4-notifyd xfce4-screensaver xfce4-screenshooter xfce4-weather-plugin xfce4-whiskermenu-plugin)
#
# keyring/secrets
# ->  https://wiki.archlinux.org/title/GNOME/Keyring#Installation
depends+=(gnome-keyring libsecret)
#
# bluelight filter
depends+=(de-p1st-redshift)

# ============== display manager ==============
# sddm with autologin
# depends+=(de-p1st-sddm-autologin)
#
# sddm themeing
depends+=(de-p1st-sddm-theme)

# ============== file manager: thunar/nautilus and optional dependencies ==============

# Option1: thunar
#depends+=(thunar thunar-media-tags-plugin thunar-volman)
#depends+=(tumbler)  # thunar thumbnail previews
#depends+=(gvfs)  # for trash support, mounting with udisk and remote filesystems (e.g. webdav)
#
# Option2: nautilus (GNOME files)
# -> As thunar contains libraries required by xfdesktop, it will still be installed
# -> https://forum.xfce.org/viewtopic.php?pid=63945#p63945
depends+=(nautilus)
depends+=(xdg-user-dirs)  # nautilus new file templates
depends+=(python-nautilus)  # e.g. Nextcloud integration
depends+=(libnotify cmark-gfm de-p1st-image-width-limit wkhtmltopdf)  # md-to-pdf script depends on these packages

# compression/archiving
# -> https://docs.xfce.org/xfce/thunar/archive#supported_archive_managers
#
# Option1: thunar and xarchiver
#depends+=(thunar-archive-plugin xarchiver p7zip unzip zip unrar)
#
# Option2: thunar and file-roller
#depends+=(thunar-archive-plugin file-roller p7zip unrar)
#
# Option3: nautilus and file-roller
depends+=(file-roller)

# ============== audio ==============
# pulseaudio - base
depends+=('pulseaudio' 'pulseaudio-alsa' 'pavucontrol')
# pulseaudio - xfce4
depends+=('xfce4-pulseaudio-plugin')
# sound theme
depends+=('libcanberra' 'libcanberra-pulse')

# ============== bluetooth (TODO) ==============
depends+=('toggle-bluetooth')

# ============== network, theme, wallpaper, keyboard ==============
#
# NetworkManager and NetworkManager applet
depends+=(network-manager-applet)  # depends on networkmanager
#
# gtk and qt theme
depends+=(de-p1st-theme)
#
# wallpaper
depends+=(de-p1st-wallpaper)
#
# x11 keyboard layouts
depends+=(de-p1st-keyboard-x11)


optdepends=()

# https://wiki.archlinux.org/title/GNOME/Keyring#Manage_using_GUI
optdepends+=('seahorse: Manage the contents of GNOME Keyring; manage GPG keys')
optdepends+=('seahorse-nautilus: PGP encryption and signing for nautilus')

build() {
  # copy nautilus script
  cp md-to-pdf/md-to-pdf "${_reponame}/pkg/${pkgname}"/skel_nautilus/.local/share/nautilus/scripts/md-to-pdf
}

package() {
  cd "${_reponame}/pkg/${pkgname}"

  install -Dm0644 img/face.jpg "$pkgdir"/etc/skel/.face

  # Adding a xml configuration to /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/*.xml does not work.
  # (It will not be copied to ~/.config/xfce4/xfconf/xfce-perchannel-xml/*.xml)
  # Thus we place it in the skeleton for new users!
  # -> See comments in individual files in directory "config"
  # -> Additionally there is the file .config/user-dirs.dirs for nautilus new file templates
  mkdir -p        "$pkgdir"/etc/
  rsync -av skel/ "$pkgdir"/etc/skel/

  # === shortcuts ===
  # Did not work with "$pkgdir"/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

  # === display manager ===
  install -Dm0644 systemd.preset     "$pkgdir"/usr/lib/systemd/system-preset/20-"$pkgname".preset
  install -Dm0644 p1st-settings.conf "$pkgdir"/etc/sddm.conf.d/p1st-settings.conf

  # === nautilus ===
  # -> default file manager
  # -> nautilus scripts
  # -> .config/dconf/user -> nautilus preferences (show hidden files, list view, show create symlink)
  mkdir -p                 "$pkgdir"/etc/
  rsync -av skel_nautilus/ "$pkgdir"/etc/skel/
}