#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.2 #Date: 28-02-07 / 18-11-07 #System: Ubuntu/Debian GNU/Linux #Information: man zenity, man sed, man wc #Information: http://wooledge.org/~greg/foo.txt #Information: http://wooledge.org/mywiki/BashFaq#faq48 #Information: http://wooledge.org/mywiki/BashFaq#faq50 #Category Thunar scripts (thunar->edit->custom actions) #Name: Get Size #Description: Displays the total size of selected items #Command: /usr/share/pct-thunar-scripts/scripts/directory-getsize %F #Patterns: * #Directories: True #Audio Files: True #Image Files: True #Text Files: True #Video Files: True #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Get Size" DESCRIPTION=$"Displays the total size of selected items" echo $"program:" echo "$0" echo $"description:" echo "$DESCRIPTION" #whereis zenity if [ ! -e /usr/bin/zenity ] then echo $"zenity not found, installing now" xterm -e "sudo apt-get install zenity" fi for I in "$@" do query+=("${I}") done if [ -n "$query" ] then total=$(du --summarize --total --block-size=1M "${query[@]}" | sed 's/\t/M: /') #~ total=$(du --summarize --total --human-readable "${query[@]}" | sed 's/\t/ /') (( WIDTH = 35 + 7 * $(wc -L <<< "$total") )) (( HEIGHT = 80 + 23 * $(wc -l <<< "$total") )) echo "$total" | zenity --text-info --title $"Total Disk Usage" --width=$WIDTH --height=$HEIGHT #~ echo "$total" | sort --general-numeric-sort | zenity --text-info --title "Total Disk Usage" --width=$WIDTH --height=$HEIGHT #"WIDTH = 30 + 7 * $(wc -L <<< "$total")" #let WIDTH=$(echo "$total" | wc -L); let WIDTH*=7; let WIDTH+=30 #let HEIGHT=$(echo "$total" | wc -l); let HEIGHT*=23; let HEIGHT+=80 #find . -type f -exec ls -s '{}' \; | cut -f 1 -d ' ' #dir="my dir"; du -shc "${dir}" #dirs=("/first thing/with spaces" "/the second one/also with spaces"); du -shc "${dirs[@]}" | whatever #args=(-s "The subject" "$address") #mail "${args[@]}" < $body #query=(a "b c" d); .. ${query[@]} #i='1234567'; echo "${i:4}" #i='1234567'; echo "${i##????}" #set -- a "b c" d #set -- a 'b c' d #echo "${@}" #echo a 'b c' d #to see what shell is actually using "set -x" #$@ exapnds positional parameters #set(1) sets positional parameters #set -- a "b c" d sets $1=a $2="b c" $3=d #args=($(${query})) # | grep total | cut -f 1 -d \t #du -shc "/mnt/hda3/scripts/thunar" "/mnt/hda3/scripts/via-epia-en12000-ultimate" "/mnt/hda3/scripts/via-epia-me6000-ultimate" | grep total | cut -f 1 -d \t #help ulimit, man setrlimit, etc. #total=$(du -shc "${query[@]}" | grep total) #zenity --info --title "Total Size" --text "Total disk space used: $total" fi exit 0