blob: cc91aa7d35c88ef73b02354a62bf0d364e7f725c (
plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
;; -*- lexical-binding: t -*-
;;; utilities
(defun jao-mixer-get-level (&optional dev nomsg)
(interactive)
(let* ((dev (or dev "Master"))
(s (shell-command-to-string (format "amixer sget %s" dev)))
(s (car (last (split-string s "\n" t)))))
(when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s)
(let ((level (match-string 1 s)))
(unless nomsg (message "%s level: %s%%" dev level))
(string-to-number level)))))
(defun jao-mixer-set (dev v)
(jao-shell-exec* t "amixer" "sset" dev v)
(jao-mixer-get-level dev))
(defun jao-mixer-master-toggle ()
(interactive)
(jao-mixer-set "Master" "toggle"))
(defun jao-mixer-master-up ()
(interactive)
(jao-mixer-set "Master" "10%+"))
(defun jao-mixer-master-down ()
(interactive)
(jao-mixer-set "Master" "10%-"))
(defun jao-mixer-capture-up ()
(interactive)
(jao-mixer-set "Capture" "10%+"))
(defun jao-mixer-capture-down ()
(interactive)
(jao-mixer-set "Capture" "10%-"))
(jao-shell-def-exec jao-audio-applet "pasystray")
(defun jao-toggle-audio-applet ()
(interactive)
(or (jao-shell-kill-p "paystray") (jao-audio-applet)))
(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet)
;;; streaming aliases
(defalias 'jao-streaming-list #'ignore)
(defalias 'jao-streaming-like #'ignore)
(defalias 'jao-streaming-dislike #'ignore)
(defalias 'jao-streaming-toggle-shuffle #'ignore)
(defalias 'jao-streaming-lyrics #'ignore)
(defalias 'jao-streaming-toggle #'ignore)
(defalias 'jao-streaming-next #'ignore)
(defalias 'jao-streaming-prev #'ignore)
(defalias 'jao-streaming-current #'ignore)
(defalias 'jao-streaming-seek #'ignore)
(defalias 'jao-streaming-seek-back #'ignore)
(defalias 'jao-streaming-volume #'ignore)
(defalias 'jao-streaming-volume-down #'ignore)
(defun jao-toggle-pasystray-applet ()
(interactive)
(or (jao-shell-kill-p "pasystray") (jao-shell-exec "pasystray")))
(transient-define-prefix jao-transient-streaming ()
[:description
(lambda () (format "Streaming using %s" jao-mpris-player))
["Search" :if jao-mpris-mopidy-p
("a" "album" jao-streaming-album)
("A" "artist" jao-streaming-artist)
("t" "track" jao-streaming-track)
("P" "playlist" jao-streaming-playlist)]
["Play"
("s" "toggle" jao-streaming-toggle)
("n" "next" jao-streaming-next)
("p" "previous" jao-streaming-prev)
("T" "toggle player" jao-streaming-toggle-player)]
["Seek & shout"
("f" "seek fwd" jao-streaming-seek :transient t)
("F" "seek bwd" jao-streaming-seek-back :transient t)
("u" "up" jao-streaming-volume :transient t)
("d" "down" jao-streaming-volume-down :transient t)]
["Browse"
("l" "playing list" j
ao-streaming-list :if jao-mpris-mopidy-p)
("L" "lyrics" jao-streaming-lyrics)
("w" "currently playing" jao-streaming-current)]
["Act" :if jao-mpris-mopidy-p
("k" "like" jao-streaming-like)
("K" "dislike" jao-streaming-dislike)
("S" "toggle shuffle" jao-streaming-toggle-shuffle)]])
;;; mpris
(defun jao-mpris-lyrics (&optional force)
(interactive "P")
(jao-show-lyrics force #'jao-mpris-artist-title))
(defun jao-mpris-mopidy-p () (string= "mopidy "jao-mpris-player))
(defun jao-mpc-mopidy-playlist ()
(interactive)
(jao-mpc-show-playlist jao-mopidy-port))
(use-package jao-mpris :demand t)
(defun jao-mpris-setup-aliases ()
(setq espotify-play-uri-function #'espotify-play-uri-with-dbus)
;; (setq jao-mpris-player "mopidy")
(defalias 'jao-streaming-list #'jao-mpc-mopidy-playlist)
(defalias 'jao-streaming-lyrics #'jao-mpris-lyrics)
(defalias 'jao-streaming-toggle #'jao-mpris-play-pause)
(defalias 'jao-streaming-next #'jao-mpris-next)
(defalias 'jao-streaming-prev #'jao-mpris-previous)
(defalias 'jao-streaming-current #'jao-mpris-show-osd)
(defalias 'jao-streaming-seek #'jao-mpris-seek)
(defalias 'jao-streaming-seek-back #'jao-mpris-seek-back)
(defalias 'jao-streaming-volume #'jao-mpris-vol)
(defalias 'jao-streaming-volume-down #'jao-mpris-vol-down))
(jao-mpris-register "playerctld" :session 70)
;;; - provide
(provide 'jao-custom-multimedia)
|