fogine / udiskie-dmenu

Manage removable devices in couple of keystrokes!
MIT License
43 stars 5 forks source link

Return path of mounted drive #3

Open rien333 opened 5 years ago

rien333 commented 5 years ago

Great little app! I find the default mount path a bit troublesome to reach though (I know that I can run lsblk and copy/paste, but simpler solutions are def possible), so I was thinking about auto opening udiskie-dmenu mounts with a file manager/terminal. Turns out that there is no easy way to script this app.

Initially I wanted to open a PR to support auto-opening mounts in filemanagers, but I fortunately thought of the more elegant idea to just return the path of the mount point. In this way, users can script their own udiskie-dmenu behaviors on basis of the returned path, which is totally inline with the dmenu philosophy. (ofc, the default behaviour of dmenu itself is just to return the selected output)

For example:

#!/usr/bin/fish
set path (udiskie-dmenu) 
if lsblk | grep $path
   kitty -d  $path # open a terminal with the wd of the mount path
end
fogine commented 5 years ago

I think, its a good idea. The output will have to be a little bit more complex than that though as the user can select multiple paths or the whole device with multiple partitions to umout/mount at once.
Meaning that the output of udiskie-dmenu should provide a collection of mounted paths (I dont see how it could be beneficial to also provide a collection of umounted paths at the moment)

rien333 commented 5 years ago

Hm, that seems reasonable. I'm not aware of how to select more than one item in dmenu, but maybe I'm missing something. I would implement this myself, but unfortunately my node/js is a bit rusty.

fogine commented 5 years ago

I'm not aware of how to select more than one item in dmenu

dmenu can be compiled with multi-select feature, users of rofi have also multi-select capabilities. Even without the multi-select feature when you have a device with multiple partitions, udiskie-dmenu will show this:

/dev/sdc  : DeviceName
/dev/sdc1 : DevicePartitionLabel
/dev/sdc2 : DevicePartitionLabel

In that case when you select the first option which represents the whole device, not just a single partition, udiskie-dmenu will operate on all device partitions, mounting or umounting them depending on its state.

Your particular case would be perhaps better solved if you hooked up directly to udiskie.
From its man pages:

-f PROGRAM, --file-manager=PROGRAM Set program to open mounted directories. Default is 'xdg-open'.

So when you run udiskie as a daemon on system startup and specify your script under --file-manager option, it should work:

eg. in your .xinitrc

udiskie --file-manager /path/to/your/executable &