mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Added doas support
This commit is contained in:
parent
828c052184
commit
3c797d82da
@ -12,21 +12,21 @@ getmount() { \
|
|||||||
test -z "$mp" && exit 1
|
test -z "$mp" && exit 1
|
||||||
if [ ! -d "$mp" ]; then
|
if [ ! -d "$mp" ]; then
|
||||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || $elev mkdir -p "$mp")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mountusb() { \
|
mountusb() { \
|
||||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
$elev mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||||
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||||
case "$partitiontype" in
|
case "$partitiontype" in
|
||||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
"vfat") $elev mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||||
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
|
"exfat") $elev mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
|
||||||
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
*) $elev mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; $elev chown "$user":"$ug" "$mp";;
|
||||||
esac
|
esac
|
||||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||||
}
|
}
|
||||||
@ -51,6 +51,11 @@ asktype() { \
|
|||||||
|
|
||||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||||
|
if [ $(command -v sudo) ]; then
|
||||||
|
elev="sudo -A"
|
||||||
|
else
|
||||||
|
elev="doas"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$usbdrives" ]; then
|
if [ -z "$usbdrives" ]; then
|
||||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||||
|
|||||||
@ -9,13 +9,13 @@ unmountusb() {
|
|||||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
[ -z "$chosen" ] && exit
|
[ -z "$chosen" ] && exit
|
||||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
$elev umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||||
}
|
}
|
||||||
|
|
||||||
unmountandroid() { \
|
unmountandroid() { \
|
||||||
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||||
[ -z "$chosen" ] && exit
|
[ -z "$chosen" ] && exit
|
||||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
$elev umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||||
}
|
}
|
||||||
|
|
||||||
asktype() { \
|
asktype() { \
|
||||||
@ -26,7 +26,12 @@ asktype() { \
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}')
|
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||||
|
if [ $(command -v sudo) ]; then
|
||||||
|
elev="sudo -A"
|
||||||
|
else
|
||||||
|
elev="doas"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! grep simple-mtpfs /etc/mtab; then
|
if ! grep simple-mtpfs /etc/mtab; then
|
||||||
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user