-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmounter.py
32 lines (26 loc) · 809 Bytes
/
mounter.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
#!/usr/bin/python3
# coding: utf-8
# License: The MIT License
# Author: Alexander Lutsai <sl_ru@live.com>
# Year: 2021
# Description: This launches script that draws menu to choose, mount and unmount drives from ranger file manager
import os
import tempfile
from ranger.api.commands import Command
class mount(Command):
""":mount
Show menu to mount and unmount
"""
def execute(self):
"""Show menu to mount and unmount"""
(f, p) = tempfile.mkstemp()
os.close(f)
self.fm.execute_console(
f"shell python3 {os.path.dirname(os.path.realpath(__file__))}/blkmenu "
f"--tmpfile {p}"
)
with open(p, "r") as f:
d = f.readline()
if os.path.exists(d):
self.fm.cd(d)
os.remove(p)