Commit 2339f03d authored by Brandon Invergo's avatar Brandon Invergo

Add another NI AK1 example

parent d99efe45
(use-modules (librekontrol core)
(librekontrol device)
(librekontrol input)
(librekontrol alsa)
((librekontrol devices ni-ak1) #:prefix ak1:)
(ice-9 popen)
(ice-9 rdelim))
(define (playerctl-playing?)
(let* ((playerctl-port (open-input-pipe "playerctl status"))
(playerctl-status (read-line playerctl-port)))
(close-pipe playerctl-port)
(equal? playerctl-status "Playing")))
(configure-device
#:alsa-name ak1:alsa-name
#:input-name ak1:input-name
#:remap-events (list (make-input-event ev-key key-1)
(make-input-event ev-key key-2)
(make-input-event ev-key key-space)
(make-input-event ev-key key-a)
(make-input-event ev-key key-p)
(make-input-event ev-key key-leftctrl))
#:controls (list (list ak1:left system-button
#:cmd "playerctl previous")
(list ak1:middle (make-system-button-toggle
(playerctl-playing?))
#:on-cmd "playerctl play"
#:off-cmd "playerctl pause")
(list ak1:right system-button
#:cmd "playerctl next")
(list ak1:knob (make-abs-knob-to-button)
#:neg-event-code key-a
#:pos-event-code key-p
#:pos-mod-keys (list key-leftctrl)
#:knob-max (ak1:knob-max)
#:invert #t))
#:idle-wait 0.5
#:idle-hooks (list (lambda ()
(set-ctl (control-alsa-ctl ak1:knob) #f)))
#:exit-hooks (list (lambda ()
(turn-off-ctls
(map control-alsa-ctl
(list ak1:left ak1:middle ak1:right ak1:knob)))))
#:init (list (if (playerctl-playing?)
(set-ctl (control-alsa-ctl ak1:middle) #t))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment