Browse Source

Add music player keybindings

pull/6/head
Duarte Dias 5 months ago
committed by Damien Cassou
parent
commit
d8560e4fe9
Signed by: DamienCassou GPG Key ID: B68746238E59B548
2 changed files with 49 additions and 2 deletions
  1. +7
    -0
      README.org
  2. +42
    -2
      desktop-environment.el

+ 7
- 0
README.org View File

@ -69,6 +69,9 @@ keybinding if ~desktop-environment-mode~ is enabled:
| desktop-environment-lock-screen | ~s-l~ |
| desktop-environment-toggle-wifi | ~<XF86WLAN>~ |
| desktop-environment-toggle-bluetooth | ~<XF86Bluetooth>~ |
| desktop-environment-toggle-music | ~<XF86AudioPlay>~ |
| desktop-environment-music-previous | ~<XF86AudioPrev>~ |
| desktop-environment-music-next | ~<XF86AudioNext>~ |
** Configuration
@ -83,6 +86,7 @@ the package, the following system packages must be available on your system:
- Screenlock: [[https://tools.suckless.org/slock/][slock]]
- Keyboard backlight: [[https://upower.freedesktop.org/][upower]]
- Wifi and bluetooth: [[https://linrunner.de/en/tlp/tlp.html][TLP]]
- Music: [[https://github.com/altdesktop/playerctl][playerctl]]
*** Configuring desktop-environment
@ -115,6 +119,9 @@ customize-group RET desktop-environment RET~ to change them.
| ~desktop-environment-screenlock-command~ | Shell command locking the screen |
| ~desktop-environment-wifi-command~ | Shell command toggling wifi |
| ~desktop-environment-bluetooth-command~ | Shell command toggling bluetooth |
| ~desktop-environment-music-toggle-command~ | Shell command toggling the music player |
| ~desktop-environment-music-previous-command~ | Shell command for going to previous song |
| ~desktop-environment-music-next-command~ | Shell command for going to next song |
**** Using light instead of brightnessctl


+ 42
- 2
desktop-environment.el View File

@ -177,6 +177,21 @@ portion of the screen."
:type 'string)
;;; Customization - music
(defcustom desktop-environment-music-toggle-command "playerctl play-pause"
"Shell command toggling the music player."
:type 'string)
(defcustom desktop-environment-music-previous-command "playerctl previous"
"Shell command for going to previous song."
:type 'string)
(defcustom desktop-environment-music-next-command "playerctl next"
"Shell command for going to next song."
:type 'string)
;;; Customization - EXWM keybindings
(defcustom desktop-environment-update-exwm-global-keys :global
@ -387,7 +402,28 @@ the screen."
(interactive)
(let ((async-shell-command-buffer 'new-buffer))
(async-shell-command desktop-environment-bluetooth-command)))
;;; Commands - music
(defun desktop-environment-toggle-music ()
"Play/pause the music player."
(interactive)
(message "%s"
(shell-command-to-string desktop-environment-music-toggle-command)))
(defun desktop-environment-music-previous ()
"Play the previous song."
(interactive)
(message "%s"
(shell-command-to-string desktop-environment-music-previous-command)))
(defun desktop-environment-music-next()
"Play the next song."
(interactive)
(message "%s"
(shell-command-to-string desktop-environment-music-next-command)))
;;; Minor mode
(defvar desktop-environment-mode-map
@ -412,7 +448,11 @@ the screen."
;; Wifi controls
(,(kbd "<XF86WLAN>") . ,(function desktop-environment-toggle-wifi))
;; Bluetooth controls
(,(kbd "<XF86Bluetooth>") . ,(function desktop-environment-toggle-bluetooth))))
(,(kbd "<XF86Bluetooth>") . ,(function desktop-environment-toggle-bluetooth))
;; Music controls
(,(kbd "<XF86AudioPlay>") . ,(function desktop-environment-toggle-music))
(,(kbd "<XF86AudioPrev>") . ,(function desktop-environment-music-previous))
(,(kbd "<XF86AudioNext>") . ,(function desktop-environment-music-next))))
(map (make-sparse-keymap)))
(dolist (keybinding desktop-environment--keybindings)
(define-key map (car keybinding) (cdr keybinding)))


Loading…
Cancel
Save