# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.

[gcode_macro _km_idle_timeout]
gcode:
  {% if printer.pause_resume.is_paused %}
    {action_respond_info("Extruder powered down on idle timeout.")}
    SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{
      printer[printer.toolhead.extruder].target}"
    M104; Turn off extruder but leave the bed on.
  {% else %}
    TURN_OFF_HEATERS
    M107; turn off fan
    M84
    _KM_PRINT_STATUS ACTION=CHANGE STATUS=ready
  {% endif %}
