## arg 1:  the new package version
pre_install() {
	systemctl stop turing-smart-screen-python.service
}

## arg 1:  the new package version
post_install() {
	chmod -R +x "${pkgdir}/usr/share/turing-smart-screen/"
	sudo chown -R $(whoami):$(id -gn) "${pkgdir}/usr/share/turing-smart-screen/"

	sed -i 's|CONFIG_DATA = load_yaml("config.yaml")|CONFIG_DATA = load_yaml("/usr/share/turing-smart-screen/config.yaml")|' /usr/share/turing-smart-screen/library/config.py
	sed -i 's|THEME_DEFAULT = load_yaml("res/themes/default.yaml")|THEME_DEFAULT = load_yaml("/usr/share/turing-smart-screen/res/themes/default.yaml")|' /usr/share/turing-smart-screen/library/config.py
	sed -i 's|res/themes|/usr/share/turing-smart-screen/res/themes|g' /usr/share/turing-smart-screen/configure.py
	
	sed -i 's|WorkingDirectory=.*|WorkingDirectory=/usr/share/turing-smart-screen/|' /usr/lib/systemd/system/turing-smart-screen-python.service
	sed -i 's|ExecStart=.*|ExecStart=/usr/share/turing-smart-screen/turing-smart-screen.sh|' /usr/lib/systemd/system/turing-smart-screen-python.service
	
	sed -i 's/^ProtectSystem=full/#&/' /usr/lib/systemd/system/turing-smart-screen-python.service
	
	sleep 2  # Aguarde 2 segundos

	systemctl daemon-reload
	systemctl enable --now turing-smart-screen-python.service
	systemctl --global enable turing-smart-screen-python.service
	systemctl start turing-smart-screen-python.service	
	
}

## arg 2:  the old package version
#pre_upgrade() {
	# do something here
#}

## arg 2:  the old package version
post_upgrade() {
	post_install
}

## arg 1:  the old package version
pre_remove() {
	systemctl --global disable turing-smart-screen-python.service
}

## arg 1:  the old package version
#post_remove() {
	# do something here
#}
