Merge branch 'iStagnant-master'
This commit is contained in:
commit
6c92dfa4eb
2 changed files with 30 additions and 17 deletions
|
@ -3,26 +3,36 @@
|
||||||
# Mounts Android Phones and USB drives (encrypted or not). This script will
|
# Mounts Android Phones and USB drives (encrypted or not). This script will
|
||||||
# replace the older `dmenumount` which had extra steps and couldn't handle
|
# replace the older `dmenumount` which had extra steps and couldn't handle
|
||||||
# encrypted drives.
|
# encrypted drives.
|
||||||
# TODO: Remove already mounted Android phones from prompt.
|
|
||||||
# TODO: Try decrypt for drives in crtypttab
|
# TODO: Try decrypt for drives in crtypttab
|
||||||
# TODO: Add some support for connecting iPhones (although they are annoying).
|
# TODO: Add some support for connecting iPhones (although they are annoying).
|
||||||
|
|
||||||
set -e
|
IFS='
|
||||||
|
'
|
||||||
|
# Function for escaping cell-phone names.
|
||||||
|
escape(){ echo "$@" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g" ;}
|
||||||
|
|
||||||
# Check for phones.
|
# Check for phones.
|
||||||
phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/📱/")"
|
phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/📱/")"
|
||||||
|
mountedphones="$(grep "simple-mtpfs" /etc/mtab)"
|
||||||
|
# If there are already mounted phones, remove them from the list of mountables.
|
||||||
|
[ -n "$mountedphones" ] && phones="$(for phone in $phones; do
|
||||||
|
for mounted in $mountedphones; do
|
||||||
|
escphone="$(escape "$phone")"
|
||||||
|
[[ "$mounted" =~ "$escphone" ]] && break 1
|
||||||
|
done && continue 1
|
||||||
|
echo "$phone"
|
||||||
|
done)"
|
||||||
|
|
||||||
# Check for drives.
|
# Check for drives.
|
||||||
lsblkoutput="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,fstype")"
|
lsblkoutput="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,fstype")"
|
||||||
# Get all LUKS drives
|
# Get all LUKS drives
|
||||||
allluks="$(echo "$lsblkoutput" | grep crypto_LUKS)" || true
|
allluks="$(echo "$lsblkoutput" | grep crypto_LUKS)"
|
||||||
# Get a list of the LUKS drive UUIDs already decrypted.
|
# Get a list of the LUKS drive UUIDs already decrypted.
|
||||||
decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed "s|.*LUKS2-||;s|-.*||")" || true
|
decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed "s|.*LUKS2-||;s|-.*||")"
|
||||||
# Functioning for formatting drives correctly for dmenu:
|
# Functioning for formatting drives correctly for dmenu:
|
||||||
filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6}' ; }
|
filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6}' ; }
|
||||||
|
|
||||||
# Get only LUKS drives that are not decrypted.
|
# Get only LUKS drives that are not decrypted.
|
||||||
IFS='
|
|
||||||
'
|
|
||||||
unopenedluks="$(for drive in $allluks; do
|
unopenedluks="$(for drive in $allluks; do
|
||||||
uuid="${drive%% *}"
|
uuid="${drive%% *}"
|
||||||
uuid="${uuid//-}" # This is a bashism.
|
uuid="${uuid//-}" # This is a bashism.
|
||||||
|
@ -39,6 +49,10 @@ normalparts="$(echo "$lsblkoutput"| grep -v crypto_LUKS | grep 'part\|rom\|crypt
|
||||||
alldrives="$(echo "$phones
|
alldrives="$(echo "$phones
|
||||||
$unopenedluks
|
$unopenedluks
|
||||||
$normalparts" | sed "/^$/d;s/ *$//")"
|
$normalparts" | sed "/^$/d;s/ *$//")"
|
||||||
|
|
||||||
|
# Quit the script if a sequential command fails.
|
||||||
|
set -e
|
||||||
|
|
||||||
test -n "$alldrives"
|
test -n "$alldrives"
|
||||||
|
|
||||||
# Feed all found drives to dmenu and get user choice.
|
# Feed all found drives to dmenu and get user choice.
|
||||||
|
@ -92,9 +106,9 @@ case "$chosen" in
|
||||||
📱*)
|
📱*)
|
||||||
notify-send "❗Note" "Remember to allow file access on your phone now."
|
notify-send "❗Note" "Remember to allow file access on your phone now."
|
||||||
getmount
|
getmount
|
||||||
chosen="${chosen%%:*}"
|
number="${chosen%%:*}"
|
||||||
chosen="${chosen:1}" # This is a bashism.
|
number="${chosen:1}" # This is a bashism.
|
||||||
sudo -A simple-mtpfs -o allow_other --device "$chosen" "$mp"
|
sudo -A simple-mtpfs -o allow_other -o fsname="simple-mtpfs-$(escape "$chosen")" --device "$number" "$mp"
|
||||||
notify-send "🤖 Android Mounted." "Android device mounted to $mp."
|
notify-send "🤖 Android Mounted." "Android device mounted to $mp."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -8,7 +8,6 @@ vidlist="
|
||||||
dwm (window manager) https://videos.lukesmith.xyz/videos/watch/f6b78db7-b368-4647-bc64-28c08fff1988
|
dwm (window manager) https://videos.lukesmith.xyz/videos/watch/f6b78db7-b368-4647-bc64-28c08fff1988
|
||||||
dwmblocks (status bar) https://videos.lukesmith.xyz/w/mmxHMbqZZEr5FManB57Yy1
|
dwmblocks (status bar) https://videos.lukesmith.xyz/w/mmxHMbqZZEr5FManB57Yy1
|
||||||
pacman (installing/managing programs) https://videos.lukesmith.xyz/videos/watch/8e7cadb9-0fed-47ce-a2a8-6635fa48614b
|
pacman (installing/managing programs) https://videos.lukesmith.xyz/videos/watch/8e7cadb9-0fed-47ce-a2a8-6635fa48614b
|
||||||
status bar https://videos.lukesmith.xyz/videos/watch/a4d5326b-0aac-496e-bfc3-5acd5cee89f0
|
|
||||||
sxiv (image viewer) https://videos.lukesmith.xyz/videos/watch/ad4c8d85-90c3-4f3d-a1f3-89129e64a3c2
|
sxiv (image viewer) https://videos.lukesmith.xyz/videos/watch/ad4c8d85-90c3-4f3d-a1f3-89129e64a3c2
|
||||||
st (terminal) https://videos.lukesmith.xyz/videos/watch/efddd39d-bac5-4599-b572-177beb4ce6e8
|
st (terminal) https://videos.lukesmith.xyz/videos/watch/efddd39d-bac5-4599-b572-177beb4ce6e8
|
||||||
i3 (old window manager) https://videos.lukesmith.xyz/videos/watch/b861525c-7ada-40ee-a2bb-b5e1ffe0f48b
|
i3 (old window manager) https://videos.lukesmith.xyz/videos/watch/b861525c-7ada-40ee-a2bb-b5e1ffe0f48b
|
||||||
|
|
Loading…
Reference in a new issue