Skip to content

Commit 7d50f25

Browse files
committed
Add --no-left-right feature
1 parent 79d47ec commit 7d50f25

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

karrowswitch.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using std::signal;
2626
// ------------------------------------------------- GLOBALS
2727

2828
bool DEBUG;
29+
bool NO_LEFT_RIGHT_ARROWS;
2930

3031
// ------------------------------------------------- X11/XTEST ENGINE
3132

@@ -170,6 +171,8 @@ void handle(KeyCode key, bool isPressed) {
170171
auto isArrowForward = (key == KEY_DOWN || key == KEY_RIGHT);
171172
auto isArrowBackward = (key == KEY_UP || key == KEY_LEFT);
172173
auto isArrow = isArrowBackward || isArrowForward;
174+
if (NO_LEFT_RIGHT_ARROWS)
175+
isArrow = key == KEY_DOWN || key == KEY_UP;
173176

174177
if (!isPressed && isAlt) {
175178
if (DEBUG)
@@ -206,15 +209,19 @@ void handle(KeyCode key, bool isPressed) {
206209
int main (int argc, char *argv[]) {
207210
// parse args
208211
if (argc == 0) {
209-
cout << "Usage: karrowswitch [-d]";
210-
cout << "Runs as a daemon unless -d flag is set" << endl;
212+
cout << "Usage: karrowswitch [-d] [--no-left-right]";
213+
cout << " Runs as a daemon unless -d flag is set" << endl;
214+
cout << " --no-left-right ignores left/right arrow keys" << endl;
211215
return 0;
212216
}
217+
NO_LEFT_RIGHT_ARROWS = false;
213218
DEBUG = false;
214219
for (int i = 0; i < argc; ++i) {
215220
string arg = argv[i];
216221
if (arg == "-d")
217222
DEBUG = true;
223+
else if (arg == "--no-left-right")
224+
NO_LEFT_RIGHT_ARROWS = true;
218225
}
219226
// go !
220227
if (!DEBUG)

0 commit comments

Comments
 (0)