#!/bin/bash

export BASE_HYPRLAND_PACKAGES="\
	brightnessctl \
	cliphist \
	dconf-editor \
	eog \
	eog-plugins \
	falkon \
	fcitx5-im \
	fcitx5-chinese-addons \
	file-roller \
	gnome-calculator \
	gnome-software \
	gnome-keyring \
	grim \
	hypridle \
	hyprland \
	hyprland-qt-support \
	hyprlock \
	hyprpaper \
	hyprpicker \
	hyprutils \
	hyprshot \
	kitty \
	kvantum \
	kvantum-qt5 \
	mako \
	network-manager-applet \
	noto-fonts-cjk \
	nwg-look \
	papirus-icon-theme \
	pavucontrol \
	polkit-gnome \
	qt5ct \
	qt6ct \
	rofi-wayland \
	seahorse \
	thunar \
	thunar-archive-plugin \
	thunar-media-tags-plugin \
	thunar-volman \
	tumbler \
	waybar \
	xed \
	xorg-xhost \
	xdg-desktop-portal-gtk \
	xdg-desktop-portal-hyprland \
	wl-clip-persist \
	wofi \
	uwsm \
"

export BASE_HYPRLAND_AUR_PACKAGES="\
	tofi \
	wlogout-git \
"

hyprland_postinstallhook() {
	echo "password	optional	pam_gnome_keyring.so" >> /etc/pam.d/passwd

	# Handle cursor binary setup
	if [ -e /usr/bin/cursor ]; then
		if [ -L /usr/bin/cursor ]; then
			# /usr/bin/cursor is a symlink, check its target
			cursor_target=$(readlink /usr/bin/cursor)
			if [ "$cursor_target" != "/usr/bin/cursor-wrapper" ]; then
				# Symlink points to something else, preserve the original target
				ln -sf "$cursor_target" /usr/libexec/cursor
				ln -sf /usr/bin/cursor-wrapper /usr/bin/cursor
			fi
		else
			# /usr/bin/cursor is a regular file
			cp /usr/bin/cursor /usr/bin/cursor.orig
			ln -sf /usr/bin/cursor.orig /usr/libexec/cursor
			ln -sf /usr/bin/cursor-wrapper /usr/bin/cursor
		fi
	fi
}