Advertisement
Guest User

Untitled

a guest
Jul 10th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 4.59 KB | None | 0 0
  1. (define-configuration/no-serialization interception-tools-configuration
  2.   (package
  3.    (file-like interception-tools)
  4.    "The interception-tools package to use.")
  5.   (udevmon-jobs
  6.    (list-of-strings '())
  7.    "The jobs that the udevmon daemon should be configured to run."))
  8.  
  9. (define (interception-tools-shepherd-service config)
  10.   (list
  11.    (shepherd-service
  12.     (documentation "Run interception-tools udevmon daemon.")
  13.     (provision '(interception-tools))
  14.     (requirement '(user-processes))
  15.     (start #~(make-forkexec-constructor
  16.               (list #$(file-append coreutils "/bin/nice") "-n" "-20"
  17.                     #$(file-append interception-tools "/bin/udevmon") "-c" "/etc/interception/udevmon.yml")
  18.               #:log-file "/var/log/interception-tools.log"))
  19.     (stop #~(make-kill-destructor)))))
  20.  
  21. (define (interception-tools-config-file config)
  22.   "Return the udevmon configuration file corresponding to CONFIG."
  23.   (list
  24.    (list
  25.     "interception/udevmon.yml"
  26.     (computed-file "udevmon.yml"
  27.                    #~(begin
  28.                        (call-with-output-file #$output
  29.                          (lambda (port)
  30.                            (display "# Generated by 'interception-tools-service'.\n" port)
  31.                            (for-each (lambda (job) (format port "~a\n" job))
  32.                                      '#$(interception-tools-configuration-udevmon-jobs config)))))))))
  33.  
  34. (define (interception-tools-profile config)
  35.   (list (interception-tools-configuration-package config)))
  36.  
  37. (define interception-tools-service-type
  38.   (service-type
  39.    (name 'interception-tools)
  40.    (description
  41.     "Run @command{udevmon} daemon.")
  42.    (extensions
  43.     (list
  44.      (service-extension shepherd-root-service-type interception-tools-shepherd-service)
  45.      (service-extension etc-service-type interception-tools-config-file)
  46.      (service-extension profile-service-type interception-tools-profile)))
  47.    (compose concatenate)
  48.    (extend
  49.     (lambda (config udevmon-jobs)
  50.       (interception-tools-configuration
  51.        (inherit config)
  52.        (udevmon-jobs (append (interception-tools-configuration-udevmon-jobs config) udevmon-jobs)))))
  53.    (default-value (interception-tools-configuration))))
  54.  
  55. (define-configuration/no-serialization interception-dual-function-keys-configuration
  56.   (package
  57.    (file-like interception-dual-function-keys)
  58.    "The interception-dual-function-keys package to use.")
  59.   (mappings
  60.    (list-of-strings '())
  61.    "The mappings that dual-function-keys should be configured to run.")
  62.   (keys
  63.    (string "")
  64.    "The keys for which the udevmon job should be triggered."))
  65.  
  66. (define (interception-dual-function-keys-config-file config)
  67.   "Return the dual-function-keys configuration file corresponding to CONFIG."
  68.   (list
  69.    (list
  70.     "interception/dual-function-keys.yml"
  71.     (computed-file "dual-function-keys.yml"
  72.                    #~(begin
  73.                        (call-with-output-file #$output
  74.                          (lambda (port)
  75.                            (display "# Generated by 'interception-dual-function-keys-service'.\n" port)
  76.                            (for-each (lambda (mapping) (format port "~a\n" mapping))
  77.                                      '#$(interception-dual-function-keys-configuration-mappings config)))))))))
  78.  
  79. (define (interception-dual-function-keys-job config)
  80.   (list
  81.    (string-append
  82.     "- JOB: \"" "/run/current-system/profile/bin/intercept" " -g $DEVNODE | "
  83.     "/run/current-system/profile/bin/dual-function-keys"
  84.     " -c /etc/interception/dual-function-keys.yml | "
  85.     "/run/current-system/profile/bin/uinput"" -d $DEVNODE\"
  86.  DEVICE:
  87.    EVENTS:
  88.      EV_KEY: \"" (interception-dual-function-keys-configuration-keys config) "\"")))
  89.  
  90. (define (interception-dual-function-keys-profile config)
  91.   (list (interception-dual-function-keys-configuration-package config)))
  92.  
  93. (define interception-dual-function-keys-service-type
  94.   (service-type
  95.    (name 'interception-dual-function-keys)
  96.    (description
  97.     "Run @command{dual-function-keys} via @command{udevmon} daemon.")
  98.    (extensions
  99.     (list
  100.      (service-extension interception-tools-service-type interception-dual-function-keys-job)
  101.      (service-extension etc-service-type interception-dual-function-keys-config-file)
  102.      (service-extension profile-service-type interception-dual-function-keys-profile)))))
  103.  
  104. (define dual-function-key-setup
  105.   (interception-dual-function-keys-configuration
  106.    (mappings '("\
  107. TIMING:
  108.    TAP_MLLISEC: 400
  109.    DOUBLE_TAP_MILLISEC: 0
  110.  
  111. MAPPINGS:
  112.    - KEY: KEY_CAPSLOCK
  113.      TAP: KEY_ESC
  114.      HOLD: KEY_LEFTCTRL"))
  115.    (keys "[KEY_CAPSLOCK]")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement