# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Meta ebuild for Budgie Desktop Applets. Half of them are installed through the package budgie-extras. The rest are separate packages."

LICENSE="metapackage"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~arm ~arm64"

# Note: the following are taken out due to no wayland support and won't work on budgie-10.10
# - budgie_applets_window-previews
# - budgie_applets_hotcorners
# - budgie_applets_workspace-stopwatch
# - budgie_applets_quickchar
# - budgie_applets_window-shuffler
# - budgie_applets_keyboard-autoswitch
# - budgie_applets_rotation-lock
#
# - budgie_applets_brightness-control
# - budgie_applets_pixel-saver
# - budgie_applets_screenshot
#
# - budgie_applets_browser_profile_launcher
#
# Rest works and is left in, but some are taken out of recommended.

IUSE_BUDGIE_APPLETS="
	+budgie_applets_recommended
	budgie_applets_workspace-switcher
	budgie_applets_quicknote
	budgie_applets_showtime
	budgie_applets_countdown
	budgie_applets_clockworks
	budgie_applets_dropby
	budgie_applets_kangaroo
	budgie_applets_show-weather
	budgie_applets_app-launcher
	budgie_applets_recently-used
	budgie_applets_take-a-break
	budgie_applets_fuzzyclock
	budgie_applets_brightness-controller
	budgie_applets_visualspace
	budgie_applets_wallstreet
	budgie_applets_applications-menu
	budgie_applets_network-manager
	budgie_applets_screencast
	budgie_applets_extras-daemon
	budgie_applets_analogue-clock
	budgie_applets_calendar
	budgie_applets_clipboard
	budgie_applets_haste
	budgie_applets_systemmonitor
	budgie_applets_cputemp
	budgie_applets_performance_gauge
	budgie_applets_user-indicator-redux
	budgie_applets_media-player
	budgie_applets_hostname
	budgie_applets_cpufreq
	budgie_applets_lightpad
	budgie_applets_indicator
	budgie_applets_indicator-sysmonitor
"
IUSE="${IUSE_BUDGIE_APPLETS}"

# The idea is simple, at least one needs to be turned on or there is no purpose :P
REQUIRED_USE="
	|| ( budgie_applets_recommended
		budgie_applets_workspace-switcher
		budgie_applets_quicknote
		budgie_applets_showtime
		budgie_applets_countdown
		budgie_applets_clockworks
		budgie_applets_dropby
		budgie_applets_kangaroo
		budgie_applets_show-weather
		budgie_applets_app-launcher
		budgie_applets_recently-used
		budgie_applets_take-a-break
		budgie_applets_fuzzyclock
		budgie_applets_brightness-controller
		budgie_applets_visualspace
		budgie_applets_wallstreet
		budgie_applets_applications-menu
		budgie_applets_screencast
		budgie_applets_extras-daemon
		budgie_applets_analogue-clock
		budgie_applets_calendar
		budgie_applets_clipboard
		budgie_applets_haste
		budgie_applets_systemmonitor
		budgie_applets_cputemp
		budgie_applets_performance_gauge
		budgie_applets_hostname
		budgie_applets_cpufreq
		budgie_applets_lightpad
		budgie_applets_indicator
		budgie_applets_network-manager
		budgie_applets_user-indicator-redux
		budgie_applets_media-player
		budgie_applets_indicator-sysmonitor
	)"
# Taken out since they are supported with wayland. Left in comments for the future later.
#	budgie_applets_window-previews? ( budgie_applets_extras-daemon )
#	budgie_applets_quickchar? ( budgie_applets_extras-daemon )
#	budgie_applets_window-shuffler? ( budgie_applets_extras-daemon )
#"

# Taken out since it is not 100% working:
# - budgie_applets_user-indicator-redux > Can't lock the session as it calls upon budgie-screensaver which won't work.

