Skip to content

Feature Request: Allow expanding environment variables in gcode shell command PARAMS #961

Description

@pellcorp

I would like to be able to use $TMPDIR and $HOME in PARAMS like so:

RUN_SHELL_COMMAND CMD=calibrate_shaper PARAMS="--shapers {shapers} $TMPDIR/resonances_y_b.csv -o $HOME/printer_data/config/images/resonances_y.png"

The change I have in my local fork is:

diff --git a/klippy/extras/gcode_shell_command.py b/klippy/extras/gcode_shell_command.py
index da2427512..3f7843055 100644
--- a/klippy/extras/gcode_shell_command.py
+++ b/klippy/extras/gcode_shell_command.py
@@ -53,6 +53,7 @@ class ShellCommand:
 
     def cmd_RUN_SHELL_COMMAND(self, params):
         gcode_params = params.get("PARAMS", "")
+        gcode_params = os.path.expandvars(gcode_params)
         gcode_params = shlex.split(gcode_params)
         reactor = self.printer.get_reactor()
         try:

Wondering if Kalico would consider making this change and if so will it be useful for me to open a PR?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions