From 7882eca61be64e86968c000ef51e1b43be658379 Mon Sep 17 00:00:00 2001 From: Alexander Lutsai Date: Sun, 25 Apr 2021 21:11:15 +0300 Subject: [PATCH] readme --- README.md | 34 ++++++++++++++++++++++++++++++++++ menu.py | 12 +++++------- readme.md | 0 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 README.md delete mode 100644 readme.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b7aac7 --- /dev/null +++ b/README.md @@ -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 diff --git a/menu.py b/menu.py index 0575dc0..8ae52ce 100644 --- a/menu.py +++ b/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 = "" diff --git a/readme.md b/readme.md deleted file mode 100644 index e69de29..0000000