Created
October 20, 2013 10:09
-
-
Save fgiobergia/7067502 to your computer and use it in GitHub Desktop.
Touchpad switch, for enabling/disabling the touchpad (using xinput)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
/* | |
* `xinput list` shows a list | |
* of devices from which you | |
* can get your device's id. | |
*/ | |
#define DEVICE 12 | |
int main () { | |
FILE *pp; | |
int v; | |
char line[512],cmd[32]; | |
sprintf (cmd, "xinput list-props %d",DEVICE); | |
pp = popen (cmd,"r"); | |
while (fgets(line,sizeof(line),pp)) { | |
if (strstr (line,"Device Enabled")) { | |
sscanf (strchr(line,':')+1,"%d",&v); | |
if (v) { | |
// Enabled (switch do Disabled) | |
sprintf (cmd,"xinput disable %d",DEVICE); | |
pclose(popen(cmd,"r")); | |
} | |
else { | |
// Disabled (switch to Enabled) | |
sprintf(cmd,"xinput enable %d",DEVICE); | |
pclose(popen(cmd,"r")); | |
} | |
break; | |
} | |
} | |
pclose (pp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment