[hackers] [dwm][PATCH] Add keys to control monitor backlight using xbackligh

From: Gonzalo G. Fernandez <fernandez.gfg_AT_gmail.com>
Date: Sat, 11 Apr 2020 02:27:33 -0300

From: Gonzalo G. Fernández <fernandez.gfg_AT_gmail.com>

---
 config.def.h | 5 +++++
 dwm.c        | 1 +
 2 files changed, 6 insertions(+)
diff --git a/config.def.h b/config.def.h
index 1c0b587..aa2a149 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -58,6 +58,9 @@ static const Layout layouts[] = {
 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
 static const char *termcmd[]  = { "st", NULL };
+static char xbacklight_perc[2] = "5";
+static const char *xbacklighcmd_inc[] = { "xbacklight", "-inc", xbacklight_perc, NULL };
+static const char *xbacklighcmd_dec[] = { "xbacklight", "-dec", xbacklight_perc, NULL };
 
 static Key keys[] = {
 	/* modifier                     key        function        argument */
_AT_@ -84,6 +87,8 @@ static Key keys[] = {
 	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
 	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
 	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
+	{ 0,           XF86XK_MonBrightnessUp,     spawn,          {.v = xbacklighcmd_inc} },
+	{ 0,           XF86XK_MonBrightnessDown,   spawn,          {.v = xbacklighcmd_dec} },
 	TAGKEYS(                        XK_1,                      0)
 	TAGKEYS(                        XK_2,                      1)
 	TAGKEYS(                        XK_3,                      2)
diff --git a/dwm.c b/dwm.c
index 4465af1..c5307c0 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -40,6 +40,7 @@
 #include <X11/extensions/Xinerama.h>
 #endif /* XINERAMA */
 #include <X11/Xft/Xft.h>
+#include <X11/XF86keysym.h>
 
 #include "drw.h"
 #include "util.h"
-- 
2.26.0
Received on Sat Apr 11 2020 - 07:27:33 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 11 2020 - 07:48:36 CEST