summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdmount21
1 files changed, 19 insertions, 2 deletions
diff --git a/dmount b/dmount
index 8b0b2b7..0aeb89f 100755
--- a/dmount
+++ b/dmount
@@ -14,10 +14,14 @@ error_msg () {
exit 1
}
-while getopts "xwhd:" o; do case "${o}" in
+while getopts "xwhpPugd:" o; do case "${o}" in
x) DMENU="dmenu" ;;
w) DMENU="bemenu" ;;
d) ARGS="$ARGS $OPTARG" ;;
+ p) USE_USER_ID="y" ;;
+ P) unset USE_USER_ID ;;
+ u) USERID="$OPTARG" ;;
+ g) GROUPID="$OPTARG" ;;
h)
printhelp
exit
@@ -87,7 +91,20 @@ getmount() { \
mount_device () {
getmount "/mnt /media /mount /home -maxdepth 3 -type d -empty $alreadymounted"
- doas mount "$1" "$mp" && show "Mounted successfully\n"
+ if [ -z "$USE_USER_ID" ]; then
+ doas mount "$1" "$mp" && show "Mounted successfully\n"
+ else
+ if [ -n "$USERID" -a -n "$GROUPID" ]; then
+ MOUNTPROPS="uid=$USERID,gid=$GROUPID"
+ elif [ -n "$USERID" ]; then
+ MOUNTPROPS="uid=$USERID"
+ elif [ -n "$GROUPID" ]; then
+ MOUNTPROPS="gid=$GROUPID"
+ else
+ MOUNTPROPS="$(grep "$(whoami)" /etc/passwd | sed 's/:/ /g' | awk '{print "uid="$3",gid="$4}')"
+ fi
+ doas mount -o "$MOUNTPROPS" "$1" "$mp" && show "Mounted successfully\n"
+ fi
}
DEVICE="$(get_available | $DMENU -p "Devices" $ARGS -l 15)"