repo: music action: commit revision: path_from: revision_from: f009dd800111a1f904831e1a0c6e651e7f8e37be: path_to: revision_to:
commit f009dd800111a1f904831e1a0c6e651e7f8e37be Author: epochDate: Sat Aug 20 23:34:41 2022 -0500 keyboard /dev/input/event listener and script to run scripts based on key-codes passed from it to $1 (with xargs) diff --git a/extra/handler b/extra/handler new file mode 100755 index 0000000000000000000000000000000000000000..2690d3486fe6858b2e298d151275c3fe6d4063ba --- /dev/null +++ b/extra/handler @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +case "$1" in +115) + volume + & + ;; +114) + volume - & + ;; +163) + music-next & + ;; +165) + music-prev & + ;; +166) + music-stop & + ;; +164) + music-playpause & + ;; +*) + echo "unhandled" + ;; +esac diff --git a/extra/kdie.c b/extra/kdie.c new file mode 100644 index 0000000000000000000000000000000000000000..7e439268f6b7e0a6470a25a41032e7a64b916869 --- /dev/null +++ b/extra/kdie.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +int main(int argc,char *argv[]) { + struct input_event ie; + int kbfd; + if(argc < 2) { + fprintf(stderr,"usage: kdie \n"); + return 1; + } + if((kbfd=open(argv[1],O_RDWR)) == -1) { + fprintf(stderr,"# failed to open keyboard: %s\n",argv[1]); + return 2; + } + setlinebuf(stdout); + while(read(kbfd,&ie,sizeof(ie)) > 0) { + if(ie.type != 1) continue; + if(ie.code == 0) continue; + if(ie.value == 0) printf("-%d\n",ie.code); //release + if(ie.value == 1) printf("%d\n",ie.code); //press + if(ie.value == 2) printf("%d+\n",ie.code); //repeated from being held down + } + close(kbfd); + return 0; +}
-----END OF PAGE-----