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