ref: 90062b313490bdc16705eb1fb6fdf0a94ce23788
parent: 6c18febc1e3d06756604df5384809e120e2ab521
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Feb 19 07:01:08 EST 2021
emulate key presses by parsing "key KEYS" plumb message from audio port
--- a/README.md
+++ b/README.md
@@ -57,6 +57,11 @@
bind /dev/null /mnt/plumb/audio
+To remote control zuke, you can emulate pressing keys through plumber
+(ugh!):
+
+ plumb -d audio 'key >' # will skip to the next song
+
## Formats
The ones supported with stock 9front: mp3, ogg/vorbis, flac, wav.
--- a/zuke.c
+++ b/zuke.c
@@ -1099,19 +1099,26 @@
}
static void
-plumbaudio(void *)
+plumbaudio(void *kbd)
{
int i, f, pf;
Playlist *p;
Plumbmsg *m;
char *s, *e;
+ Rune c;
threadsetname("audio/plumb");
if((f = plumbopen("audio", OREAD)) >= 0){
while((m = plumbrecv(f)) != nil){
s = m->data;
+ if(strncmp(s, "key", 3) == 0 && isspace(s[3])){
+ for(s = s+4; isspace(*s); s++);
+ for(; (i = chartorune(&c, s)) > 0 && c != Runeerror; s += i)
+ sendul(kbd, c);
+ continue;
+ }
if(*s != '/' && m->wdir != nil)
- s = smprint("%s/%s", m->wdir, m->data);
+ s = smprint("%s/%.*s", m->wdir, m->ndata, m->data);
if((e = strrchr(s, '.')) != nil && strcmp(e, ".plist") == 0 && (pf = open(s, OREAD)) >= 0){
p = readplist(pf);
@@ -1243,7 +1250,7 @@
scrolling = 0;
themetid = -1;
- proccreate(plumbaudio, nil, 4096);
+ proccreate(plumbaudio, kctl->c, 4096);
for(;;){
ev: