-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_mont
More file actions
executable file
·134 lines (117 loc) · 2.43 KB
/
menu_mont
File metadata and controls
executable file
·134 lines (117 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env sh
# Autenticação utilizada
# Exemplo: sudo -A ou doas --
set -x
auth="doas_askpass"
menu="tofi --prompt-text"
[ -z "$WAYLAND_DISPLAY" ] && menu="dmenu -b -l 15 -p"
#config
mount_dir="/tmp"
# desmontar
desmontar() {
select=$(
grep "/mnt\|$mount_dir/" /proc/self/mounts |
cut -d " " -f2 |
sort |
$menu "desmontar"
)
[ -n "$select" ] &&
$auth umount "$select" &&
notify-send \
"desmontar" \
"$select desmontado" &&
rm -d "$select"
}
# montar usb
montar_usb() {
select="$(lsblk -rpo "name,type,size,mountpoint" |
awk '{ if ($2=="part"&&$4=="" || $2=="rom"&&$4=="" || $3=="1,4M"&&$4=="") printf "%s (%s)\n",$1,$3}' |
$menu "montar usb" |
cut -d " " -f1)"
[ -z "$select" ] &&
exit 0
mount_point="$HOME/mnt/usb"
partition_type="$(lsblk -no "fstype" "$select")"
[ ! -d "$mount_point" ] &&
mkdir "$mount_point" &&
case "$partition_type" in
vfat)
$auth mount -t "$partition_type" "$select" "$mount_point" -o rw,umask=0000
;;
exfat)
$auth mount "$select" "$mount_point" -o rw,umask=0000
;;
*)
$auth mount "$select" "$mount_point"
user="$(whoami)"
user_group="$(groups | cut -d " " -f1)"
$auth chown "$user":"$user_group" 741 "$mount_point"
;;
esac &&
notify-send \
"montar usb $partition_type" \
"$select montado em $mount_point"
}
# montar iso
montar_iso() {
search="$HOME/Downloads"
select=$(
find "$search" -type f \
-iname "*.iso" -o \
-iname "*.img" -o \
-iname "*.bin" -o \
-iname "*.mdf" -o \
-iname "*.nrg" |
cut -d / -f 5 |
$menu "montar iso"
)
[ -z "$select" ] &&
exit 0
mount_point="$HOME/mnt/iso"
set -x
[ ! -d "$mount_point" ] &&
mkdir "$mount_point"
$auth mount -o loop "$search/$select" "$mount_point" &&
notify-send \
"montar iso" \
"$select montado em $mount_point"
}
# montar android
montar_android() {
select=$(
simple-mtpfs -l 2>/dev/null |
$menu "montar android" |
cut -d ":" -f1
)
[ -z "$select" ] &&
exit 0
mount_point="$HOME/mnt/android"
[ ! -d "$mount_point" ] &&
mkdir "$mount_point" &&
simple-mtpfs --device "$select" "$mount_point" &&
notify-send \
"montar android" \
"$select montado em $mount_point"
}
# menu
case $(
printf "%s\n" \
"desmontar" \
"montar usb" \
"montar iso" \
"montar android" |
$menu ""
) in
"desmontar")
desmontar
;;
"montar usb")
montar_usb
;;
"montar iso")
montar_iso
;;
"montar android")
montar_android
;;
esac