You are not logged in.

#1 2018-10-03 01:56:30

sbg
Member
Registered: 2018-06-15
Posts: 2

Brightness keybinding issue in dwm

My machine is lenovo T480s

I have the following set up in my dwm config.h

/* key definitions */
#define XF86MonBrightnessDown           0x1008ff03
#define XF86MonBrightnessUp                0x1008ff02
...
...
/* commands */
static const char *cmdbrightnessup[]  = { "sudo", "brightness", "up", NULL };
static const char *cmdbrightnessdown[]  = { "sudo", "brightness", "down", NULL };
...
...
static Key keys[] = {
 /* modifier                     key        function        argument */

{ 0,                       XF86MonBrightnessDown, spawn,   {.v = cmdbrightnessdown } },
{ 0,                       XF86MonBrightnessUp, spawn,     {.v = cmdbrightnessup } },

I have confirmed the keysym using xev and when I hold press alt+F5 i get:

KeyRelease event, serial 37, synthetic NO, window 0x1800001,
    root 0x16a, subw 0x0, time 76079393, (1331,272), root:(1332,301),
    state 0x8, keycode 232 (keysym 0x1008ff03, XF86MonBrightnessDown), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

And for alt+F6:

KeyPress event, serial 37, synthetic NO, window 0x1800001,
    root 0x16a, subw 0x0, time 76080899, (1331,272), root:(1332,301),
    state 0x8, keycode 233 (keysym 0x1008ff02, XF86MonBrightnessUp), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

I have this script in my /usr/bin:

 #!/bin/bash
 if [ "$EUID" -ne 0 ]
 then
          echo "Please run $0 as root"
          exit
  fi
 
  bd=/sys/devices/pci0000:00/0000:00:02.0/drm/card*/card*-eDP-1/intel_backlight/bri
  ghtness
 
  bdv=$(cat $bd)
 
  case $1 in
          up)
                  echo $(( bdv + 100 )) > $bd
                  cat $bd
          ;;
          down)
                  echo $(( bdv - 100 )) > $bd
                  cat $bd
          ;;
          *)
          echo "$bdv"
  esac

When I run sudo brightness up it works and turns the brightness up so the issue must be in the key bindings but everything here checks out. Any one have any suggestions as to why this may not be working?? Its driving me nuts.

Offline

#2 2018-10-03 02:09:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,142
Website

Re: Brightness keybinding issue in dwm

Did you configure sudo to run that script with no password?  What's on dwm's stdout/stderr (likely directed to the controlling tty if you don't redirect it)?

If so, are you sure your edits to config.h were actually used?  How do you compile/install dwm?  Generally, xev will not report the keysym for keys that are grabbed by the WM (so your xev output suggests that DWM didn't grab those keys).

Last edited by Trilby (2018-10-03 02:11:01)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-10-03 02:27:54

sbg
Member
Registered: 2018-06-15
Posts: 2

Re: Brightness keybinding issue in dwm

I didn't edit the sudoers file for /usr/bin/brightness.... doh! Thank you so much!! Works great now.

Offline

Board footer

Powered by FluxBB