shithub: riscv

Download patch

ref: c5f79f5371b3735ac4498343182fb9596b7809fe
parent: b38a3d2a0d0f2022bab40eec4975179daa0ceee1
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Oct 6 15:56:01 EDT 2022

reform/shortcuts: use media keys for LCD brightness control

--- a/sys/man/1/reform
+++ b/sys/man/1/reform
@@ -145,23 +145,21 @@
 reform/shortcuts </dev/kbdtap >/dev/kbdtap
 .EE
 .PP
-.I Super+F1/F2
+.I Hyper+F1/F2
 decreases/increases LCD brightness,
 .I Hyper+F7/F8/F9
 skips to the previous track, (un)pauses or skips to the next track in
 .IR zuke (1),
-.I Hyper+F11/F12
-decreases/increases "master" volume,
 .I Hyper+F10
-(un)mutes the audio.
-Optionally, a single step amount can be set with
+(un)mutes the audio,
+.I Hyper+F11/F12
+decreases/increases "master" volume.  Optionally, a single step amount
+can be set with
 .I -l
 for LCD light level (default is 5) and
 .I -v
 for volume (default is 3).  Values can be negative to essentially swap
-.I F1
-with
-.IR F2 .
+the decrement and increment keys.
 .SH SOURCE
 .B /sys/src/cmd/reform
 .SH SEE ALSO
--- a/sys/src/cmd/reform/shortcuts.c
+++ b/sys/src/cmd/reform/shortcuts.c
@@ -4,7 +4,7 @@
 #include <plumb.h>
 
 static int lightstep = 5, volstep = 3;
-static int light, vol, actl, mod;
+static int light, vol, actl;
 
 static void
 aplumb(char *s)
@@ -12,11 +12,8 @@
 	int f;
 
 	if((f = plumbopen("send", OWRITE)) >= 0){
-		if(plumbsendtext(f, "shortcuts", "audio", "/", s) < 0)
-			fprint(2, "aplumb: %r\n");
+		plumbsendtext(f, "shortcuts", "audio", "/", s);
 		close(f);
-	}else{
-		fprint(2, "aplumb: %r\n");
 	}
 }
 
@@ -29,8 +26,6 @@
 
 	o = 0;
 	b[o++] = *s;
-	if(*s == 'k' || *s == 'K')
-		mod = utfrune(s+1, Kmod4) != nil;
 
 	for(p = s+1; *p != 0; p += n){
 		if((n = chartorune(&r, p)) == 1 && r == Runeerror){
@@ -42,27 +37,25 @@
 			break;
 		}
 
-		skip = 0;
-		if(*s == 'c'){
-			if(mod){
-				if(skip |= (r == (KF|1)))
-					fprint(light, "lcd %+d", -lightstep);
-				else if(skip |= (r == (KF|2)))
-					fprint(light, "lcd %+d", lightstep);
-			}else{
-				if(skip |= (r == Kvoldn))
-					fprint(vol, "master %+d", -volstep);
-				else if(skip |= (r == Kvolup))
-					fprint(vol, "master %+d", volstep);
-				else if(skip |= (r == Kmute))
-					fprint(actl, "master toggle");
-				else if(skip |= (r == Ksbwd))
-					aplumb("key <");
-				else if(skip |= (r == Ksfwd))
-					aplumb("key >");
-				else if(skip |= (r == Kpause))
-					aplumb("key p");
-			}
+		if(skip = (*s == 'c')){
+			if(r == Kbrtdn)
+				fprint(light, "lcd %+d", -lightstep);
+			else if(r == Kbrtup)
+				fprint(light, "lcd %+d", lightstep);
+			else if(r == Kvoldn)
+				fprint(vol, "master %+d", -volstep);
+			else if(r == Kvolup)
+				fprint(vol, "master %+d", volstep);
+			else if(r == Kmute)
+				fprint(actl, "master toggle");
+			else if(r == Ksbwd)
+				aplumb("key <");
+			else if(r == Ksfwd)
+				aplumb("key >");
+			else if(r == Kpause)
+				aplumb("key p");
+			else
+				skip = 0;
 		}
 
 		if(!skip){