Last active
October 13, 2021 15:18
-
-
Save 0mark/6282407 to your computer and use it in GitHub Desktop.
Mount/unmount with dmenu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i
,ii
.iii
such codestyle