Created
October 21, 2021 07:08
-
-
Save iAmGroute/3badb30c228837efd47f6a5221544457 to your computer and use it in GitHub Desktop.
XbindKey guile config for volume controls with extra mouse button (button 8, normally 'back')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This configuration is guile based. | |
;; https://www.gnu.org/software/guile/learn/ | |
;; Based on the awesome script created by Zero Angel: | |
;; https://www.linuxquestions.org/questions/linux-desktop-74/%5Bxbindkeys%5D-advanced-mouse-binds-4175428297/ | |
;; We'll need a named pipe later, because we can't share FDs | |
(if (not (file-exists? ".xbindkey.pipe")) | |
(run-command "mkfifo .xbindkey.pipe") | |
(sleep 1) | |
) | |
;; In case we want to force the file type: | |
;; (if (not (eq? (stat:type (stat ".xbindkey.pipe")) 'fifo)) (exit 1)) | |
;; Run xte to execute key presses | |
(run-command "xte <.xbindkey.pipe") | |
;; Action | |
(define fo (open-file ".xbindkey.pipe" "w0")) | |
(define has_scrolled 0) | |
;; Extra mouse button | |
(xbindkey-function '("b:8") (lambda () | |
;; This seems to be needed to avoid duplicate calls after a single press | |
(remove-all-keys) | |
;; Scroll Up | |
(xbindkey-function '("b:4") (lambda () | |
(display "key XF86AudioRaiseVolume\n" fo) | |
(set! has_scrolled 1) | |
)) | |
;; Scroll Down | |
(xbindkey-function '("b:5") (lambda () | |
(display "key XF86AudioLowerVolume\n" fo) | |
(set! has_scrolled 1) | |
)) | |
;; Released | |
(xbindkey-function '(release "b:8") (lambda () | |
(if (= has_scrolled 0) (display "key XF86AudioMute\n" fo)) | |
(set! has_scrolled 0) | |
)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment