Files
illogical-impulse/sdata/subcmd-install/2.setups.sh
T
2025-11-10 09:05:31 +08:00

66 lines
3.0 KiB
Bash

# This script is meant to be sourced.
# It's not for directly running.
function prepare_systemd_user_service(){
if [[ ! -d "${XDG_CONFIG_HOME}/systemd/user" ]]; then
x mkdir -p "${XDG_CONFIG_HOME}/systemd/user"
fi
if [[ ! -e "${XDG_CONFIG_HOME}/systemd/user/ydotool.service" ]]; then
x ln -s /usr/lib/systemd/system/ydotool.service "${XDG_CONFIG_HOME}/systemd/user/ydotool.service"
fi
}
#####################################################################################
# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies.
showfun install-python-packages
v install-python-packages
if [[ -z $(getent group i2c) ]]; then
v sudo groupadd i2c
fi
v sudo usermod -aG video,i2c,input "$(whoami)"
if [[ ! -z $(systemctl --version) ]]; then
if [[ "$OS_DISTRO_ID" == "fedora" ]]; then
v bash -c "echo uinput | sudo tee /etc/modules-load.d/uinput.conf"
v bash -c 'echo SUBSYSTEM==\"misc\", KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"input\" | sudo tee /etc/udev/rules.d/99-uinput.rules'
else
v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf"
fi
# TODO: find a proper way for enable Nix installed ydotool. When running `systemctl --user enable ydotool, it errors "Failed to enable unit: Unit ydotool.service does not exist".
if [[ ! "${INSTALL_VIA_NIX}" == true ]]; then
if [[ "$OS_DISTRO_ID" == "fedora" ]]; then
v prepare_systemd_user_service
fi
# When $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR are empty, it commonly means that the current user has been logged in with `su - user` or `ssh user@hostname`. In such case `systemctl --user enable <service>` is not usable. It should be `sudo systemctl --machine=$(whoami)@.host --user enable <service>` instead.
if [[ ! -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
v systemctl --user enable ydotool --now
else
v sudo systemctl --machine=$(whoami)@.host --user enable ydotool --now
fi
fi
v sudo systemctl enable bluetooth --now
elif [[ ! -z $(openrc --version) ]]; then
v bash -c "echo 'modules=i2c-dev' | sudo tee -a /etc/conf.d/modules"
v sudo rc-update add modules boot
v sudo rc-update add ydotool default
v sudo rc-update add bluetooth default
x sudo rc-service ydotool start
x sudo rc-service bluetooth start
else
printf "${STY_RED}"
printf "====================INIT SYSTEM NOT FOUND====================\n"
printf "${STY_RST}"
pause
fi
# _icons_, _konsole_, _hypr_, and _quickshell_ are are chowned to user since they're emerge in as root by default.
if [[ "$OS_DISTRO_ID" == "gentoo" ]]; then
v sudo chown -R $(whoami):$(whoami) ~/.config/hypr/
v sudo chown -R $(whoami):$(whoami) ~/.config/quickshell/
fi
v gsettings set org.gnome.desktop.interface font-name 'Rubik 11'
v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly