Disk : Add unlock function.

This commit is contained in:
Dmitry Voronin 2024-04-15 17:58:37 +03:00 committed by Dmitry Voronin
parent 4b293ac1e9
commit 7e8d23496b
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -11,5 +11,20 @@
function tdu() {
du -sh --si "''${@}"
}
# Unlock encrypted disk file.
# Usage: unlock <FILE>
function unlock() {
_filter() {
sed -e "s/.*\ a[st]\ //" -e "s/\.$//"
}
local file="''${1}"
local name=$(parse_alnum ''${file} | _filter)
local loop=$(udisksctl loop-setup -f "''${file}" | _filter)
local unlock=$(udisksctl unlock -b "''${loop}" | _filter)
local mount=$(udisksctl mount -b "''${unlock}" | _filter)
cd "''${mount}"
}
'';
}