forked from mirrors/ranger_udisk_menu
readme
This commit is contained in:
parent
2b52ada098
commit
7882eca61b
3 changed files with 39 additions and 7 deletions
34
README.md
Normal file
34
README.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Ranger udisk menu
|
||||
This script draws menu to mount and unmount partitions using udisksctl and ncurses
|
||||
|
||||
# Requirements
|
||||
- python3
|
||||
- udisks2 (for udisksctl)
|
||||
- lsblk
|
||||
|
||||
# How to install
|
||||
Firstly you need to clone this repo to ranger config directory
|
||||
|
||||
```Bash
|
||||
cd ~/.config/ranger
|
||||
git clone https://github.com/SL-RU/ranger_udisk_menu
|
||||
```
|
||||
|
||||
Then you need to add to `commands.py` line:
|
||||
|
||||
```Python3
|
||||
from ranger_udisk_menu.mounter import mount
|
||||
```
|
||||
|
||||
Thats all
|
||||
|
||||
# How to use
|
||||
Enter in ranger `:mount`, than will be shown menu. In this menu you can press:
|
||||
|
||||
- `j` or `arrow down` or `Ctrl+n` to move selection down
|
||||
- `k` or `arrow up` or `Ctrl+p` to move selection up
|
||||
- `Ctrl+g` or `Esc` or `q` to quit
|
||||
- `g` or `r` to refresh all partitions and drives
|
||||
- `m` to mount selected partition
|
||||
- `u` to unmount selected partition
|
||||
- `e` to unmount all partitions of selected partition's drive
|
12
menu.py
12
menu.py
|
@ -58,7 +58,7 @@ class ChoosePartition:
|
|||
self.screen.border(0)
|
||||
self.screen.addstr(
|
||||
2, 2,
|
||||
"Press 'm' to mount and 'u' to unmount and 'e' to unmount whole drive")
|
||||
"Press 'm' to mount and 'u' to unmount and 'e' to unmount whole drive" + str(x))
|
||||
|
||||
partn = 0
|
||||
i = 0
|
||||
|
@ -106,21 +106,20 @@ class ChoosePartition:
|
|||
def select(self):
|
||||
sel = None
|
||||
x = 0
|
||||
while x != ord('q'):
|
||||
# quit when pressed `q` or `Esc` or `Ctrl+g`
|
||||
while x != ord('q') and x != 27 and x != 7:
|
||||
self._select_print(x)
|
||||
x = self.screen.getch()
|
||||
|
||||
if x == ord('j') or x == 66 or x == 14:
|
||||
# down
|
||||
self.selected_partn += 1
|
||||
if self.selected_partn > self.partn:
|
||||
self.selected_partn = self.partn
|
||||
elif x == ord('k') or x == 65 or x == 16:
|
||||
# up
|
||||
self.selected_partn -= 1
|
||||
if self.selected_partn <= 0:
|
||||
self.selected_partn = 1
|
||||
elif x == 10:
|
||||
sel = self._get_part_by_partn()
|
||||
break
|
||||
elif x == ord('e'):
|
||||
sel = self._eject_all()
|
||||
elif x == ord('m'):
|
||||
|
@ -134,7 +133,6 @@ class ChoosePartition:
|
|||
elif x == ord('g') or x == ord('r'):
|
||||
self._read_partitions()
|
||||
curses.endwin()
|
||||
return sel
|
||||
|
||||
def _udisk_mount_unmount(self, cmd, dev):
|
||||
r = ""
|
||||
|
|
Loading…
Add table
Reference in a new issue