linput

Listen to input events
git clone git://git.akobets.xyz/linput
Log | Files | Refs | README | LICENSE

config.def.h (2446B)


      1 static char *cmd_sleep[] = { "sudo", "zzz", NULL };
      2 static char *cmd_openterminal[] = { "st", NULL };
      3 static char *cmd_volumeup[] = { "amixer", "-qM", "sset", "Master", "2%+", NULL };
      4 static char *cmd_volumedown[] = { "amixer", "-qM", "sset", "Master", "2%-", NULL };
      5 
      6 static struct EventRule {
      7   /* set cmd as NULL to disable the rule */
      8   char **cmd;
      9   /* see <linux/input-event-codes.h>
     10    * for type/code/value available values */
     11   int type;
     12   int code;
     13   int value;
     14 } events[] = {
     15   /* suspend system when lid is closed */
     16   {
     17     cmd_sleep,
     18     EV_SW, SW_LID, 1
     19   }
     20 };
     21 
     22 enum {
     23   MOD_ANY         = 0x0001, /* any modifiers */
     24   MOD_SHIFT       = 0x0002, /* left or right shift */
     25   MOD_LEFTSHIFT   = 0x0004,
     26   MOD_RIGHTSHIFT  = 0x0008,
     27   MOD_CTRL        = 0x0010, /* left or right ctrl */
     28   MOD_LEFTCTRL    = 0x0020,
     29   MOD_RIGHTCTRL   = 0x0040,
     30   MOD_SUPER       = 0x0080, /* left or right super */
     31   MOD_LEFTSUPER   = 0x0100,
     32   MOD_RIGHTSUPER  = 0x0200,
     33   MOD_ALT         = 0x0400, /* left or right alt */
     34   MOD_LEFTALT     = 0x0800,
     35   MOD_RIGHTALT    = 0x1000
     36 } HotkeyMod;
     37 
     38 enum {
     39   ON_RELEASE = 0x01,
     40   ON_PRESS   = 0x02,
     41   ON_HOLD    = 0x04
     42 } HotkeyEvent;
     43 
     44 #define HOTKEY_MAX_KEYS  10
     45 
     46 static struct HotkeyRule {
     47   /* set cmd as NULL to disable the rule */
     48   char **cmd;
     49   int mod_mask;
     50   /* see <linux/input-event-codes.h> for complete list
     51    * (KEY_* constants)
     52    * end with 0 */
     53   int keys[HOTKEY_MAX_KEYS + 1];
     54   int event_mask;
     55 } hotkeys[] = {
     56   /* open terminal on Super + C */
     57   {
     58     cmd_openterminal,
     59     MOD_SUPER,
     60     { KEY_C, 0 },
     61     ON_PRESS,
     62   },
     63   /* open terminal on Super + E + 1 */
     64   {
     65     cmd_openterminal,
     66     MOD_SUPER,
     67     { KEY_E, KEY_1, 0 },
     68     ON_PRESS,
     69   },
     70   /* increase volume on Volume Up */
     71   {
     72     cmd_volumeup,
     73     0,
     74     { KEY_VOLUMEUP, 0 },
     75     ON_PRESS | ON_HOLD
     76   },
     77   /* decrease volume on Volume Down */
     78   {
     79     cmd_volumedown,
     80     0,
     81     { KEY_VOLUMEDOWN, 0 } ,
     82     ON_PRESS | ON_HOLD
     83   },
     84 };
     85 
     86 /* keys, pressing which shouldn't block hotkeys */
     87 static int ignored_keys[] = {
     88   /* touchpad events */
     89   BTN_TOOL_FINGER,
     90   BTN_TOUCH,
     91   BTN_TOOL_DOUBLETAP,
     92   BTN_TOOL_TRIPLETAP,
     93   BTN_TOOL_QUADTAP,
     94   BTN_TOOL_QUINTTAP,
     95   /* mouse events */
     96   BTN_MOUSE,
     97   BTN_LEFT,
     98   BTN_RIGHT,
     99   BTN_MIDDLE
    100 };
    101 
    102 /* A key, pressing which will reset hotkey state.
    103  * For rare cases when input event detection misbehaves
    104  * (e.g. on system suspend/resume).
    105  * Set to 0 for no reset key. */
    106 static int reset_key = 0;