aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rwxr-xr-xpkgs/by-name/au/aumo/aumo.sh16
-rw-r--r--pkgs/by-name/au/aumo/package.nix6
2 files changed, 15 insertions, 7 deletions
diff --git a/pkgs/by-name/au/aumo/aumo.sh b/pkgs/by-name/au/aumo/aumo.sh
index dba5ef63..824d817a 100755
--- a/pkgs/by-name/au/aumo/aumo.sh
+++ b/pkgs/by-name/au/aumo/aumo.sh
@@ -25,18 +25,24 @@ usage() {
echo "Usage: $NAME mount|unmount"
}
+is_label_mounted() {
+ label="$1"
+
+ findmnt --output label --json | jq --arg label "$label" '.filesystems | map(.label) | sort | unique | map(select(. != null)) | index($label) != null'
+}
+
get_mounted_labels() {
findmnt --output label --json | jq '.filesystems | map(.label) | sort | unique | map(select(. != null))'
}
get_unmounted_labels() {
first=true
- find /dev/disk/by-label -printf "%P\n" | while read -r label; do
- if ! get_mounted_labels | jq 'join("\n")' --raw-output | grep "$label" --quiet; then
+ fd . /dev/disk/by-label --format "{/.}" | while read -r label; do
+ if ! [ "$(is_label_mounted "$label")" = true ]; then
if [ "$first" = "true" ]; then
first=false
else
- printf "|"
+ printf "\0"
fi
printf "%s" "$label"
fi
@@ -44,13 +50,13 @@ get_unmounted_labels() {
}
unmounting() {
- disk_name="$(get_mounted_labels | jq 'join("|")' --join-output | rofi -sep "|" -dmenu -p "Select disk to unmount")"
+ disk_name="$(get_mounted_labels | jq 'join("\u0000")' --join-output | rofi -sep "\0" -dmenu -p "Select disk to unmount" | sed 's/ /\\x20/')"
udisksctl unmount --block-device "/dev/disk/by-label/$disk_name"
}
mounting() {
- disk_name="$(get_unmounted_labels | rofi -sep "|" -dmenu -p "Select disk to mount")"
+ disk_name="$(get_unmounted_labels | rofi -sep "\0" -dmenu -p "Select disk to mount")"
udisksctl mount --block-device "/dev/disk/by-label/$disk_name"
}
diff --git a/pkgs/by-name/au/aumo/package.nix b/pkgs/by-name/au/aumo/package.nix
index 8132a15a..c3c2f3ca 100644
--- a/pkgs/by-name/au/aumo/package.nix
+++ b/pkgs/by-name/au/aumo/package.nix
@@ -10,12 +10,13 @@
{
writeShellApplication,
# Dependencies
+ fd,
udisks,
- findutils,
rofi,
jq,
gnugrep,
util-linux,
+ gnused,
}:
writeShellApplication {
name = "aumo";
@@ -23,10 +24,11 @@ writeShellApplication {
inheritPath = false;
runtimeInputs = [
udisks
- findutils
+ fd
rofi
jq
gnugrep
util-linux # for findmnt
+ gnused
];
}