After making a new file in sudoers.d, I allowed sudo udisksctl in some ways
without password. Read the steps carefully in order to do that:
https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password
It uses vi by default btw. Some additional info:
https://wiki.archlinux.org/index.php/Sudo#Sudoers_default_file_permissions
This script works like a charm (tried with several drives at the same time):
#!/bin/bash
udisksctl unmount -b /dev/sdb1 && sudo udisksctl power-off -b /dev/sdb1
udisksctl unmount -b /dev/sdb2 && sudo udisksctl power-off -b /dev/sdb2
udisksctl unmount -b /dev/sdb3 && sudo udisksctl power-off -b /dev/sdb3
udisksctl unmount -b /dev/sdc1 && sudo udisksctl power-off -b /dev/sdc1
udisksctl unmount -b /dev/sdc2 && sudo udisksctl power-off -b /dev/sdc2
udisksctl unmount -b /dev/sdc3 && sudo udisksctl power-off -b /dev/sdc3
I could make a very similar one to mount the plugged in drives, then launch
those 2 scripts with dmenu as needed. I need to test that without the polkit
tweaks though.
Now udev might be great to clean this ugly code.