mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
Introduce OS_GROUP_ID
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# This script is meant to be sourced.
|
||||
# It's not for directly running.
|
||||
|
||||
# This file is currently WIP.
|
||||
|
||||
v install-Rubik
|
||||
v install-Gabarito
|
||||
v install-OneUI
|
||||
v install-bibata
|
||||
v install-MicroTeX
|
||||
v install-uv
|
||||
@@ -1 +0,0 @@
|
||||
WIP
|
||||
@@ -0,0 +1,116 @@
|
||||
# This script is meant to be sourced.
|
||||
# It's not for directly running.
|
||||
function print_os_group_id(){
|
||||
printf "${STY_CYAN}"
|
||||
printf "===INFO===\n"
|
||||
printf "Detected OS_DISTRO_ID: ${OS_DISTRO_ID}\n"
|
||||
printf "Detected OS_DISTRO_ID_LIKE: ${OS_DISTRO_ID_LIKE}\n"
|
||||
printf "Determined OS_GROUP_ID: ${OS_GROUP_ID}\n"
|
||||
printf "==========\n\n"
|
||||
printf "${STY_RST}"
|
||||
}
|
||||
function print_os_group_id_alike(){
|
||||
printf "${STY_YELLOW}"
|
||||
printf "===WARNING===\n"
|
||||
printf "Ideally, it should also work for your distro.\n"
|
||||
printf "Still, there is a chance that it not works as expected or even fails.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "=============\n\n"
|
||||
printf "${STY_RST}"
|
||||
}
|
||||
function print_os_group_id_unofficial(){
|
||||
printf "${STY_PURPLE}"
|
||||
printf "===NOTICE===\n"
|
||||
printf "The support for your distro is provided by the community.\n"
|
||||
printf "It is not officially supported by github:end-4/dots-hyprland .\n"
|
||||
printf "${STY_BOLD}"
|
||||
printf "If you find out any problems about it, PR is welcomed if you are able to address it. Or, create a discussion about it, but please do not submit issue, because the developers do not use this distro, therefore they cannot help.${STY_RST}\n"
|
||||
printf "${STY_PURPLE}"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "============\n\n"
|
||||
printf "${STY_RST}"
|
||||
}
|
||||
function print_os_group_id_fallback(){
|
||||
printf "${STY_RED}"
|
||||
printf "===CAUTION===\n"
|
||||
printf "No support provided for your distro, using fallback method.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "=============\n\n"
|
||||
printf "${STY_RST}"
|
||||
}
|
||||
function print_os_group_id_force_vianix(){
|
||||
printf "${STY_RED}"
|
||||
printf "===CAUTION===\n"
|
||||
printf "\"--via-nix\" is forcely specified as the only method to support your distro.\n"
|
||||
printf "It is still experimental and some functionalities are missing.\n"
|
||||
printf "It may also behave unexpectedly.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "=============\n\n"
|
||||
printf "${STY_RST}"
|
||||
}
|
||||
#####################################################################################
|
||||
|
||||
####################
|
||||
# Detect architecture
|
||||
# Helpful link(s):
|
||||
# http://stackoverflow.com/questions/45125516
|
||||
export MACHINE_ARCH=$(uname -m)
|
||||
case "${MACHINE_ARCH}" in
|
||||
"x86_64") sleep 0;;
|
||||
*)
|
||||
printf "${STY_YELLOW}"
|
||||
printf "===WARNING===\n"
|
||||
printf "Detected machine architecture: ${MACHINE_ARCH}\n"
|
||||
printf "This script only supports x86_64.\n"
|
||||
printf "It is very likely to fail when installing dependencies on your machine.\n"
|
||||
printf "=============\n"
|
||||
printf "\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
;;
|
||||
esac
|
||||
|
||||
####################
|
||||
# Detect distro
|
||||
# Helpful link(s):
|
||||
# http://stackoverflow.com/questions/29581754
|
||||
# https://github.com/which-distro/os-release
|
||||
OS_RELEASE_FILE_CUSTOM="${REPO_ROOT}/os-release"
|
||||
if test -f "${OS_RELEASE_FILE_CUSTOM}"; then
|
||||
printf "${STY_YELLOW}Warning: using custom os-release file \"${OS_RELEASE_FILE_CUSTOM}\".${STY_RST}\n"
|
||||
OS_RELEASE_FILE="${OS_RELEASE_FILE_CUSTOM}"
|
||||
elif test -f /etc/os-release; then
|
||||
OS_RELEASE_FILE=/etc/os-release
|
||||
else
|
||||
printf "${STY_RED}/etc/os-release does not exist, aborting...${STY_RST}\n" ; exit 1
|
||||
fi
|
||||
export OS_DISTRO_ID=$(awk -F'=' '/^ID=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
|
||||
export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
|
||||
|
||||
|
||||
####################
|
||||
# Determine distro ID
|
||||
|
||||
if [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros|cachyos)$ ]]; then
|
||||
OS_GROUP_ID="arch"
|
||||
print_os_group_id_functions=(print_os_group_id)
|
||||
elif [[ "$OS_DISTRO_ID_LIKE" == "arch" ]]; then
|
||||
OS_GROUP_ID="arch"
|
||||
print_os_group_id_functions=(print_os_group_id{,_alike})
|
||||
elif [[ "$OS_DISTRO_ID" == "gentoo" ]]; then
|
||||
OS_GROUP_ID="gentoo"
|
||||
print_os_group_id_functions=(print_os_group_id{,_unofficial})
|
||||
elif [[ "$OS_DISTRO_ID_LIKE" == "gentoo" ]]; then
|
||||
OS_GROUP_ID="gentoo"
|
||||
print_os_group_id_functions=(print_os_group_id{,_alike,_unofficial})
|
||||
elif [[ "$OS_DISTRO_ID" == "fedora" ]]; then
|
||||
OS_GROUP_ID="fedora"
|
||||
print_os_group_id_functions=(print_os_group_id{,_unofficial})
|
||||
elif [[ "$OS_DISTRO_ID_LIKE" == "fedora" ]]; then
|
||||
OS_GROUP_ID="fedora"
|
||||
print_os_group_id_functions=(print_os_group_id{,_alike,_unofficial})
|
||||
else
|
||||
OS_GROUP_ID="fallback"
|
||||
INSTALL_VIA_NIX=true
|
||||
print_os_group_id_functions=(print_os_group_id{,_fallback,_force_vianix})
|
||||
fi
|
||||
@@ -41,42 +41,7 @@ function outdate_detect(){
|
||||
echo "UPDATED"
|
||||
fi
|
||||
}
|
||||
####################
|
||||
# Detect architecture
|
||||
# Helpful link(s):
|
||||
# http://stackoverflow.com/questions/45125516
|
||||
export MACHINE_ARCH=$(uname -m)
|
||||
case $MACHINE_ARCH in
|
||||
"x86_64") sleep 0;;
|
||||
*)
|
||||
printf "${STY_YELLOW}"
|
||||
printf "===WARNING===\n"
|
||||
printf "Detected machine architecture: ${MACHINE_ARCH}\n"
|
||||
printf "This script only supports x86_64.\n"
|
||||
printf "It is very likely to fail when installing dependencies on your machine.\n"
|
||||
printf "\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
;;
|
||||
esac
|
||||
|
||||
####################
|
||||
# Detect distro
|
||||
# Helpful link(s):
|
||||
# http://stackoverflow.com/questions/29581754
|
||||
# https://github.com/which-distro/os-release
|
||||
OS_RELEASE_FILE_CUSTOM="${REPO_ROOT}/os-release"
|
||||
if test -f "${OS_RELEASE_FILE_CUSTOM}"; then
|
||||
printf "${STY_YELLOW}Warning: using custom os-release file \"${OS_RELEASE_FILE_CUSTOM}\".${STY_RST}\n"
|
||||
OS_RELEASE_FILE="${OS_RELEASE_FILE_CUSTOM}"
|
||||
elif test -f /etc/os-release; then
|
||||
OS_RELEASE_FILE=/etc/os-release
|
||||
else
|
||||
printf "${STY_RED}/etc/os-release does not exist, aborting...${STY_RST}\n" ; exit 1
|
||||
fi
|
||||
export OS_DISTRO_ID=$(awk -F'=' '/^ID=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
|
||||
export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
|
||||
|
||||
#####################################################################################
|
||||
|
||||
if [[ "$INSTALL_VIA_NIX" == "true" ]]; then
|
||||
|
||||
@@ -91,103 +56,37 @@ if [[ "$INSTALL_VIA_NIX" == "true" ]]; then
|
||||
pause
|
||||
source ./sdata/dist-${TARGET_ID}/install-deps.sh
|
||||
|
||||
elif [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros)$ ]]; then
|
||||
elif [[ "$OS_GROUP_ID" =~ ^(arch|gentoo|fedora)$ ]]; then
|
||||
|
||||
TARGET_ID=arch
|
||||
printf "${STY_GREEN}"
|
||||
printf "===INFO===\n"
|
||||
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
|
||||
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
|
||||
printf "\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
source ./sdata/dist-${TARGET_ID}/install-deps.sh
|
||||
|
||||
elif [[ -f "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh" ]]; then
|
||||
|
||||
TARGET_ID=${OS_DISTRO_ID}
|
||||
printf "${STY_PURPLE}"
|
||||
printf "===NOTICE===\n"
|
||||
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
|
||||
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
|
||||
printf "This file is provided by the community.\n"
|
||||
printf "It is not officially supported by github:end-4/dots-hyprland .\n"
|
||||
test -f "./sdata/dist-${TARGET_ID}/README.md" && \
|
||||
printf "Read ${STY_INVERT} ./sdata/dist-${TARGET_ID}/README.md ${STY_RST}${STY_PURPLE} for more information.\n"
|
||||
printf "${STY_BOLD}"
|
||||
printf "If you find out any problems about it, PR is welcomed if you are able to address it. Or, create a discussion about it, but please do not submit issue, because the developers do not use this distro, therefore they cannot help.${STY_RST}\n"
|
||||
printf "${STY_PURPLE}"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
tmp_update_status="$(outdate_detect sdata/dist-arch sdata/dist-${TARGET_ID})"
|
||||
if [[ "${tmp_update_status}" =~ ^(OUTDATED|EMPTY_TARGET|EMPTY_SOURCE|FORCE_OUTDATED|WIP)$ ]]; then
|
||||
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
|
||||
printf "${STY_RED}"
|
||||
printf "The community provided ./sdata/dist-${TARGET_ID}/ is outdated (status: ${tmp_update_status}),\n"
|
||||
printf "which means it probably does not reflect all latest changes of ./sdata/dist-arch/ .\n"
|
||||
printf "\n"
|
||||
printf "According to the actual changes, it may still works, but it can also work unexpectedly.\n"
|
||||
printf "It's highly recommended to check the following links before continue:${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/discussions/2140${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-arch${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-${TARGET_ID}${STY_RST}\n"
|
||||
printf "\n"
|
||||
printf "${STY_PURPLE}${STY_INVERT}PR on ./sdata/dist-${TARGET_ID}/ to properly reflect the latest changes of ./sdata/dist-arch is welcomed.${STY_RST}\n"
|
||||
printf "\n"
|
||||
if [ "$ask" = "false" ]; then
|
||||
echo "Urgent problem encountered, aborting...";exit 1
|
||||
else
|
||||
printf "${STY_RED}Still proceed?${STY_RST}\n"
|
||||
read -p "[y/N]: " p
|
||||
case "$p" in
|
||||
[yY])sleep 0;;
|
||||
*)echo "Aborting...";exit 1;;
|
||||
esac
|
||||
TARGET_ID=$OS_GROUP_ID
|
||||
if ! [[ "${TARGET_ID}" = "arch" ]]; then
|
||||
tmp_update_status="$(outdate_detect sdata/dist-arch sdata/dist-${TARGET_ID})"
|
||||
if [[ "${tmp_update_status}" =~ ^(OUTDATED|EMPTY_TARGET|EMPTY_SOURCE|FORCE_OUTDATED|WIP)$ ]]; then
|
||||
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
|
||||
printf "${STY_RED}"
|
||||
printf "The community provided ./sdata/dist-${TARGET_ID}/ is outdated (status: ${tmp_update_status}),\n"
|
||||
printf "which means it probably does not reflect all latest changes of ./sdata/dist-arch/ .\n"
|
||||
printf "\n"
|
||||
printf "According to the actual changes, it may still works, but it can also work unexpectedly.\n"
|
||||
printf "It's highly recommended to check the following links before continue:${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/discussions/2140${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-arch${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-${TARGET_ID}${STY_RST}\n"
|
||||
printf "\n"
|
||||
printf "${STY_PURPLE}${STY_INVERT}PR on ./sdata/dist-${TARGET_ID}/ to properly reflect the latest changes of ./sdata/dist-arch is welcomed.${STY_RST}\n"
|
||||
printf "\n"
|
||||
if [ "$ask" = "false" ]; then
|
||||
echo "Urgent problem encountered, aborting...";exit 1
|
||||
else
|
||||
printf "${STY_RED}Still proceed?${STY_RST}\n"
|
||||
read -p "[y/N]: " p
|
||||
case "$p" in
|
||||
[yY])sleep 0;;
|
||||
*)echo "Aborting...";exit 1;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
source ./sdata/dist-${TARGET_ID}/install-deps.sh
|
||||
|
||||
elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then
|
||||
|
||||
TARGET_ID=arch
|
||||
printf "${STY_YELLOW}"
|
||||
printf "===WARNING===\n"
|
||||
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
|
||||
printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n"
|
||||
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
|
||||
printf "Ideally, it should also work for your distro.\n"
|
||||
printf "Still, there is a chance that it not works as expected or even fails.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
source ./sdata/dist-${TARGET_ID}/install-deps.sh
|
||||
|
||||
else
|
||||
|
||||
TARGET_ID=fallback
|
||||
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
|
||||
printf "${STY_RED}"
|
||||
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
|
||||
printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n"
|
||||
printf "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh not found.\n"
|
||||
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
|
||||
printf "1. It may disrupt your system and will likely fail without your manual intervention.\n"
|
||||
printf "2. It is WIP and only contains small number of dependencies far from enough.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "${STY_RST}"
|
||||
if [ "$ask" = "false" ]; then
|
||||
echo "Urgent problem encountered, aborting...";exit 1
|
||||
else
|
||||
printf "${STY_RED}Still proceed?${STY_RST}\n"
|
||||
read -p "[y/N]: " p
|
||||
case "$p" in
|
||||
[yY])sleep 0;;
|
||||
*)echo "Aborting...";exit 1;;
|
||||
esac
|
||||
fi
|
||||
source ./sdata/dist-${TARGET_ID}/install-deps.sh
|
||||
|
||||
fi
|
||||
|
||||
@@ -20,7 +20,7 @@ fi
|
||||
v sudo usermod -aG video,i2c,input "$(whoami)"
|
||||
|
||||
if [[ ! -z $(systemctl --version) ]]; then
|
||||
if [[ "$OS_DISTRO_ID" == "fedora" ]]; then
|
||||
if [[ "$OS_GROUP_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
|
||||
@@ -28,7 +28,7 @@ if [[ ! -z $(systemctl --version) ]]; then
|
||||
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
|
||||
if [[ "$OS_GROUP_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.
|
||||
@@ -55,7 +55,7 @@ else
|
||||
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
|
||||
if [[ "$OS_GROUP_ID" == "gentoo" ]]; then
|
||||
v sudo chown -R $(whoami):$(whoami) ~/.config/hypr/
|
||||
v sudo chown -R $(whoami):$(whoami) ~/.config/quickshell/
|
||||
fi
|
||||
|
||||
@@ -59,7 +59,7 @@ case $SKIP_HYPRLAND in
|
||||
true) sleep 0;;
|
||||
*)
|
||||
warning_rsync_delete; v rsync -av --delete "${arg_excludes[@]}" dots/.config/hypr/ "$XDG_CONFIG_HOME"/hypr/
|
||||
if [ "$OS_DISTRO_ID" = "fedora" ];then
|
||||
if [ "$OS_GROUP_ID" = "fedora" ];then
|
||||
v rsync -av "${REPO_ROOT}/dots-extra/fedora/hypr/hyprland/execs.conf" "$XDG_CONFIG_HOME/hypr/hyprland/execs.conf"
|
||||
fi
|
||||
# When hypr/custom does not exist, we assume that it's the firstrun.
|
||||
|
||||
@@ -5,6 +5,7 @@ REPO_ROOT="$(pwd)"
|
||||
source ./sdata/lib/environment-variables.sh
|
||||
source ./sdata/lib/functions.sh
|
||||
source ./sdata/lib/package-installers.sh
|
||||
source ./sdata/lib/dist-determine.sh
|
||||
|
||||
prevent_sudo_or_root
|
||||
set -e
|
||||
@@ -58,6 +59,11 @@ case $1 in
|
||||
*)printf "${STY_RED}Unknown subcommand \"$1\".${STY_RST}\n";showhelp_global;exit 1;;
|
||||
esac
|
||||
#####################################################################################
|
||||
for function in ${print_os_group_id_functions[@]}; do
|
||||
$function
|
||||
done
|
||||
pause
|
||||
|
||||
if [[ -f "${SUBCMD_DIR}/options.sh" ]];
|
||||
then source "${SUBCMD_DIR}/options.sh"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user