Search code examples
hotkeysawesome-wm

Power Button in awful.key


How can I set an action to powerbutton on my laptop? I tried to use awful.key({ }, "Power",... but it doesn't work.


Solution

  • Try running xev in a terminal and see what it says for the key press. For example, I have a calculator key on my keyboard and it seems to be XF86Calculator:

    KeyRelease event, serial 37, synthetic NO, window 0x2400001,
        root 0x761, subw 0x0, time 179605294, (572,728), root:(2493,769),
        state 0x10, keycode 148 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
        XLookupString gives 0 bytes: 
        XFilterEvent returns: False
    

    Here are some random guesses on what the key name might be:

    $ grep -r Power /usr/include/X11 
    /usr/include/X11/Xtrans/Xtranslcl.c: *  Pittsburgh Powercomputing Corporation (PPc)/Quarterdeck Office Systems
    /usr/include/X11/XF86keysym.h:#define XF86XK_PowerDown  0x1008FF21   /* Deep sleep the system      */
    /usr/include/X11/XF86keysym.h:#define XF86XK_PowerOff       0x1008FF2A   /* Power off system entirely  */
    /usr/include/X11/Sunkeysym.h:#define SunXK_PowerSwitch      0x1005FF76
    /usr/include/X11/Sunkeysym.h:#define SunXK_PowerSwitchShift     0x1005FF7D