1
0
Fork 0
mirror of https://github.com/kou029w/dotfiles.git synced 2025-01-18 16:07:59 +00:00
dotfiles/mod.bash

71 lines
1.5 KiB
Bash

function install_apt_packages() {
local packages
local apt_sources_dir
. packages.bash
eval "$(apt-config shell apt_sources_dir 'Dir::Etc::sourceparts/d')"
rsync -rv etc/apt/keyrings/ /usr/share/keyrings/
rsync -rv etc/apt/sources.list.d/ "$apt_sources_dir"
[[ -d etc/default ]] \
&& rsync -rv etc/default/ /etc/default/
apt update
apt install -y "${packages[@]}"
}
function install_gitconfig() {
if (($(id -u) == 0)); then
sudo --user="#${SUDO_UID:-0}" \
git config --global --add include.path "$(realpath gitconfig)"
else
git config --global --add include.path "$(realpath gitconfig)"
fi
}
function install_dotfiles() {
local home
local dotfile
home=$(eval "echo ~${SUDO_USER:-}")
for dotfile in .*; do
[[ $dotfile =~ ^(\.\.?|\.git)$ ]] && continue
dotfile=$(realpath "$dotfile")
(
cd -- "$home"
ln -svf "$dotfile" .
)
done
}
function install_addons() {
local addon
for addon in "$@"; do
(
cd -- "$addon"
./install
)
done
}
function install_gsettings() {
local uid
local gsettings_file
local gsettings_dir
uid=${SUDO_UID:-$(id -u)}
gsettings_file=$1
gsettings_dir=$2
< "$gsettings_file" \
sudo --user="#$uid" \
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$uid/bus" \
dconf load "$gsettings_dir"
}
function install_pkg_packages() {
local packages
. packages.bash
pkg upgrade -y
pkg install -y "${packages[@]}"
}
function install_termux_task() {
mkdir -p ~/.shortcuts/tasks
install -v "$1" ~/.shortcuts/tasks/
}