Skip to content

Instantly share code, notes, and snippets.

@0mark
Last active Oct 13, 2021
Embed
What would you like to do?
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

Kipparis commented Mar 16, 2020

i, ii. iii such codestyle

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