File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,15 @@ static void close_restricted(int fd, void *user_data) {
15
15
close (fd );
16
16
}
17
17
18
- int main () {
18
+ int main (int argc , char * argv []) {
19
+ char * cmd_tablet = "echo tablet" ;
20
+ char * cmd_laptop = "echo laptop" ;
21
+
22
+ if (argc >= 2 )
23
+ cmd_tablet = cmd_laptop = argv [1 ];
24
+ if (argc >= 3 )
25
+ cmd_laptop = argv [2 ];
26
+
19
27
if (geteuid ()) {
20
28
fprintf (stderr , "Error: this utility requires root privileges (did you forget `sudo`?)\n" );
21
29
return 1 ;
@@ -49,8 +57,9 @@ int main() {
49
57
if (libinput_event_get_type (event ) != LIBINPUT_EVENT_SWITCH_TOGGLE ) continue ;
50
58
struct libinput_event_switch * switch_event = libinput_event_get_switch_event (event );
51
59
if (libinput_event_switch_get_switch (switch_event ) != LIBINPUT_SWITCH_TABLET_MODE ) continue ;
52
- const char switch_on = libinput_event_switch_get_switch_state (switch_event ) == LIBINPUT_SWITCH_STATE_ON ;
53
- printf ("%s\n" , switch_on ? "TABLET" : "LAPTOP" );
60
+ const char tablet_mode = libinput_event_switch_get_switch_state (switch_event ) == LIBINPUT_SWITCH_STATE_ON ;
61
+ if (!fork ())
62
+ exit (system (tablet_mode ? cmd_tablet : cmd_laptop ));
54
63
libinput_event_destroy (event );
55
64
}
56
65
}
You can’t perform that action at this time.
0 commit comments