From c7890d171000eac539c6a515edbc70818d535e41 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Sat, 14 May 2022 12:33:06 +0200 Subject: [PATCH] refactor(klipper.sh): show python3 in main menu Signed-off-by: Dominik Willner th33xitus@gmail.com --- scripts/klipper.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/klipper.sh b/scripts/klipper.sh index b29464d..08675eb 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -436,7 +436,7 @@ function update_klipper(){ #================================================# function get_klipper_status(){ - local sf_count status + local sf_count status py_ver sf_count="$(klipper_systemd | wc -w)" ### detect an existing "legacy" klipper init.d installation if [ "$(klipper_systemd | wc -w)" -eq 0 ] \ @@ -444,6 +444,8 @@ function get_klipper_status(){ sf_count=1 fi + py_ver=$(get_klipper_python_ver) + ### remove the "SERVICE" entry from the data array if a klipper service is installed local data_arr=(SERVICE "${KLIPPER_DIR}" "${KLIPPY_ENV}") [ "${sf_count}" -gt 0 ] && unset "data_arr[0]" @@ -455,7 +457,11 @@ function get_klipper_status(){ done if (( filecount == ${#data_arr[*]})); then - status="Installed: ${sf_count}" + if (( py_ver == 3 )); then + status="Installed: ${sf_count}(py${py_ver})" + else + status="Installed: ${sf_count}" + fi elif ((filecount == 0)); then status="Not installed!" else @@ -515,6 +521,8 @@ function get_klipper_cfg_dir() { ### returns the major python version the klippy-env was created with function get_klipper_python_ver() { + ! [[ -d ${KLIPPY_ENV} ]] && return + local version version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1) echo "${version}"