Skip to content

Commit

Permalink
RunCommand: Set TOUCHEGG_GESTURE_ON environment variable
Browse files Browse the repository at this point in the history
To allow custom scripts to know if the command is ran when the gesture
begins, updates or ends, set a environment variable.
  • Loading branch information
JoseExposito committed Dec 1, 2024
1 parent f71c321 commit 8d41d09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ Example 1:
<gesture type="SWIPE" fingers="4" direction="DOWN">
<action type="RUN_COMMAND">
<repeat>false</repeat>
<command>notify-send 'Hello World' "Swipe down, DEVICE_TYPE=$TOUCHEGG_DEVICE_TYPE"</command>
<command>notify-send 'Hello World' "Swipe down, DEVICE_TYPE=$TOUCHEGG_DEVICE_TYPE TOUCHEGG_GESTURE_ON=$TOUCHEGG_GESTURE_ON"</command>
<on>begin</on>
</action>
</gesture>
Expand Down
11 changes: 11 additions & 0 deletions src/actions/run-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "animations/animation-factory.h"

void RunCommand::onGestureBegin(const Gesture &gesture) {
setenv("TOUCHEGG_GESTURE_ON", "begin", 1);
RepeatedAction::onGestureBegin(gesture);

if (!this->animate) {
Expand All @@ -38,6 +39,16 @@ void RunCommand::onGestureBegin(const Gesture &gesture) {
}
}

void RunCommand::onGestureUpdate(const Gesture &gesture) {
setenv("TOUCHEGG_GESTURE_ON", "update", 1);
RepeatedAction::onGestureUpdate(gesture);
}

void RunCommand::onGestureEnd(const Gesture &gesture) {
setenv("TOUCHEGG_GESTURE_ON", "end", 1);
RepeatedAction::onGestureEnd(gesture);
}

void RunCommand::executePrelude() {
if (this->settings.count("command") == 1) {
this->command = this->settings.at("command");
Expand Down
2 changes: 2 additions & 0 deletions src/actions/run-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class RunCommand : public RepeatedAction {
public:
using RepeatedAction::RepeatedAction;
void onGestureBegin(const Gesture &gesture) override;
void onGestureUpdate(const Gesture &gesture) override;
void onGestureEnd(const Gesture &gesture) override;
bool runOnSystemWindows() override { return true; }
void executePrelude() override;
void executeAction(const Gesture &gesture) override;
Expand Down

0 comments on commit 8d41d09

Please sign in to comment.