From ff900d0b98da3aa7673b7b09268a7e89c3f9d97f Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Fri, 12 Jul 2024 16:09:06 +0200 Subject: [PATCH] nushell: add some udisksctl helper subcommands --- .config/nushell/conf.d/99-udisks.nu | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .config/nushell/conf.d/99-udisks.nu diff --git a/.config/nushell/conf.d/99-udisks.nu b/.config/nushell/conf.d/99-udisks.nu new file mode 100644 index 0000000..90936b7 --- /dev/null +++ b/.config/nushell/conf.d/99-udisks.nu @@ -0,0 +1,18 @@ +def "udisksctl lockmount" [--block-device (-b): path] { + let cryptdev = udisksctl unlock -b $block_device | parse "{_} as {dev}." | get 0.dev + udisksctl mount -b $cryptdev +} + +def "udisksctl lockumount" [--block-device (-b): path] { + let plain_dev = udisksctl info -b $block_device | parse -r "CleartextDevice: +'(?P.*)'" | get 0.dev + + # This is borked on the udisksctl side + #udisksctl unmount -p $plain_dev + (dbus call --system + --dest org.freedesktop.UDisks2 + $plain_dev + org.freedesktop.UDisks2.Filesystem + Unmount []) + + udisksctl lock -b $block_device +}