mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-15 11:34:27 +05:00
fix: rework locate_printer_cfg function
This commit is contained in:
@@ -12,16 +12,18 @@ check_euid(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
locate_printer_cfg(){
|
locate_printer_cfg(){
|
||||||
|
unset PRINTER_CFG
|
||||||
|
status_msg "Locating printer.cfg"
|
||||||
if [ -f $KLIPPER_SERVICE2 ]; then
|
if [ -f $KLIPPER_SERVICE2 ]; then
|
||||||
#reads /etc/default/klipper and gets the default printer.cfg location
|
#reads /etc/default/klipper and gets the default printer.cfg location
|
||||||
PRINTER_CFG_LOC=$(grep "KLIPPY_ARGS=" /etc/default/klipper | cut -d" " -f2)
|
KLIPPY_ARGS_LINE="$(grep "KLIPPY_ARGS=" /etc/default/klipper)"
|
||||||
if [ -e $PRINTER_CFG_LOC ]; then
|
KLIPPY_ARGS_COUNT="$(grep -o " " <<< "$KLIPPY_ARGS_LINE" | wc -l)"
|
||||||
PRINTER_CFG=$(readlink -e $PRINTER_CFG_LOC)
|
i=1
|
||||||
else
|
PRINTER_CFG=$(while [ "$i" != "$KLIPPY_ARGS_COUNT" ]; do grep -E "(\/[A-Za-z0-9\_-]+)+\/printer\.cfg" /etc/default/klipper | cut -d" " -f"$i"; i=$(( $i + 1 )); done | grep "printer.cfg")
|
||||||
PRINTER_CFG=""
|
ok_msg "printer.cfg found in: '$PRINTER_CFG'"
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
PRINTER_CFG=""
|
PRINTER_CFG=""
|
||||||
|
warn_msg "Couldn't locate printer.cfg - File not found!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user