|
| 1 | +# This script is meant to be sourced. |
| 2 | +# It's not for directly running. |
| 3 | + |
| 4 | +function prepare_systemd_user_service(){ |
| 5 | + if [[ ! -d "${XDG_CONFIG_HOME}/systemd/user" ]]; then |
| 6 | + x mkdir -p "${XDG_CONFIG_HOME}/systemd/user" |
| 7 | + fi |
| 8 | + if [[ ! -e "${XDG_CONFIG_HOME}/systemd/user/ydotool.service" ]]; then |
| 9 | + x ln -s /usr/lib/systemd/system/ydotool.service "${XDG_CONFIG_HOME}/systemd/user/ydotool.service" |
| 10 | + fi |
| 11 | +} |
| 12 | +##################################################################################### |
| 13 | +# 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. |
| 14 | +showfun install-python-packages |
| 15 | +v install-python-packages |
| 16 | + |
| 17 | +if [[ -z $(getent group i2c) ]]; then |
| 18 | + v sudo groupadd i2c |
| 19 | +fi |
| 20 | +v sudo usermod -aG video,i2c,input "$(whoami)" |
| 21 | + |
| 22 | +if [[ ! -z $(systemctl --version) ]]; then |
| 23 | + if [[ "$OS_DISTRO_ID" == "fedora" ]]; then |
| 24 | + v bash -c "echo uinput | sudo tee /etc/modules-load.d/uinput.conf" |
| 25 | + v bash -c 'echo SUBSYSTEM==\"misc\", KERNEL==\"uinput\", MODE=\"0660\", GROUP=\"input\" | sudo tee /etc/udev/rules.d/99-uinput.rules' |
| 26 | + else |
| 27 | + v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" |
| 28 | + fi |
| 29 | + # 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". |
| 30 | + if [[ ! "${INSTALL_VIA_NIX}" == true ]]; then |
| 31 | + if [[ "$OS_DISTRO_ID" == "fedora" ]]; then |
| 32 | + v prepare_systemd_user_service |
| 33 | + fi |
| 34 | + # 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. |
| 35 | + if [[ ! -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then |
| 36 | + v systemctl --user enable ydotool --now |
| 37 | + else |
| 38 | + v sudo systemctl --machine=$(whoami)@.host --user enable ydotool --now |
| 39 | + fi |
| 40 | + fi |
| 41 | + v sudo systemctl enable bluetooth --now |
| 42 | +elif [[ ! -z $(openrc --version) ]]; then |
| 43 | + v bash -c "echo 'modules=i2c-dev' | sudo tee -a /etc/conf.d/modules" |
| 44 | + v sudo rc-update add modules boot |
| 45 | + v sudo rc-update add ydotool default |
| 46 | + v sudo rc-update add bluetooth default |
| 47 | + |
| 48 | + x sudo rc-service ydotool start |
| 49 | + x sudo rc-service bluetooth start |
| 50 | +else |
| 51 | + printf "${STY_RED}" |
| 52 | + printf "====================INIT SYSTEM NOT FOUND====================\n" |
| 53 | + printf "${STY_RST}" |
| 54 | + pause |
| 55 | +fi |
| 56 | + |
| 57 | +if [[ "$OS_DISTRO_ID" == "gentoo" ]]; then |
| 58 | + v sudo chown -R $(whoami):$(whoami) ~/.config/hypr/ |
| 59 | + v sudo chown -R $(whoami):$(whoami) ~/.config/quickshell/ |
| 60 | +fi |
| 61 | + |
| 62 | +v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' |
| 63 | +v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' |
| 64 | +v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly |
0 commit comments