slitaz-tools view tinyutils/mountbox @ rev 443

mountbox: few gui changes
author Rohit Joshi <jozee@slitaz.org>
date Fri Mar 19 11:49:42 2010 +0000 (2010-03-19)
parents d8c2f18f96c2
children 0005f89b44dd
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box for the mount/umount commands. Part of SliTaz tools.
4 # libmountbox: /usr/lib/slitaz/libmountbox
5 #
6 # (C) 2009 - SliTaz GNU/Linux project.
7 #
8 VERSION=20090802
9 # Mountbox is only for root.
10 if test $(id -u) != 0 ; then
11 exec subox mountbox
12 exit 0
13 fi
15 # Commom mount point in /mnt
16 mkdir -p /mnt/harddisk
18 # Just basic help.
19 export HELP='
20 <window title="Mountbox - Help" icon-name="help">
21 <vbox>
22 <text use-markup="true" width-chars="56">
23 <label>"
24 <b>SliTaz Mountbox - Help</b>"
25 </label>
26 </text>
28 <frame English>
29 <text wrap="true" use-markup="true">
30 <label>
31 "Mountbox lets you mount devices on mount points. A device
32 can be a cdrom, flash key, USB disk or local HD partition.
33 Mount points are generated from /media and /mnt.
34 "
35 </label>
36 </text>
37 </frame>
38 <frame Français>
39 <text wrap="true" use-markup="true">
40 <label>
41 "Mountbox permet de monter des périphériques (devices)
42 sur des points de montage. Un device peut être un cdrom,
43 une clé USB ou un disque dur local. La liste des points
44 de montage est généré depuis /media te /mnt.
45 "
46 </label>
47 </text>
48 </frame>
50 <hbox>
51 <button ok>
52 <action type="closewindow">HELP</action>
53 </button>
54 </hbox>
55 </vbox>
56 </window>'
58 # Mount and umount buttons with fiel for devive and mount point.
59 MAIN_DIALOG='
60 <window title="Mountbox" icon-name="media-flash">
61 <vbox>
62 <frame>
63 <tree>
64 <width>500</width><height>130</height>
65 <variable>DEVICE</variable>
66 <label>Umounted dev|Size|System|Type|Label|Boot|Start|End|Blocks|Id|UUID</label>
67 <input>/usr/lib/slitaz/libmountbox list-umounted</input>
68 <action>/usr/lib/slitaz/libmountbox umounted-fs-infos</action>
69 <action>refresh:MOUNTED</action>
70 <action>refresh:DEVICE</action>
71 </tree>
72 </frame>
73 <frame>
74 <tree>
75 <width>500</width><height>110</height>
76 <variable>MOUNTED</variable>
77 <label>Mounted fs|Size|Used|Available|Use%|Mounted on|Option</label>'
79 # /dev/root
80 RES=`df -h / | grep rootfs`
81 dev="/dev/root"
82 SIZE=`echo $RES | cut -d " " -f 2`
83 USED=`echo $RES | cut -d " " -f 3`
84 AVAILABLE=`echo $RES | cut -d " " -f 4`
85 PCT=`echo $RES | cut -d " " -f 5`
86 MOUNTED_ON=`echo $RES | cut -d " " -f 6`
87 if [ $SIZE != 0 ]; then
88 ROOT_ITEM="
89 <item icon=\"drive-harddisk\">$dev | $SIZE | $USED | $AVAILABLE | $PCT | $MOUNTED_ON</item>"
90 fi
91 MAIN_DIALOG=${MAIN_DIALOG}${ROOT_ITEM}
93 # Now we have rootfs and icons, list all mounted fs.
94 DEVICE='<input>/usr/lib/slitaz/libmountbox list-mounted</input>
95 <action>/usr/lib/slitaz/libmountbox mounted-fs-infos</action>
96 <action>refresh:MOUNTED</action>
97 <action>refresh:DEVICE</action>
98 </tree>
100 </frame>
102 <hbox>
103 <text use-markup="true" >
104 <label>"<b>Mount selected device on:</b>"</label>
105 </text>
106 <entry accept="directory">
107 <default>/media/cdrom</default>
108 <variable>MOUNT_POINT</variable>
109 </entry>
110 <button>
111 <label>Browse</label>
112 <input file icon="folder-open"></input>
113 <action type="fileselect">MOUNT_POINT</action>
114 </button>
115 </hbox>
116 <hbox>
117 <text use-markup="true" wrap="false">
118 <label>"Tip: Select an unmounted /dev. Then, type or select a folder to mount. Then, press a button.
119 "</label>
120 </text>
121 </hbox>
122 '
124 # Get the mount points list.
125 MAIN_DIALOG=${MAIN_DIALOG}${DEVICE}
127 # Actions buttons (mount, umount, eject, etc).
128 ACTIONS='
130 <hbox>
131 <button>
132 <label>Mount</label>
133 <input file icon="edit-redo"></input>
134 <action>mkdir -p $MOUNT_POINT</action>
135 <action>mount $DEVICE $MOUNT_POINT</action>
136 <action>refresh:MOUNTED</action>
137 <action>refresh:DEVICE</action>
138 </button>
139 <button>
140 <label>Umount</label>
141 <input file icon="undo"></input>
142 <action>umount $MOUNT_POINT; sleep 1</action>
143 <action>refresh:MOUNTED</action>
144 <action>refresh:DEVICE</action>
145 </button>
146 <button>
147 <label>Device list</label>
148 <input file icon="reload"></input>
149 <action>refresh:DEVICE</action>
150 </button>
151 <button>
152 <label>Eject</label>
153 <input file icon="media-cdrom"></input>
154 <action>eject</action>
155 </button>
156 <button>
157 <label>Loop</label>
158 <input file icon="go-jump"></input>
159 <action>/usr/lib/slitaz/libmountbox loopmgr</action>
160 <action>refresh:MOUNTED</action>
161 <action>refresh:DEVICE</action>
162 </button>
163 <button>
164 <label>Crypto</label>
165 <input file icon="passwd"></input>
166 <action>/usr/lib/slitaz/libmountbox cryptomgr</action>
167 <action>refresh:DEVICE</action>
168 </button>
169 <button help>
170 <input file icon="help"></input>
171 <action type="launch">HELP</action>
172 </button>
173 <button>
174 <label>Quit</label>
175 <input file icon="exit"></input>
176 <action type="exit">Exit</action>
177 </button>
179 </hbox>
181 </vbox>
182 </window>'
184 export MAIN_DIALOG=${MAIN_DIALOG}${ACTIONS}
185 gtkdialog --center --program=MAIN_DIALOG >/dev/null
187 exit 0