Skip to content

Instantly share code, notes, and snippets.

@davebrny
Created June 13, 2022 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/a410b08acf7a776926cd0cf4ddead77b to your computer and use it in GitHub Desktop.
Save davebrny/a410b08acf7a776926cd0cf4ddead77b to your computer and use it in GitHub Desktop.
(tasker) a task that runs the termux plugin and termux-relay.py
<TaskerData sr="" dvi="1" tv="5.15.14">
<Task sr="task775">
<cdate>1653984629316</cdate>
<edate>1655136097308</edate>
<id>775</id>
<nme>python termux &gt;</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>547</code>
<label>set par1</label>
<Str sr="arg0" ve="3">%command</Str>
<Str sr="arg1" ve="3">%par1</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
<Int sr="arg5" val="3"/>
<Int sr="arg6" val="1"/>
</Action>
<Action sr="act1" ve="7">
<code>547</code>
<label>append par2</label>
<Str sr="arg0" ve="3">%command</Str>
<Str sr="arg1" ve="3"> %par2</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="1"/>
<Int sr="arg5" val="3"/>
<Int sr="arg6" val="1"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%par2</lhs>
<op>12</op>
<rhs></rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act2" ve="7">
<code>1256900802</code>
<Bundle sr="arg0">
<Vals sr="val">
<com.termux.execute.arguments>%command</com.termux.execute.arguments>
<com.termux.execute.arguments-type>java.lang.String</com.termux.execute.arguments-type>
<com.termux.tasker.extra.BACKGROUND_CUSTOM_LOG_LEVEL>&lt;null&gt;</com.termux.tasker.extra.BACKGROUND_CUSTOM_LOG_LEVEL>
<com.termux.tasker.extra.BACKGROUND_CUSTOM_LOG_LEVEL-type>java.lang.String</com.termux.tasker.extra.BACKGROUND_CUSTOM_LOG_LEVEL-type>
<com.termux.tasker.extra.EXECUTABLE>termux-relay.py</com.termux.tasker.extra.EXECUTABLE>
<com.termux.tasker.extra.EXECUTABLE-type>java.lang.String</com.termux.tasker.extra.EXECUTABLE-type>
<com.termux.tasker.extra.SESSION_ACTION>&lt;null&gt;</com.termux.tasker.extra.SESSION_ACTION>
<com.termux.tasker.extra.SESSION_ACTION-type>java.lang.String</com.termux.tasker.extra.SESSION_ACTION-type>
<com.termux.tasker.extra.STDIN></com.termux.tasker.extra.STDIN>
<com.termux.tasker.extra.STDIN-type>java.lang.String</com.termux.tasker.extra.STDIN-type>
<com.termux.tasker.extra.TERMINAL>false</com.termux.tasker.extra.TERMINAL>
<com.termux.tasker.extra.TERMINAL-type>java.lang.Boolean</com.termux.tasker.extra.TERMINAL-type>
<com.termux.tasker.extra.VERSION_CODE>6</com.termux.tasker.extra.VERSION_CODE>
<com.termux.tasker.extra.VERSION_CODE-type>java.lang.Integer</com.termux.tasker.extra.VERSION_CODE-type>
<com.termux.tasker.extra.WAIT_FOR_RESULT>true</com.termux.tasker.extra.WAIT_FOR_RESULT>
<com.termux.tasker.extra.WAIT_FOR_RESULT-type>java.lang.Boolean</com.termux.tasker.extra.WAIT_FOR_RESULT-type>
<com.termux.tasker.extra.WORKDIR>&lt;null&gt;</com.termux.tasker.extra.WORKDIR>
<com.termux.tasker.extra.WORKDIR-type>java.lang.String</com.termux.tasker.extra.WORKDIR-type>
<com.twofortyfouram.locale.intent.extra.BLURB>termux-relay.py %command
Working Directory ✕
Stdin ✕
Custom Log Level null
Terminal Session ✕
Wait For Result ✓</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.RELEVANT_VARIABLES>&lt;StringArray sr=""&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;%stdout
Standard Output
The &amp;lt;B&amp;gt;stdout&amp;lt;/B&amp;gt; of the command.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;%stdout_original_length
Standard Output Original Length
The original length of &amp;lt;B&amp;gt;stdout&amp;lt;/B&amp;gt;.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;%stderr
Standard Error
The &amp;lt;B&amp;gt;stderr&amp;lt;/B&amp;gt; of the command.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;%stderr_original_length
Standard Error Original Length
The original length of &amp;lt;B&amp;gt;stderr&amp;lt;/B&amp;gt;.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES3&gt;&lt;_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;%result
Exit Code
The &amp;lt;B&amp;gt;exit code&amp;lt;/B&amp;gt; of the command.0 often means success and anything else is usually a failure of some sort.&lt;/_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES4&gt;&lt;/StringArray&gt;</net.dinglisch.android.tasker.RELEVANT_VARIABLES>
<net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>com.termux.tasker.extra.EXECUTABLE com.termux.execute.arguments com.termux.tasker.extra.WORKDIR com.termux.tasker.extra.STDIN com.termux.tasker.extra.SESSION_ACTION com.termux.tasker.extra.BACKGROUND_CUSTOM_LOG_LEVEL</net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>java.lang.String</net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">com.termux.tasker</Str>
<Str sr="arg2" ve="3">com.termux.tasker.EditConfigurationActivity</Str>
<Int sr="arg3" val="10"/>
<Int sr="arg4" val="0"/>
</Action>
<Action sr="act3" ve="7">
<code>129</code>
<label>trim trailing whitespace</label>
<Str sr="arg0" ve="3">var stdout = stdout.trimRight()</Str>
<Str sr="arg1" ve="3"/>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="45"/>
</Action>
<Action sr="act4" ve="7">
<code>126</code>
<Str sr="arg0" ve="3">%stdout</Str>
<Int sr="arg1" val="1"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Str sr="arg4" ve="3"/>
</Action>
</Task>
</TaskerData>
@davebrny
Copy link
Author

davebrny commented Jun 13, 2022

see termux-relay-py

Task: python termux >

<set par1>
A1: Variable Set [
     Name: %command
     To: %par1
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

<append par2>
A2: Variable Set [
     Name: %command
     To:  %par2
     Append: On
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]
    If  [ %par2 Set ]

A3: Termux [
     Configuration: termux-relay.py %command
     
     Working Directory ✕
     Stdin ✕
     Custom Log Level null
     Terminal Session ✕
     Wait For Result ✓
     Timeout (Seconds): 10 ]

<trim trailing whitespace>
A4: JavaScriptlet [
     Code: var stdout = stdout.trimRight()
     Auto Exit: On
     Timeout (Seconds): 45 ]

A5: Return [
     Value: %stdout
     Stop: On ]

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