-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcmus.py
46 lines (37 loc) · 1.41 KB
/
cmus.py
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
from ranger.api.commands import *
def get_files(fm):
ftd = fm.thisdir
selected_files = ftd.get_selection()
active_file = fm.thisfile if not selected_files else None
if not selected_files and not active_file:
return
else:
file_objs = selected_files if selected_files else [active_file]
return file_objs
class cmus_play(Command):
def execute(self):
""" Add selected files or folders to playlist """
file_objs = get_files(self.fm)
cmus = ["cmus-remote"]
cmus.extend([f.path for f in file_objs])
self.fm.execute_command(cmus)
self.fm.notify("Files were sent to cmus playlist")
self.fm.thisdir.mark_all(False)
class cmus_queue(Command):
def execute(self):
""" Add selected files or folders to queue """
file_objs = get_files(self.fm)
cmus = ["cmus-remote", "-q"]
cmus.extend([f.path for f in file_objs])
self.fm.execute_command(cmus)
self.fm.notify("Files were sent to cmus queue")
self.fm.thisdir.mark_all(False)
class cmus_lib(Command):
def execute(self):
""" Add selected files or folders to library """
file_objs = get_files(self.fm)
cmus = ["cmus-remote", "-l"]
cmus.extend([f.path for f in file_objs])
self.fm.execute_command(cmus)
self.fm.notify("Files were sent to cmus library")
self.fm.thisdir.mark_all(False)