Skip to content

Instantly share code, notes, and snippets.

@0mark
Last active October 13, 2021 15:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0mark/6282407 to your computer and use it in GitHub Desktop.
Save 0mark/6282407 to your computer and use it in GitHub Desktop.
Mount/unmount with dmenu
#!/bin/bash
##### CONFIG
DEVS=( "sd" "mmcblk" )
BLOCK=( "sda" )
#### DO NOT TOUCH
c=0
for i in $(mount | cut -d " " -f 1); do
mounted[$c]="$i"
let c++
done
for i in ${DEVS[@]}; do
for ii in /dev/${i}*; do
blocked=0
for iii in ${BLOCK[@]}; do
if [ $(echo $ii | grep $iii | wc -l) -gt 0 ]; then blocked=1; fi
done
for iii in ${mounted[@]}; do
if [ "$iii" == "$ii" ]; then blocked=1; fi
done
if [ $blocked -eq 0 ]; then
devices="${devices}${ii}\n"
fi
done
done
device=$(echo -e "${devices}" | dmenu $DMENUSETTINGS)
if [ -n "$device" ]; then
pmount $device
fi
#!/bin/bash
#### DO NOT TOUCH
for i in $(mount | grep /media | cut -d " " -f 1); do
devices="${devices}${i}\n"
done
device=$(echo -e "${devices}" | dmenu $DMENUSETTINGS)
if [ -n "$device" ]; then
pumount $device
fi
@Kipparis
Copy link

i, ii. iii such codestyle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment