#!/usr/bin/env bash
# Do not use this script unless you know what you are doing! And even when
# thou art I, and know what thou art doing, this is a poor practice I really
# should stop.
set -x

# If the latest commit cannot be verified, exit to error.
echo "git config --global gpg.ssh.allowedSignersFile ~/src/codeberg.org/Aminda/ssh-allowed_signers/allowed_signers"
git verify-commit HEAD || exit 1

# Place my personal more questionable aliases in place, except that I don't
# actually use them as I keep forgetting about them.
cp -v .mikaela/bash_aliases $HOME/.bash_aliases
cp -v .mikaela/zsh_aliases $HOME/.zsh_aliases

# I still question whether xinitrc gets read under wayland, but I am not
# about to start removing this legacy config, just in case of something
# unexpected.
cp -v rc/xinitrc $HOME/.xinitrc

# My gnupg configuration with questionable options such as always
# encrypting to me, so paws off.
mkdir -p ~/.gnupg
cp -v .mikaela/gpg.conf $HOME/.gnupg/gpg.conf

# my name and all in pastes made through pastebinit, if it still even exists
cp -v .mikaela/pastebinit.xml $HOME/.pastebinit.xml

# may change your language to Finnish or do other fun someone else than I
# wouldn't expect
cp -v .mikaela/environment $HOME/.environment

# my git configuration including the names, addresses, public keys, etc.
mkdir ~/.config/git
git config --global --add include.path '~/.shell-things/.mikaela/gitconfig'
cp -v .gitattributes $HOME/.config/git/attributes

# unless thou art I, thou don't want my authorized_keys on your system.
mkdir -p ~/.ssh
cp -v .mikaela/keys/authorized_keys $HOME/.ssh/authorized_keys
cp -v etc/ssh/ssh_config $HOME/.ssh/config

# Text editor configuration (with a lot of bloat) that shouldn't be reached
# anyway since every project should have its own not so bloated editorconfig.
cp -v .editorconfig $HOME/.editorconfig

# Is Firefox installed to the location I generally use? Then apply my
# autoconfigs. These are very surprising and unexpected unless thou art I,
# thou have been warned.
if [ -d ~/.local/firefox/defaults/pref/ ]; then
	cp -v conf/autoconfig.js $HOME/.local/firefox/defaults/pref/autoconfig.js
	#cp -v conf/librewolf.overrides.cfg $HOME/.local/firefox/librewolf.overrides.cfg
	cp -v conf/firefox-forbidden-policies.js $HOME/.local/firefox/firefox-forbidden-policies.js
fi
#cp -v conf/librewolf.overrides.cfg $HOME/public_html/autoconfig.js
cp -v conf/firefox-forbidden-policies.js $HOME/public_html/autoconfig.js
mkdir -p ~/.librewolf/ ~/.var/app/io.gitlab.librewolf-community/.librewolf/
#cp -v conf/librewolf.overrides.cfg $HOME/.librewolf/librewolf.overrides.cfg
cp -v conf/firefox-forbidden-policies.js $HOME/.librewolf/librewolf.overrides.cfg
#cp -v conf/librewolf.overrides.cfg $HOME/.var/app/io.gitlab.librewolf-community/.librewolf/librewolf.overrides.cfg
cp -v conf/firefox-forbidden-policies.js $HOME/.var/app/io.gitlab.librewolf-community/.librewolf/librewolf.overrides.cfg

# Mainly KDE Plasma Integration extension support, but there may be GNOME
# and similar there too
mkdir -p ~/.mozilla/native-messaging-hosts
if [ -d /usr/lib64/mozilla/native-messaging-hosts/ ]; then
	cp -v /usr/lib64/mozilla/native-messaging-hosts/* ~/.mozilla/native-messaging-hosts
elif [ -d /usr/lib/mozilla/native-messaging-hosts/ ]; then
	cp -v /usr/lib/mozilla/native-messaging-hosts/ ~/.mozilla/native-messaging-hosts
fi

# Desktop menu integration
mkdir -p ~/.local/share/applications
ln -nsfv ~/.shell-things/local/share/applications ~/.local/share/applications/shell-things

# Update desktop menu entries
if hash update-desktop-database 2>/dev/null; then
	update-desktop-database ~/.local/share/applications
fi

# Set a marker that this script has been used for the main script to read
touch ~/.MIKAELA_GREP

set +x

# vim : set ft=bash :