# its a little bit double but since i do not know a way of making an ebuild use the same dep for 2 useflags at ones..
RDEPEND="
	budgie_applets_recommended? ( 
		>=budgie-extra/budgie-extras-2.1.0[budgie_applets_recommended,wayland]	
		>=budgie-extra/budgie-analogue-clock-applet-2.2-r1[wayland]
		=budgie-extra/budgie-calendar-applet-5.3-r1
		=budgie-extra/budgie-clipboard-applet-1.1.0-r1
		=budgie-extra/budgie-haste-applet-0.3.0-r1
		=budgie-extra/budgie-systemmonitor-applet-0.2.1-r1
	 	=budgie-extra/budgie-cputemp-applet-1.2.0-r1
	 	=budgie-extra/budgie-performance-gauge-applet-1.2-r1
	 	=budgie-extra/budgie-hostname-applet-1.0-r1
	 	=budgie-extra/budgie-cpufreq-applet-1.1.0-r1
	 	=budgie-extra/budgie-lightpad-applet-0.1.0
	 	=budgie-extra/budgie-indicator-applet-0.7.2-r1
	)

	budgie_applets_workspace-switcher?			( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_workspace-switcher,wayland] )
	budgie_applets_quicknote?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_quicknote,wayland] )
	budgie_applets_showtime?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_showtime,wayland] )
	budgie_applets_countdown?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_countdown,wayland] )
	budgie_applets_clockworks?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_clockworks,wayland] )
	budgie_applets_dropby?						( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_dropby,wayland] )
	budgie_applets_kangaroo?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_kangaroo,wayland] )
	budgie_applets_show-weather?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_show-weather,wayland] )
	budgie_applets_app-launcher?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_app-launcher,wayland] )
	budgie_applets_recently-used?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_recently-used,wayland] )
	budgie_applets_take-a-break?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_take-a-break,wayland] )
	budgie_applets_fuzzyclock?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_fuzzyclock,wayland] )
	budgie_applets_brightness-controller?		( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_brightness-controller,wayland] )
	budgie_applets_visualspace?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_visualspace,wayland] )
	budgie_applets_wallstreet?					( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_wallstreet,wayland] )
	budgie_applets_applications-menu?			( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_applications-menu,wayland] )
	budgie_applets_network-manager?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_network-manager,wayland] )
	budgie_applets_extras-daemon?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_extras-daemon,wayland] )
	budgie_applets_screencast?					( >=budgie-extra/budgie-extras-2.2.0[budgie_applets_screencast,wayland] )
	budgie_applets_analogue-clock?				( >=budgie-extra/budgie-analogue-clock-applet-2.2-r1[wayland] )
	budgie_applets_calendar?					( =budgie-extra/budgie-calendar-applet-5.3-r1 )
	budgie_applets_clipboard?					( =budgie-extra/budgie-clipboard-applet-1.1.0-r1 )
	budgie_applets_haste?						( =budgie-extra/budgie-haste-applet-0.3.0-r1 )
	budgie_applets_systemmonitor?				( =budgie-extra/budgie-systemmonitor-applet-0.2.1-r1 )
	budgie_applets_cputemp? 					( =budgie-extra/budgie-cputemp-applet-1.2.0-r1 )
	budgie_applets_performance_gauge? 			( =budgie-extra/budgie-performance-gauge-applet-1.2-r1 )
	budgie_applets_user-indicator-redux? 		( =budgie-extra/budgie-user-indicator-redux-applet-1.1.0 )
	budgie_applets_media-player? 				( =budgie-extra/budgie-media-player-applet-1.3.0[wayland] )
	budgie_applets_hostname? 					( =budgie-extra/budgie-hostname-applet-1.0-r1 )
	budgie_applets_cpufreq? 					( =budgie-extra/budgie-cpufreq-applet-1.1.0-r1 )
	budgie_applets_lightpad? 					( =budgie-extra/budgie-lightpad-applet-0.1.0 )
	budgie_applets_indicator? 					( =budgie-extra/budgie-indicator-applet-0.7.2-r1 )
	budgie_applets_indicator-sysmonitor? 		( =budgie-extra/budgie-indicator-sysmonitor-applet-0.10.2-r1[wayland] )

	!budgie-extra/budgie-screenshot-applet
	!budgie-extra/budgie-browser-profile-launcher-applet
	!budgie-extra/budgie-brightness-control-applet
	!budgie-extra/budgie-pixel-saver-applet
"
# 4 are blocked and will be uninstalled cause they either don't work or will crash budgie..

# Taken out since no wayland support for now:
#	budgie_applets_window-previews?			( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_window-previews] )
#	budgie_applets_hotcorners?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_hotcorners] )
#	budgie_applets_workspace-stopwatch?		( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_workspace-stopwatch] )
#	budgie_applets_quickchar?				( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_quickchar] )
#	budgie_applets_window-shuffler?			( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_window-shuffler] )
#	budgie_applets_keyboard-autoswitch?		( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_keyboard-autoswitch] )
#	budgie_applets_rotation-lock?			( >=budgie-extra/budgie-extras-2.1.0[budgie_applets_rotation-lock] )
# Permanently taken out due to not working properly.. or not at all..
#	budgie_applets_pixel-saver?				( >=budgie-extra/budgie-pixel-saver-applet-4.0.0 )
#	budgie_applets_screenshot?				( >=budgie-extra/budgie-screenshot-applet-0.4.3 )
#	budgie_applets_brightness-control?		( >=budgie-extra/budgie-brightness-control-applet-0.3 )
#	budgie_applets_browser-profile-launcher? ( >=budgie-extra/budgie-browser-profile-launcher-2.1.2 )
# Taken out due to PyGObject-3.52.3+ hardmask unmasking requirement:
# 	=budgie-extra/budgie-indicator-sysmonitor-applet-0.10.2-r1[wayland]
#	=budgie-extra/budgie-media-player-applet-1.3.0[wayland]

pkg_postinst() {
	if use budgie_applets_recommended ; then
		ewarn "The useflag 'recommended' of 'BUDGIE_APPLETS' has been turned on."
		ewarn "This will install every applet except the following:"
		ewarn "    - network-manager"
		ewarn "    - user-indicator-redux"
		ewarn "    - media-player"
		ewarn "    - indicator-sysmonitor"
		ewarn "If these are still wanted please add them to 'BUDGIE_APPLETS' and remerge this package."
		ewarn ""
		ewarn "For more information on how to configure this please check the following link:"
		ewarn "https://gitlab.com/SarahMia/sarahmiaoverlay/-/wikis/budgie-applets"
	fi

	elog "In order for all the applets to appear after installation without relogging it is recommended to run the following as your current logged in user:"
	elog "  nohup budgie-panel --replace > /dev/null 2>&1 &"
}

pkg_postrm() {
	elog "In order for all the applets to be removed from the budgie-settings applets without relogging it is recommended to run the following as your current logged in user in budgie:"
	elog "  nohup budgie-panel --replace > /dev/null 2>&1 &"
}