aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/init/ycp-emms.el
blob: a3a460435c26a749d7f10112c821f5c3ac2f3659 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
;;; ycp-emms.el -- My configs for multimedia -*- lexical-binding: t -*-

;; Copyright (C) 2023 Free Software Foundation.

;; Author: Yuchen Pei <id@ypei.org>
;; Package-Requires: ((emacs "28.2"))

;; This file is part of dotfiles.

;; dotfiles is free software: you can redistribute it and/or modify it under
;; the terms of the GNU Affero General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; dotfiles is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
;; Public License for more details.

;; You should have received a copy of the GNU Affero General Public
;; License along with dotfiles.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; My configs for multimedia.

;;; Code:

;;; emms is only loaded when `my-profile' is emms, see early-init.el
(my-package emms
  (:install t)
  (require 'emms-setup)
  ;; FIXME: only enable what i use
  (emms-all)
  (setq emms-playing-time-resume-from-last-played t)
  (add-to-list 'emms-info-functions 'emms-info-ytdl)
  ;; emms-info-native is not very useful
  (delete 'emms-info-native emms-info-functions)
  (setq emms-source-file-default-directory (locate-user-emacs-file "emms"))
  (setq emms-source-playlist-default-format 'native)
  (setq emms-repeat-playlist t)
  (my-keybind emms-playlist-mode-map "C-x C-f" #'emms-play-playlist)
  (setq emms-player-list '(emms-player-mpv emms-player-vlc))
  (setq emms-player-vlc-parameters '("--intf=qt" "--extraintf=rc"))
  (setq emms-playlist-buffer-name "*EMMS Playlist*")
  (setq emms-source-file-directory-tree-function
        'emms-source-file-directory-tree-find)
  (setq emms-info-ytdl-using-torsocks t)
  (add-hook 'emms-playlist-mode-hook #'hl-line-mode)
  (add-hook 'emms-metaplaylist-mode-hook #'hl-line-mode)
  )

(my-package my-emms
  (my-setq-from-local my-emms-playlist-alist)
  (my-keybind global-map
    "C-c s t" #'my-emms-mpv-toggle-torsocks
    "C-c s SPC" #'my-emms-switch-to-playlist-buffer
    "C-c s v" #'my-emms-mpv-toggle-video
    "<XF86AudioPause>" #'emms-pause
    "<XF86AudioPlay>" #'emms-pause
    "<XF86AudioNext>" #'emms-next
    "<XF86AudioPrev>" #'emms-seek-backward
    "C-c s a" #'emms-add-all
    "C-c s s" #'emms
    "C-c s S" #'my-emms-save-all
    "C-c s e" #'emms-metaplaylist-mode-go
    "C-c s m" #'emms-mode-line-toggle
    "C-c s n" #'emms-next
    "C-c s r" #'emms-random
    "C-c s p" #'my-emms-print-current-track-display-name
    "C-c s f"	#'my-emms-append-current-track-to-favourites
    "C-c s F" #'emms-append-current-track-name-to-file
    "C-c s P" #'emms-pause
    "C-c s u" #'emms-add-url
    "C-c s o" #'my-emms-add-url-region
    "C-c s y" #'my-emms-add-ytdl-playlist
    "C-c s w" #'my-emms-kill-current-track-name
    )
  (my-keybind emms-playlist-mode-map
    "s" #'my-emms-playlist-save-current-buffer
    "C-<return>" #'my-emms-playlist-mode-make-current
    "w" #'my-emms-playlist-kill-track-name-at-point
    "D" #'my-emms-playlist-delete-at-point
    "R" #'my-emms-random-album
    "N" #'my-emms-next-track-or-random-album
    )
  (add-hook 'emms-player-started-hook 'my-emms-maybe-seek-to-last-played)
  (my-override emms-mode-line-enable)
  (my-override emms-mode-line-disable)
  (my-override emms-mode-line-toggle)
  (add-hook 'emms-playlist-selection-changed-hook
            'my-emms-output-current-track-to-i3bar-file)
  (setq emms-player-next-function 'my-emms-next-track-or-random-album)
  (setq emms-players-preference-f 'my-emms-players-preference)
  (my-keybind dired-mode-map "e" #'my-dired-add-to-emms)
  (my-override emms-track-simple-description)
  (my-emms-add-all)
  )

(provide 'ycp-emms)