Mon Oct 14, 2013 9:38 pm
fsmithred wrote:output so that the columns line up better
Tue Oct 15, 2013 2:38 pm
#!/usr/bin/env bash
# if yad is installed, use in preference
#if [[ -f /usr/bin/yad ]]; then
DIALOG="yad"
INFO="image=gtk-dialog-info"
QUESTION="image=gtk-dialog-question"
WARNING="image=gtk-dialog-warning"
ERROR="image=gtk-dialog-error"
#buttons
BUTTON0="button"
BUTTON1="button"
BUTTON0NUM=":0"
BUTTON1NUM=":1"
#cancel button always returns 1 as $?
#ok button always returns 0 as $?
#ok is default (highlighted)
#buttons in yad dialog window may show reversed from zenity window, e.g.
#yad: ok -- cancel (0 -- 1)
#zenity: cancel -- ok (1 -- 0)
#el
if [[ -f /usr/bin/zenity ]]; then
# use zenity
DIALOG="zenity"
INFO="info"
QUESTION="question"
WARNING="warning"
ERROR="error"
#buttons
BUTTON0="ok-label"
BUTTON1="cancel-label"
BUTTON0NUM=""
BUTTON1NUM=""
else
xterm -fa monaco -fs 12 -hold -e echo "
Neither Yad nor Zenity is installed. You can't run the GUI version of
Refracta Installer without one of those. Instead, you can run
'refractainstaller' from a terminal or console for the CLI version.
"
fi
# Check disk space on mounted filesystems.
check_space () {
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }' | tee >($DIALOG --title="Checking disk space..." --progress --pulsate --auto-close --width 300) ;)
}
# Put information in a zenity or yad window to show current settings and disk space
report_space () {
$DIALOG --$QUESTION --title="Disk Space and Settings Report" --${BUTTON0}="Create Snapshot"${BUTTON0NUM} \
--${BUTTON1}="Exit"${BUTTON1NUM} --no-wrap \
--text "Please CLOSE any running applications NOW.
You will need plenty of free space. It is recommended that free space (Avail) in the partition that
holds the work directory (probably \"/\") should be two times the total installed system size (Used).
(Note: You can deduct the space taken up by previous snapshots and any saved copies of the system from the Used amount.)
* You have $snapshot_count snapshots taking up $snapshot_size of disk space.
$saved_copy
$save_message
* The snapshot directory is currently set to $snapshot_dir
$tmp_warning
You can change these and other settings by editing
$configfile.
Current disk usage:
(For complete listing, exit and run 'df -h')
$disk_space
Here's an extra line of text.
"
if [ $? -ne 0 ]; then
exit 0
fi
}
check_space
report_space
echo "Done! "
Wed Oct 16, 2013 9:44 pm
Mon Oct 21, 2013 11:25 am
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660|sed 's/Mounted on/Mountpoint/'|column -t )
\n$disk_space
Mon Oct 21, 2013 1:07 pm
dzz wrote:Is it that important to change the column order? Simplifying things a little, I found that this displays perfectly:
- Code:
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660|sed 's/Mounted on/Mountpoint/'|column -t )
Also where the script calls $disk_space as text, change to:
- Code:
\n$disk_space
Only tested so far using zenity on my Squeeze laptop, will try later on another system
Sat Oct 26, 2013 9:08 pm
# Check disk space on mounted /, /home, /media, /mnt, /tmp
check_space () {
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }' | tee >($DIALOG --title="Checking disk space..." --progress --pulsate --auto-close --width 300) ;)
}
# These functions create the information window
$DIALOG --title="Checking disk space..." --progress --pulsate --width 300
check_copies
check_directories
check_space
kill $(pgrep $DIALOG)
report_space
if [[ -d $snapshot_dir ]]; then
if [[ -e "$snapshot_dir"/*.iso ]] ; then
snapshot_count=$(ls "$snapshot_dir"/*.iso | wc -l)
# Check how many snapshots already exist and their total size
if [[ -d $snapshot_dir ]]; then
if ls "$snapshot_dir"/*.iso > /dev/null ; then
snapshot_count=$(ls "$snapshot_dir"/*.iso | wc -l)
Sun Oct 27, 2013 2:41 pm
Your fix doesn't work for me. Columns are all uneven in both yad and zenity
df -h -x tmpfs -x devtmpfs -x iso9660|awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $1}'|column -t|gxmessage -geometry 480x320 -title "Current Disk Usage" -fn Monospace -file -
#!/usr/bin/env bash
# if yad is installed, use in preference
if [[ -f /usr/bin/yad ]]; then
DIALOG="yad"
INFO="image=gtk-dialog-info"
QUESTION="image=gtk-dialog-question"
WARNING="image=gtk-dialog-warning"
ERROR="image=gtk-dialog-error"
#buttons
BUTTON0="button"
BUTTON1="button"
BUTTON0NUM=":0"
BUTTON1NUM=":1"
#cancel button always returns 1 as $?
#ok button always returns 0 as $?
#ok is default (highlighted)
#buttons in yad dialog window may show reversed from zenity window, e.g.
#yad: ok -- cancel (0 -- 1)
#zenity: cancel -- ok (1 -- 0)
elif [[ -f /usr/bin/zenity ]]; then
# use zenity
DIALOG="zenity"
INFO="info"
QUESTION="question"
WARNING="warning"
ERROR="error"
#buttons
BUTTON0="ok-label"
BUTTON1="cancel-label"
BUTTON0NUM=""
BUTTON1NUM=""
else
xterm -fa monaco -fs 12 -hold -e echo "
Neither Yad nor Zenity is installed. You can't run the GUI version of
Refracta Installer without one of those. Instead, you can run
'refractainstaller' from a terminal or console for the CLI version.
"
fi
# Check disk space on mounted filesystems.
check_space () {
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660| sed 's/Mounted on/Mountpoint/' | sed 's/ /\t/'| awk '{ print $2 " " $3 " " $4 " " $5 " " $6 " " $1 }'|column -t)
}
# Put information in a zenity or yad window to show current settings and disk space
report_space () {
# use gxmessage to display disk space with neatly lined columns in a separate window
# gxmessage window will exit after main dialog is answered
df -h -x tmpfs -x devtmpfs -x iso9660|awk '{print $2 " " $3 " " $4 " " $5 " " $6 " " $1}'|column -t|gxmessage -geometry 480x320 -title "Current Disk Usage" -fn Monospace -file - &
$DIALOG --question --width 480 --height 320 --title="Disk Space and Settings Report" --${BUTTON0}="Create Snapshot"${BUTTON0NUM} \
--${BUTTON1}="Exit"${BUTTON1NUM} \
--text "Please CLOSE any running applications NOW and check the \"Current Disk Usage\" window.
You will need plenty of free space. It is recommended that free space (Avail) in the partition that holds the work directory (probably \"/\") should be two times the total installed system size (Used).
You can deduct the space taken up by previous snapshots and any saved copies of the system from the Used amount.
* You have $snapshot_count snapshots taking up $snapshot_size of disk space.
$saved_copy
$save_message
* The snapshot directory is currently set to $snapshot_dir
$tmp_warning
You can change these and other settings by editing
$configfile.
"
if [ "$?" = "0" ]; then
echo "Creating snapshot.. "
killall gxmessage
else
echo "Script will exit"
killall gxmessage
exit 0
fi
}
#check_space
report_space
echo "Done! "
Sun Oct 27, 2013 8:25 pm
Fri Nov 01, 2013 1:43 pm
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 -x udf -x aufs -x squashfs | awk '{ print $2 " \t" $3 " \t" $4 " \t" $5 " \t" $6 " \t\t\t" $1 }')
Thu Nov 07, 2013 2:41 pm
$DIALOG --title="Checking disk space..." --progress --pulsate --width 300 &
check_copies
check_directories
check_space
kill $(pgrep $DIALOG)
report_space