2021-04-25 18:25:47 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# coding: utf-8
|
|
|
|
# License: The MIT License
|
2021-04-25 18:32:45 +02:00
|
|
|
# Author: Alexander Lutsai <sl_ru@live.com>
|
2021-04-25 18:25:47 +02:00
|
|
|
# Year: 2021
|
|
|
|
# Description: This launches script that draws menu to choose, mount and unmount drives from ranger file manager
|
|
|
|
|
|
|
|
from ranger.api.commands import Command
|
2021-06-11 14:47:46 +02:00
|
|
|
import tempfile
|
|
|
|
import os
|
2021-04-25 18:25:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
class mount(Command):
|
|
|
|
""":mount
|
|
|
|
|
|
|
|
Show menu to mount and unmount
|
|
|
|
"""
|
|
|
|
def execute(self):
|
|
|
|
""" Show menu to mount and unmount """
|
2021-06-11 14:47:46 +02:00
|
|
|
(f, p) = tempfile.mkstemp()
|
|
|
|
os.close(f)
|
2022-07-25 12:31:12 +02:00
|
|
|
self.fm.execute_console(
|
|
|
|
f"shell python3 {os.path.dirname(os.path.realpath(__file__))}/menu.py {p}"
|
|
|
|
)
|
2021-06-11 14:47:46 +02:00
|
|
|
with open(p, 'r') as f:
|
|
|
|
d = f.readline()
|
|
|
|
if os.path.exists(d):
|
|
|
|
self.fm.cd(d)
|
|
|
|
os.remove(p)
|