├── COPYING ├── INSTALL ├── README ├── attic └── gs.py ├── build-stamp ├── debian ├── changelog ├── compat ├── control ├── copyright ├── dirs ├── docs ├── files ├── install ├── menu ├── pydf.debhelper.log ├── pydf.substvars ├── rules └── source │ └── format ├── install-stamp ├── pydf ├── pydf.1 └── pydfrc /COPYING: -------------------------------------------------------------------------------- 1 | This package was written by Radovan Garabík 2 | 3 | Copyright: 4 | 5 | Public domain. Do whatever you want to do with this program. 6 | 7 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | You must have python installed (at least version 2.3, or version 2.2. 2 | with optparse package). 3 | 4 | Python3 is recommended, though. 5 | 6 | edit first line of pydf to point to your python interpreter, 7 | copy pydf somewhere into your path, 8 | copy pydf.1 where your manpages reside (e.g. /usr/local/man/man1) 9 | and copy pydfrc into /etc/pydfrc, or ~/.pydfrc 10 | 11 | Modify /etc/pydfrc according to your taste. 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | pydf is all-singing, all-dancing, fully colourised df(1)-clone 2 | written in python. 3 | 4 | Requirements: 5 | pydf was written for linux, using specific linux features. 6 | The fact it runs on other systems is pure coincidence, 7 | but neverthless it happens to work on wide range of modern 8 | unix systems. 9 | 10 | System-wide configuration is in /etc/pydfrc, per-user 11 | configuration in ~/.pydfrc (format of these files is the same) 12 | 13 | Colours are one of: 14 | none, default, bold, underline, blink, reverse, concealed, 15 | black, green, yellow, blue, magenta, cyan, white, 16 | on_black, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white 17 | beep 18 | on_red means that the background (instead of foreground) is painted 19 | with red etc... 20 | 21 | 22 | pydf recognizes following parameters: 23 | 24 | --help show this help message 25 | -a, --all include filesystems having 0 blocks 26 | -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) 27 | -H, --si likewise, but use powers of 1000 not 1024 28 | -bBLOCKSIZE, --block-size=BLOCKSIZE 29 | use SIZE-byte blocks 30 | -l, --local limit listing to local filesystems 31 | -k, --kilobytes like --block-size=1024 32 | -m, --megabytes like --block-size=1048576 33 | -g, --gigabytes like --block-size=1073741824 34 | --blocks use filesystem native block size 35 | --bw do not use colours 36 | --mounts=MOUNTS_FILE File to get mount information from. On normal linux 37 | system, only /etc/mtab or proc/mounts make sense. Some 38 | other unices use /etc/mnttab. Use /proc/mounts when 39 | /etc/mtab is corrupted or inaccesable (the output 40 | looks a bit weird in this case). 41 | -B, --show-binds show also mount --bind mounted filesystems 42 | 43 | Written by Radovan Garabík . 44 | For new versions, look at http://kassiopeia.juls.savba.sk/~garabik/software/pydf/ 45 | -------------------------------------------------------------------------------- /attic/gs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # get terminal size 4 | # from resize(1) 5 | # it does not work quite properly and there is a simpler way 6 | # 7 | # do not use 8 | 9 | import os, time, termios 10 | from termios import ICRNL, IUCLC, ICANON, ECHO, CS8, VMIN, VTIME, TCSANOW, TCSADRAIN, TCSAFLUSH 11 | 12 | getsize = "\0337\033[r\033[999;999H\0336n\033[18t" 13 | restoreemu = "\0338" 14 | ttyfd = os.open('/dev/tty', os.O_RDWR) 15 | 16 | tioorig = termios.tcgetattr(ttyfd) 17 | tio = tioorig[:] 18 | 19 | tio[0] &= ~(ICRNL | IUCLC) # iflag 20 | tio[3] &= ~(ICANON | ECHO) # lflag 21 | tio[2] |= CS8 # cflag 22 | tio[6][VMIN] = 6 # cc 23 | tio[6][VTIME] = 1 # cc 24 | termios.tcsetattr(ttyfd, TCSAFLUSH, tio) 25 | os.write(ttyfd, getsize) 26 | x = os.read(ttyfd, len(getsize)) 27 | os.write(ttyfd, restoreemu) 28 | termios.tcsetattr(ttyfd, TCSADRAIN, tioorig) 29 | print `x` 30 | -------------------------------------------------------------------------------- /build-stamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/garabik/pydf/5996c5965497ad389662c5b6d19963949b33cad7/build-stamp -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | pydf (14) unstable; urgency=medium 2 | 3 | * do not colour readonly filesystem in b&w mode, thanks to Dave Vehrs 4 | (closes: #851904) 5 | 6 | -- Radovan Garabík Mon, 20 Mar 2017 10:42:03 +0100 7 | 8 | pydf (13) unstable; urgency=low 9 | 10 | * added statvfs_block configuration option, to select between 11 | statvfs.F_BSIZE and statvfs.F_FRSIZE 12 | 13 | -- Radovan Garabík Sat, 10 Jan 2015 19:35:34 +0100 14 | 15 | pydf (12) unstable; urgency=low 16 | 17 | * better python3 compatibility; escape control and invalid characters in 18 | mountpoint names 19 | 20 | -- Radovan Garabík Fri, 26 Dec 2014 22:35:40 +0100 21 | 22 | pydf (11) unstable; urgency=low 23 | 24 | * add nfs4 to the list of remote filesystems (thanks to Markus Hauschild) 25 | * add fallback if resize does not work (closes: #577454) 26 | * somewhat better dealing with possible errors in 'resize' fallback 27 | * add several Debian/kFreeBSD special filesystems 28 | 29 | -- Radovan Garabík Sun, 27 Jan 2013 20:42:24 +0200 30 | 31 | pydf (10) unstable; urgency=low 32 | 33 | * normal_colour was not interpreting colour codes properly 34 | (thanks to Juhapekka Tolvanen and Norman Rasmussen for 35 | pointing this out) 36 | (closes: #577595, #582462) 37 | * if termios reports zero for terminal width, use fallback 38 | (closes: #577454) 39 | * added devtmpfs to the list of special filesystems 40 | (closes: #577453), both bugreports thanks to Romain Francoise 41 | * use subprocess or commands depending on major python version 42 | (closes: #579936), patch thanks to Emmanuel Bouthenot 43 | * remove parentheses in class definition, to enable 44 | python2.4 compatibility (thanks to Clint Savage) 45 | * add patch for /dev/mapper links, thanks to Ernest Beinrohr 46 | 47 | -- Radovan Garabík Sun, 11 Dec 2011 15:06:41 +0200 48 | 49 | pydf (9) unstable; urgency=low 50 | 51 | * remove stray ANSI escape sequence when using --bw mode 52 | * convert to run with python3 (thanks to Dror Levin) 53 | 54 | -- Radovan Garabík Mon, 29 Mar 2010 23:06:15 +0200 55 | 56 | pydf (8) unstable; urgency=low 57 | 58 | * run pylint & pychecker -- fix some previously unnoticed bugs 59 | * treat "special" filesystems and those with 0 blocks the same 60 | (i.e. do not display them unless -a option is given) 61 | * add fuse.sshfs to the list of networked filesystems 62 | 63 | -- Radovan Garabík Sat, 24 Oct 2009 17:40:14 +0200 64 | 65 | pydf (7) unstable; urgency=low 66 | 67 | * add 'inodes' option (closes: #51044), patch thanks to Thomas Rösner 68 | * change 'blocks-size' option into 'block-size', as originally intended 69 | * if the used percentage is meaningless, display '-' instead of 0 70 | * minor documentation updates 71 | 72 | -- Radovan Garabík Fri, 10 Apr 2009 14:40:00 +0200 73 | 74 | pydf (6) unstable; urgency=low 75 | 76 | * add the 'hidebinds' options (thanks to Martin von Wittich) 77 | 78 | -- Radovan Garabík Thu, 17 Apr 2008 22:24:03 +0200 79 | 80 | pydf (5) unstable; urgency=low 81 | 82 | * make the bar stretchable, to fill the whole screen width 83 | 84 | -- Radovan Garabík Fri, 10 Aug 2007 13:53:49 +0200 85 | 86 | pydf (4) unstable; urgency=low 87 | 88 | * fix scrolling artefacts at the bottom of terminal 89 | * fix accidentally removed possibility to use colour sequences 90 | 91 | -- Radovan Garabík Thu, 19 Jul 2007 14:54:15 +0200 92 | 93 | pydf (3) unstable; urgency=low 94 | 95 | * completely rewrited formatting code, now utilizes better 96 | screen width (closes: #421118) 97 | * display special filesystems with block_size != 0 in different colour 98 | 99 | -- Radovan Garabík Sun, 15 Jul 2007 19:36:05 +0200 100 | 101 | pydf (2) unstable; urgency=low 102 | 103 | * use termios to get terminal size, does not need resize(1) anymore 104 | (thanks to Josip Rodin for the idea) 105 | 106 | -- Radovan Garabík Sun, 13 May 2007 10:14:45 +0200 107 | 108 | pydf (1) unstable; urgency=low 109 | 110 | * show read only mounted filesystems in different colour (thanks 111 | to Michał J. Gajda and Bastian Kleineidam) 112 | * add binary-arch target to debian/rules (closes: #395633) 113 | * work around python statvfs 32-bit overflow (closes: #396298) 114 | 115 | -- Radovan Garabík Wed, 1 Nov 2006 17:09:52 +0200 116 | 117 | pydf (0.9.9) unstable; urgency=low 118 | 119 | * find automatically mountpoints for arguments (closes: #140483), 120 | thanks to Jürgen A. Erhard 121 | 122 | -- Radovan Garabík Thu, 30 Mar 2006 18:34:49 +0200 123 | 124 | pydf (0.9.8.5) unstable; urgency=low 125 | 126 | * added sshfs to the list of remote filesystems 127 | * added udf to the list of filesystem that are always full 128 | (thanks to Benoît Dejean) 129 | 130 | -- Radovan Garabík Fri, 2 Sep 2005 23:12:41 +0200 131 | 132 | pydf (0.9.8.4) unstable; urgency=low 133 | 134 | * mountfile can be a list now, pydf will try each of them 135 | * fallback to parsing mount(1) output if no mountfile is available 136 | (this adds support for many different operating systems, e.g. MacOSX) 137 | 138 | -- Radovan Garabík Mon, 22 Aug 2005 11:01:01 +0200 139 | 140 | pydf (0.9.8.3) unstable; urgency=low 141 | 142 | * failback to default size when 'resize' is not present (closes: #320564) 143 | * Suggest xutils (for 'resize') 144 | * better barsize rounding 145 | 146 | -- Radovan Garabík Wed, 3 Aug 2005 10:24:40 +0200 147 | 148 | pydf (0.9.8.2) unstable; urgency=low 149 | 150 | * use F_BSIZE instead of F_FRSIZE (closes: #289527) 151 | 152 | -- Radovan Garabík Tue, 2 Aug 2005 12:54:30 +0200 153 | 154 | pydf (0.9.8.1) unstable; urgency=low 155 | 156 | * change forgotten FILL_THRESH value from ridiculously low value back 157 | to 0.95, thanks to Lasse Pommerenke for noticing (closes: #318968) 158 | 159 | -- Radovan Garabík Tue, 19 Jul 2005 09:34:41 +0200 160 | 161 | pydf (0.9.8) unstable; urgency=low 162 | 163 | * try to detect terminal size 164 | * round values to nearest number (closes: #278683, #315273), note that df(1) 165 | sometimes rounds the values incorrectly 166 | 167 | -- Radovan Garabík Sat, 30 Apr 2005 16:05:11 +0200 168 | 169 | pydf (0.9.7) unstable; urgency=low 170 | 171 | * overall reworking, brought up in sync with newer python versions 172 | * accepts mountpoints as arguments (closes: #140483), thanks to Josip Rodin 173 | * only necessary filesystems are queried (closes: #280907) 174 | 175 | -- Radovan Garabik Wed, 5 Jan 2005 20:28:28 +0100 176 | 177 | pydf (0.9.6) unstable; urgency=low 178 | 179 | * modified dependencies for new python numbering scheme (closes: #118248) 180 | * mention /etc/pydfrc in manpage (closes: #108167) 181 | 182 | -- Radovan Garabik Mon, 5 Nov 2001 10:47:10 +0100 183 | 184 | pydf (0.9.5) unstable; urgency=low 185 | 186 | * corercted typo in manpage (closes #99878). 187 | 188 | -- Radovan Garabik Mon, 4 Jun 2001 13:07:06 +0200 189 | 190 | pydf (0.9.4) unstable; urgency=low 191 | 192 | * move Build-Depends where it belongs. 193 | * depends on python | python2 194 | 195 | -- Radovan Garabik Fri, 23 Feb 2001 21:41:04 +0100 196 | 197 | pydf (0.9.3) unstable; urgency=low 198 | 199 | * rebuilt with a new GPG key 200 | 201 | -- Radovan Garabik Fri, 1 Sep 2000 08:27:58 +0200 202 | 203 | pydf (0.9.2) unstable; urgency=low 204 | 205 | * added debhelper to Build-Depends 206 | 207 | -- Radovan Garabik Wed, 16 Feb 2000 16:08:24 +0100 208 | 209 | pydf (0.9.1) unstable; urgency=low 210 | 211 | * Fixed stupid bug affecting those with broken python on RedHat. 212 | Thanks to Keith M. Briggs for pointing this out. 213 | 214 | -- Radovan Garabik Fri, 14 Jan 2000 13:09:13 +0100 215 | 216 | pydf (0.9) unstable; urgency=low 217 | 218 | * More colour definitions 219 | * Upgraded Standards-Version 220 | * Corrected typo in the manpage 221 | * Included pointer to stat(1) in README 222 | 223 | -- Radovan Garabik Thu, 6 Jan 2000 17:24:32 +0100 224 | 225 | pydf (0.8.1) unstable; urgency=low 226 | 227 | * NMU (sponsored). 228 | * Set control file so Radovan is listed properly as the maintainer. 229 | 230 | -- Chris Lawrence Tue, 4 Jan 2000 02:11:01 -0600 231 | 232 | pydf (0.8) unstable; urgency=low 233 | 234 | * statvfs checks for errors - e.g., if you do not have rights to statfs 235 | the filesystem, pydf would not crash 236 | * use getopt for argument parsing 237 | * added --block-size, --local, --all options 238 | * Radovan Garabik is the person 239 | responsible for this package; I am his sponsor and uploading it on his 240 | behalf. 241 | 242 | -- Chris Lawrence Tue, 5 Oct 1999 20:25:25 +0200 243 | 244 | pydf (0.7) unstable; urgency=low 245 | 246 | * build with new debhelper - FHS compliant 247 | * a couple of spelling errors in README fixed 248 | 249 | -- Radovan Garabik Sat, 18 Sep 1999 10:34:28 +0200 250 | 251 | pydf (0.6) unstable; urgency=low 252 | 253 | * now displays size correctly for filesystem with FRSIZE != BSIZE, 254 | workaround for some broked pythons (see 0.3) still valid 255 | * documentation update 256 | * increased version number from 0.4 :-) 257 | 258 | -- Radovan Garabik Wed, 15 Sep 1999 20:52:21 +0200 259 | 260 | pydf (0.5) unstable; urgency=low 261 | 262 | * fixed typo preventing correct display of small sizes 263 | 264 | -- Radovan Garabik Wed, 1 Sep 1999 13:19:38 +0200 265 | 266 | pydf (0.4) unstable; urgency=low 267 | 268 | * network filesystems with block size 0 are now recognized as network 269 | filesystems, not as special filesystems 270 | * workaround for older python interpreter without os.statvfs function 271 | 272 | -- Radovan Garabik Mon, 30 Aug 1999 19:53:50 +0200 273 | 274 | pydf (0.3) unstable; urgency=low 275 | 276 | * Restore original colour after itself 277 | * Should work on RedHat 6.0 now 278 | * Improved colour scheme 279 | * Added --mounts option 280 | 281 | -- Radovan Garabik Fri, 27 Aug 1999 17:24:45 +0200 282 | 283 | pydf (0.2) unstable; urgency=low 284 | 285 | * Initial Release. 286 | 287 | -- Radovan Garabik Thu, 26 Aug 1999 19:16:29 +0200 288 | 289 | Local variables: 290 | mode: debian-changelog 291 | End: 292 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pydf 2 | Section: utils 3 | Priority: optional 4 | Maintainer: Radovan Garabík 5 | Standards-Version: 3.8.3 6 | Build-Depends: debhelper (>= 9), python (>= 2.2) 7 | 8 | Package: pydf 9 | Architecture: all 10 | Depends: python, python (>= 2.2) | python3, ${misc:Depends} 11 | Suggests: 12 | Description: colourised df(1)-clone 13 | pydf is all-singing, all-dancing, fully colourised df(1)-clone 14 | written in Python. 15 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was written by Radovan Garabík 2 | 3 | Copyright: 4 | 5 | Public domain. Do whatever you want to do with this program. 6 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | etc -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README 2 | -------------------------------------------------------------------------------- /debian/files: -------------------------------------------------------------------------------- 1 | pydf_12_all.deb utils optional 2 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | pydfrc etc 2 | pydf usr/bin 3 | 4 | -------------------------------------------------------------------------------- /debian/menu: -------------------------------------------------------------------------------- 1 | ?package(pydf):needs=text section=Apps/System\ 2 | title="pydf" command="/usr/bin/pydf" 3 | -------------------------------------------------------------------------------- /debian/pydf.debhelper.log: -------------------------------------------------------------------------------- 1 | dh_prep 2 | dh_installdirs 3 | dh_install 4 | dh_installdocs 5 | dh_installman 6 | dh_installchangelogs 7 | dh_strip 8 | dh_compress 9 | dh_fixperms 10 | dh_installdeb 11 | dh_shlibdeps 12 | dh_gencontrol 13 | dh_md5sums 14 | dh_builddeb 15 | dh_builddeb 16 | -------------------------------------------------------------------------------- /debian/pydf.substvars: -------------------------------------------------------------------------------- 1 | misc:Depends= 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | #-*- makefile -*- 3 | # Made with the aid of dh_make, by Craig Small 4 | # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. 5 | # Some lines taken from debmake, by Christoph Lameter. 6 | 7 | # Uncomment this to turn on verbose mode. 8 | #export DH_VERBOSE=1 9 | 10 | build: build-arch build-indep 11 | build-arch: build-stamp 12 | build-indep: build-stamp 13 | 14 | build-stamp: 15 | dh_prep 16 | dh_testdir 17 | # Add here commands to compile the package. 18 | # $(MAKE) 19 | 20 | touch build-stamp 21 | 22 | clean: 23 | dh_testdir 24 | dh_testroot 25 | rm -f build-stamp install-stamp 26 | 27 | # Add here commands to clean up after the build process. 28 | # -$(MAKE) clean 29 | 30 | dh_clean 31 | 32 | install: install-stamp 33 | install-stamp: build-stamp 34 | dh_testdir 35 | dh_testroot 36 | dh_installdirs 37 | dh_install 38 | 39 | touch install-stamp 40 | 41 | # Build architecture-dependent files here. 42 | #binary-arch: build install 43 | # We have nothing to do by default. 44 | 45 | # Build architecture-independent files here. 46 | binary-indep: build install 47 | # dh_testversion 48 | dh_testdir 49 | dh_testroot 50 | dh_installdocs 51 | # dh_installexamples 52 | # dh_installmenu 53 | # dh_installemacsen 54 | # dh_installinit 55 | # dh_installcron 56 | dh_installman pydf.1 57 | # dh_undocumented 58 | dh_installchangelogs 59 | # dh_link 60 | dh_strip 61 | dh_compress 62 | dh_fixperms 63 | # You may want to make some executables suid here 64 | # dh_suidregister 65 | # dh_makeshlibs 66 | dh_installdeb 67 | # dh_perl 68 | # dh_python 69 | dh_shlibdeps 70 | dh_gencontrol 71 | dh_md5sums 72 | dh_builddeb 73 | 74 | source diff: 75 | @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false 76 | 77 | binary: binary-indep binary-arch 78 | .PHONY: build clean binary-indep binary-arch binary 79 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /install-stamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/garabik/pydf/5996c5965497ad389662c5b6d19963949b33cad7/install-stamp -------------------------------------------------------------------------------- /pydf: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | 3 | import sys, os, re, string, struct, unicodedata 4 | from optparse import OptionParser 5 | 6 | from math import log 7 | 8 | if not 'lexists' in dir(os.path): 9 | # for python < 2.4 10 | # will not give the same result for broken symbolic links, but who cares... 11 | os.path.lexists = os.path.exists 12 | 13 | if sys.version_info[0] < 3: 14 | # getoutput() and getstatusoutput() methods have 15 | # been moved from commands to the subprocess module 16 | # with Python >= 3.x 17 | import commands as my_subprocess 18 | else: 19 | import subprocess as my_subprocess 20 | 21 | str_ljust = str.ljust 22 | str_rjust = str.rjust 23 | str_center = str.center 24 | 25 | 26 | # again an ugly hack for python < 2.4 27 | try: 28 | str_ljust('dummy', 1, '.') 29 | except TypeError: 30 | str_ljust = lambda x, y, z: string.ljust (x, y).replace(' ', z) 31 | str_rjust = lambda x, y, z: string.rjust (x, y).replace(' ', z) 32 | str_center = lambda x, y, z: string.center (x, y).replace(' ', z) 33 | 34 | class Bar: 35 | def __init__(self, percentage=0, width=2, header=False): 36 | self.percentage = percentage 37 | self.width = width 38 | self.header = header 39 | 40 | def __len__(self): 41 | return self.width 42 | 43 | def __str__(self): 44 | return self.format(self, 'l') 45 | 46 | def format(self, pos): 47 | if self.header: 48 | return ' '*self.width 49 | size = int(round(self.percentage*(self.width-2))) 50 | return '['+manglestring(size*barchar, self.width-2, pos, bar_fillchar)+']' 51 | 52 | 53 | def get_terminal_width_termios(): 54 | try: 55 | import fcntl, termios 56 | except ImportError: 57 | return None 58 | s = struct.pack("HHHH", 0, 0, 0, 0) 59 | try: 60 | lines, cols, xpixels, ypixels = \ 61 | struct.unpack( 62 | "HHHH", 63 | fcntl.ioctl(sys.stdout.fileno(), 64 | termios.TIOCGWINSZ, s) 65 | ) 66 | except (IOError, AttributeError): 67 | return None 68 | return cols 69 | 70 | def get_terminal_width_resize(): 71 | status, output = my_subprocess.getstatusoutput('resize') 72 | if status!=0: # error in running resize 73 | return None 74 | c = output.split('\n') 75 | c = [x for x in c if x.startswith('COLUMNS=')] 76 | if c: 77 | c = c[0] 78 | dummy, c = c.split('=', 1) 79 | if c[-1] == ';': 80 | c = c[:-1] 81 | if c: 82 | return int(c) 83 | else: 84 | return None 85 | 86 | def get_terminal_width_dumb(): 87 | return 80 88 | 89 | def get_terminal_width(): 90 | handlers = [get_terminal_width_termios, get_terminal_width_resize, get_terminal_width_dumb] 91 | for handler in handlers: 92 | width = handler() 93 | if width: 94 | return width 95 | return 80 # fallback, should not happen 96 | 97 | 98 | def find_mountpoint(path): 99 | if not os.path.lexists(path): 100 | sys.stderr.write('pydf: %s: No such file or directory\n' % repr(path)) 101 | return None 102 | while not os.path.ismount(path): 103 | path = os.path.dirname(path) 104 | return path 105 | 106 | 107 | #some default definitions 108 | colours = { 109 | 'none' : "", 110 | 'default' : "\033[0m", 111 | 'bold' : "\033[1m", 112 | 'underline' : "\033[4m", 113 | 'blink' : "\033[5m", 114 | 'reverse' : "\033[7m", 115 | 'concealed' : "\033[8m", 116 | 117 | 'black' : "\033[30m", 118 | 'red' : "\033[31m", 119 | 'green' : "\033[32m", 120 | 'yellow' : "\033[33m", 121 | 'blue' : "\033[34m", 122 | 'magenta' : "\033[35m", 123 | 'cyan' : "\033[36m", 124 | 'white' : "\033[37m", 125 | 126 | 'on_black' : "\033[40m", 127 | 'on_red' : "\033[41m", 128 | 'on_green' : "\033[42m", 129 | 'on_yellow' : "\033[43m", 130 | 'on_blue' : "\033[44m", 131 | 'on_magenta' : "\033[45m", 132 | 'on_cyan' : "\033[46m", 133 | 'on_white' : "\033[47m", 134 | 135 | 'beep' : "\007" 136 | } 137 | 138 | 139 | normal_colour = 'default' 140 | header_colour = 'yellow' 141 | local_fs_colour = 'default' 142 | remote_fs_colour = 'green' 143 | special_fs_colour = 'blue' 144 | readonly_fs_colour = 'cyan' 145 | filled_fs_colour = 'red' 146 | full_fs_colour = 'on_red' 147 | custom_device_colour = {} #TODO 148 | 149 | sizeformat = "-h" 150 | column_separator = ' ' 151 | column_separator_colour = 'none' 152 | row_separator = '' 153 | hidebinds = True 154 | 155 | stretch_screen = 0.3 156 | 157 | do_total_sum = False 158 | 159 | FILL_THRESH = 95.0 160 | FULL_THRESH = 99.0 161 | 162 | 163 | format = [ 164 | ('fs', 10, "l"), ('size', 5, "r"), 165 | ('used', 5, "r"), ('avail', 5, "r"), ('perc', 4, "r"), 166 | ('bar', 0.1, "l"), ('on', 11, "l") 167 | ] 168 | 169 | 170 | barchar = '#' 171 | bar_fillchar = '.' 172 | 173 | mountfile = ['/etc/mtab', '/etc/mnttab', '/proc/mounts'] 174 | 175 | statvfs_block = 'auto' 176 | 177 | #end of default definitions 178 | 179 | # read configuration file 180 | for conffile in ["/etc/pydfrc", os.environ['HOME']+"/.pydfrc"]: 181 | if os.path.isfile(conffile): 182 | exec(compile(open(conffile).read(), conffile, 'exec')) 183 | 184 | 185 | header = { 186 | 'fs' : "Filesystem", 187 | 'size' : "Size", 188 | 'used' : "Used", 189 | 'avail' : "Avail", 190 | 'on' : "Mounted on", 191 | 'fstype' : "Type", 192 | 'perc' : "Use%", 193 | 'bar' : Bar(header=True), 194 | } 195 | 196 | def sanitize_output(s): 197 | "sanitize nonprintable characters for printing" 198 | r = '' 199 | for c in s: 200 | if ord(c)<32: 201 | r += r'\x%02x' % ord(c) 202 | # surrogate characters encoding non-decodable bytes in the names of mountpoints 203 | elif 0xdc80 <= ord(c) <= 0xdcff: 204 | r += r'\x%02x' % (ord(c)-0xdc00) 205 | # in python2, we have str, not unicode here - just give up and do not test for strange unicode characters 206 | elif sys.version_info[0] >= 3 and (unicodedata.category(c)[0]=='C' or unicodedata.category(c) in ('Zl', 'Zp')): 207 | if ord(c) <= 0xffff: 208 | r += r'\u%04X' % ord(c) 209 | else: 210 | r += r'\U%08X' % ord(c) 211 | else: 212 | r += c 213 | return r 214 | 215 | def out(s): 216 | try: 217 | sys.stdout.write(s) 218 | except UnicodeEncodeError: 219 | sys.stdout.write(s.encode('ascii', 'ignore').decode()) 220 | 221 | class DumbStatus: 222 | "emulates statvfs results with only zero values" 223 | f_bsize = f_frsize = f_blocks = f_bfree = f_bavail = f_files = f_ffree = f_favail = f_flag = f_namemax = 0 224 | 225 | def hfnum(size, base): 226 | "human readable number" 227 | if size == 0: 228 | return "0" 229 | if size < 0: 230 | return "?" 231 | if inodes: 232 | units = [""] 233 | else: 234 | units = ["B"] 235 | units += ["k", "M", "G", "T", "P", "Z", "Y"] 236 | power = int(log(size)/log(base)) 237 | if power < 0: 238 | power = 0 239 | if power >= len(units): 240 | power = len(units)-1 241 | nsize = int(round(1.*size/(base**power))) 242 | if nsize < 10 and power >= 1: 243 | power -= 1 244 | nsize = int(round(1.*size/(base**power))) 245 | r = str(nsize) + units[power] 246 | return r 247 | 248 | def myformat(number, sizeformat, fs_blocksize): 249 | "format number as file size. fs_blocksize here is a filesysem blocksize" 250 | size = int(number)*fs_blocksize 251 | if blocksize: # that is, blocksize was explicitly set up 252 | sn = round(1.*size/blocksize) 253 | sn = int(sn) 254 | return str(sn) 255 | if sizeformat == "-k": 256 | sn = round(size/1024.) 257 | sn = int(sn) 258 | return str(sn) 259 | elif sizeformat == "-m": 260 | sn = round(size/(1024.*1024)) 261 | sn = int(sn) 262 | return str(sn) 263 | elif sizeformat == "-g": 264 | sn = round(size/(1024.*1024*1024)) 265 | sn = int(sn) 266 | return str(sn) 267 | elif sizeformat == "-h": 268 | return hfnum(size, 1024) 269 | elif sizeformat == "-H": 270 | return hfnum(size, 1000) 271 | elif sizeformat == "--blocks": 272 | return str(number) 273 | else: # this should not happen 274 | raise ValueError("Impossible error, contact the author, sizeformat="+repr(sizeformat)) 275 | 276 | def manglestring(s, l, pos, fillchar=' '): 277 | "cut string to fit exactly into l chars" 278 | if pos == "r": 279 | ns = str_rjust(s, l, fillchar) 280 | elif pos == "l": 281 | ns = str_ljust(s, l, fillchar) 282 | elif pos == "c": 283 | ns = str_center(s, l, fillchar) 284 | else: 285 | raise ValueError('Error in manglestring') 286 | if len(ns) > l: 287 | ns = ns[:int(l/2)] + "~" + ns[-int(l/2)+1:] 288 | return ns 289 | 290 | def makecolour(clist): 291 | "take list (or tuple or just one name) of colour names and return string of ANSI definitions" 292 | s = "" 293 | if type(clist) == str: 294 | lclist = [clist] 295 | else: 296 | lclist = clist 297 | for i in lclist: 298 | s = s + colours[i] 299 | return s 300 | 301 | def version(): 302 | return '14' 303 | 304 | def get_all_mountpoints(): 305 | "return all mountpoints in fs" 306 | 307 | # fallback when nothing else works 308 | dummy_result = {'/': ('/', '')} 309 | 310 | if isinstance(mountfile, str): 311 | f = open(mountfile,"rb") 312 | else: 313 | for i in mountfile: 314 | if os.path.exists(i): 315 | f = open(i,"rb") 316 | break 317 | else: 318 | # fallback, first try to parse mount output 319 | status, mout = my_subprocess.getstatusoutput('mount') 320 | if status !=0: 321 | return dummy_result 322 | mlines = mout.split('\n') 323 | r = {} 324 | for line in mlines: 325 | if not ' on ' in line: 326 | continue 327 | device, on = line.split(' on ', 1) 328 | device = device.split()[0] 329 | onparts = on.split() 330 | on = onparts[0] 331 | # option format: (a,b,..) 332 | opts = onparts[-1][1:-1].split(',') 333 | r[on] = (device, '', opts) 334 | 335 | if r: 336 | return r 337 | else: 338 | return dummy_result 339 | 340 | mountlines = f.readlines() # bytes in python3 341 | 342 | # convert to representable strings (for python3) 343 | # unfortunately, we cannot keep it as bytes, because of a known bug 344 | # in python3 forcing us to use string, not bytes as filename for os.statvfs 345 | if sys.version_info[0]>=3: 346 | errhandler = 'surrogateescape' 347 | if sys.version_info[1]<1: 348 | errhandler = 'replace' 349 | mountlines = [x.decode(sys.stdin.encoding, errhandler) for x in mountlines] 350 | r = {} 351 | for l in mountlines: 352 | spl = l.split() 353 | if len(spl)<4: 354 | print("Error in", mountfile) 355 | print(repr(l)) 356 | continue 357 | device, mp, typ, opts = spl[0:4] 358 | opts = opts.split(',') 359 | r[mp] = (device, typ, opts) 360 | return r 361 | 362 | def niceprint_fs(fs): 363 | "print LVM as nice symlink" 364 | matchObj = re.search( r'^\/dev\/mapper\/(.*)-(.*)', str(fs)) # will fail in python3if fs canot be converted to unicode 365 | if matchObj: 366 | return "/dev/" + matchObj.group(1) + "/" + matchObj.group(2) 367 | else: 368 | return fs 369 | 370 | def get_row_mp(mp): 371 | # for python3, mp is bytes, not str 372 | if mp: 373 | if mp in mountpoints: 374 | device, fstype, opts = mountpoints[mp] 375 | device = niceprint_fs(device) 376 | else: 377 | # oops, the mountpoint is not in /etc/mtab or equivalent 378 | # return dummy values 379 | device, fstype, opts = '-', '-', '-' 380 | rdonly = 'ro' in opts or fstype in ("iso9660", "udf") 381 | bind = 'bind' in opts or 'rbind' in opts 382 | 383 | try: 384 | status = os.statvfs(mp) 385 | except (OSError, IOError): 386 | status = DumbStatus() 387 | if statvfs_block == 'bsize': 388 | fs_blocksize = status.f_bsize or status.f_frsize 389 | elif statvfs_block == 'frsize': 390 | fs_blocksize = status.f_frsize or status.f_bsize 391 | elif statvfs_block == 'auto': 392 | if sys.platform == 'linux2': 393 | fs_blocksize = status.f_bsize or status.f_frsize 394 | else: 395 | fs_blocksize = status.f_frsize or status.f_bsize 396 | else: 397 | # bad value in configuration 398 | raise ValueError('bad configuration: statvfs_block') 399 | free = status.f_bfree 400 | size = status.f_blocks 401 | avail = status.f_bavail 402 | inodes_free = status.f_ffree 403 | inodes_size = status.f_files 404 | inodes_avail = status.f_favail 405 | if (size==0 or is_special_fs(fstype)) and not allfss: 406 | return 407 | if bind and hidebinds: 408 | return 409 | used = size-free 410 | inodes_used = inodes_size - inodes_free 411 | 412 | if inodes: 413 | size_f = myformat(inodes_size, sizeformat, 1) 414 | used_f = myformat(inodes_used, sizeformat, 1) 415 | avail_f = myformat(inodes_avail, sizeformat, 1) 416 | try: 417 | perc = round(100.*inodes_used/inodes_size, 1) 418 | perc_f = str(perc) 419 | except ZeroDivisionError: 420 | perc = 0 421 | perc_f = '-' 422 | else: 423 | size_f = myformat(size, sizeformat, fs_blocksize) 424 | used_f = myformat(used, sizeformat, fs_blocksize) 425 | avail_f = myformat(avail, sizeformat, fs_blocksize) 426 | try: 427 | perc = round(100.*used/size, 1) 428 | perc_f = str(perc) 429 | except ZeroDivisionError: 430 | perc = 0 431 | perc_f = '-' 432 | 433 | info = { 434 | 'fs' : device, 435 | 'size' : size_f, 436 | 'used' : used_f, 437 | 'avail' : avail_f, 438 | 'on' : mp, 439 | 'fstype' : fstype, 440 | 'perc' : perc_f, 441 | 'bar' : None, 442 | } 443 | current_colour = local_fs_colour 444 | if is_remote_fs(fstype): 445 | current_colour = remote_fs_colour 446 | elif size == 0 or is_special_fs(fstype): 447 | current_colour = special_fs_colour 448 | else: # header 449 | current_colour = header_colour 450 | 451 | row = [] 452 | 453 | for j in format: 454 | 455 | if j[0]=='bar': 456 | width = j[1] 457 | if 0 FULL_THRESH: 465 | current_colour = full_fs_colour 466 | elif perc > FILL_THRESH: 467 | current_colour = filled_fs_colour 468 | if j[0]=='bar': 469 | info['bar'] = Bar(perc/100., width) 470 | 471 | text = info[j[0]] 472 | # if there are control or invalid unicode characters in mountpoint names 473 | if not isinstance(text, Bar): 474 | text = sanitize_output(text) 475 | 476 | else: 477 | text = header[j[0]] 478 | if j[0]=='bar': 479 | text.width = width 480 | 481 | column = [current_colour, text] 482 | row.append(column) 483 | 484 | return row 485 | 486 | 487 | def is_remote_fs(fs): 488 | "test if fs (as type) is a remote one" 489 | fs = fs.lower() 490 | 491 | return fs in [ "nfs", "smbfs", "cifs", "ncpfs", "afs", "coda", 492 | "ftpfs", "mfs", "sshfs", "fuse.sshfs", "nfs4" ] 493 | 494 | def is_special_fs(fs): 495 | "test if fs (as type) is a special one" 496 | "in addition, a filesystem is special if it has number of blocks equal to 0" 497 | fs = fs.lower() 498 | return fs in [ "tmpfs", "devpts", "devtmpfs", "proc", "sysfs", "usbfs", "devfs", "fdescfs", "linprocfs" ] 499 | 500 | def get_table(mps): 501 | "table is a list of rows" 502 | "row is a list of columns" 503 | "column is a list of [colour code, content]" 504 | "content is a string, unless it is a Bar() instance" 505 | rows = [get_row_mp(None)] 506 | for mp in mps: 507 | row = get_row_mp(mp) 508 | if row is not None: 509 | rows.append(row) 510 | return rows 511 | 512 | 513 | def squeeze_table(table, desired_width): 514 | "squeeze table to fit into width characters" 515 | 516 | cols = len(table[0]) 517 | 518 | # build a row of minimal (possible, from format) cell sizes 519 | minrow = [] 520 | for j in format: 521 | width = j[1] 522 | if 0 < width < 1: # i.e. percentage 523 | width = int(width*terminal_width)-1 524 | minrow.append(width) 525 | 526 | # row of maximal cell sizes 527 | maxrow = [0]*cols 528 | 529 | for row in table: 530 | for col in range(cols): 531 | colsize = len(row[col][1]) 532 | maxrow[col] = max(maxrow[col], colsize) 533 | 534 | # maximal differences between (real cell size - minimal possible cell size) 535 | deltarow = [maxrow[i]-minrow[i] for i in range(cols)] 536 | 537 | deltas = list(zip(deltarow, list(range(cols)))) 538 | deltas.sort() 539 | deltas.reverse() 540 | 541 | # how many characters we need to cut off from table width 542 | to_reduce = sum(maxrow) + (cols-1)*len(column_separator) - desired_width 543 | 544 | to_stretch = 0 545 | # if there is free space 546 | if to_reduce < 0 and stretch_screen: 547 | # -to_reduce is now number of spare characters 548 | to_stretch = int(-to_reduce * stretch_screen) 549 | 550 | new_maxrow = maxrow[:] # new sizes 551 | for delta, i in deltas: 552 | if to_reduce < 0: 553 | # we have finished 554 | break 555 | if delta >= to_reduce: 556 | new_maxrow[i] -= to_reduce 557 | # and we finished 558 | to_reduce = 0 559 | break 560 | else: 561 | new_maxrow[i] -= delta # now it contains the minimal possible width 562 | to_reduce -= delta 563 | 564 | if to_reduce > 0: 565 | # we were not able to reduce the size enough 566 | # since it will wrap anywway, we might as well display 567 | # complete long lines 568 | new_maxrow = maxrow 569 | for row in table: 570 | for col in range(cols): 571 | cell_content = row[col][1] 572 | if isinstance(cell_content, Bar): 573 | cell_content.width += to_stretch 574 | formatted_cell_content = cell_content.format(format[col][2]) 575 | else: 576 | formatted_cell_content = manglestring(cell_content, new_maxrow[col], format[col][2]) 577 | row[col][1] = formatted_cell_content 578 | 579 | 580 | def display_table(table, terminal_width): 581 | "display our internal output table" 582 | 583 | squeeze_table(table, terminal_width-1) 584 | 585 | colsepcol = makecolour(column_separator_colour) 586 | for row in table: 587 | firstcol = True 588 | for colourcode, text in row: 589 | if firstcol: 590 | firstcol = False 591 | else: 592 | out(colsepcol) 593 | out(column_separator) 594 | out(makecolour(colourcode)) 595 | out(text) 596 | out(row_separator) 597 | out(makecolour(normal_colour)) 598 | out('\n') 599 | 600 | 601 | 602 | # the fun begins here 603 | 604 | parser = OptionParser(usage="usage: %prog [options] arg", add_help_option=False) 605 | 606 | parser.version = '%prog version ' + version() 607 | 608 | parser.add_option("", "--help", action="help", help="show this help message") 609 | parser.add_option("-v", "--version", action="version", help="show version") 610 | 611 | parser.add_option("-a", "--all", 612 | action="store_true", dest="show_all", default=False, 613 | help="include filesystems having 0 blocks") 614 | parser.add_option("-h", "--human-readable", 615 | action="store_const", const='-h', dest="sizeformat", 616 | help="print sizes in human readable format (e.g., 1K 234M 2G)") 617 | parser.add_option("-H", "--si", 618 | action="store_const", const='-H', dest="sizeformat", 619 | help="likewise, but use powers of 1000 not 1024") 620 | parser.add_option("-b", "--block-size", 621 | action="store", dest="blocksize", default=0, type="int", 622 | help="use BLOCKSIZE-byte blocks") 623 | parser.add_option("-l", "--local", 624 | action="store_true", dest="local_only", default=False, 625 | help="limit listing to local filesystems") 626 | parser.add_option("-k", "--kilobytes", 627 | action="store_const", const='-k', dest="sizeformat", 628 | help="like --block-size=1024") 629 | parser.add_option("-m", "--megabytes", 630 | action="store_const", const='-m', dest="sizeformat", 631 | help="like --block-size=1048576") 632 | parser.add_option("-g", "--gigabytes", 633 | action="store_const", const='-g', dest="sizeformat", 634 | help="like --block-size=1073741824") 635 | parser.add_option("", "--blocks", 636 | action="store_const", const='--blocks', dest="sizeformat", 637 | help="use filesystem native block size") 638 | parser.add_option("", "--bw", 639 | action="store_true", dest="b_w", default=False, 640 | help="do not use colours") 641 | #parser.add_option("", "--sum", 642 | # action="store_true", dest="do_total_sum", default=False, 643 | # help="display sum of all the displayed sizes") 644 | parser.add_option("", "--mounts", 645 | action="store", dest="mounts_file", type="string", 646 | help="""File to get mount information from. 647 | On normal Linux systems only /etc/mtab or /proc/mounts make sense. 648 | Some other Unices use /etc/mnttab. 649 | Use /proc/mounts when /etc/mtab is corrupted or inaccessible 650 | (the output looks a bit weird in this case).""") 651 | parser.add_option("-B", "--show-binds", 652 | action="store_false", dest="hidebinds", default=hidebinds, 653 | help="show 'mount --bind' mounts") 654 | parser.add_option("-i", "--inodes", 655 | action="store_true", dest="inodes", default=False, 656 | help="show inode instead of block usage") 657 | 658 | (options, args) = parser.parse_args() 659 | 660 | blocksize = options.blocksize 661 | allfss = options.show_all 662 | localonly = options.local_only 663 | hidebinds = options.hidebinds 664 | inodes = options.inodes 665 | if inodes: 666 | header["size"] = "Nodes" 667 | 668 | if options.sizeformat: 669 | sizeformat = options.sizeformat 670 | 671 | #if options.do_total_sum: 672 | # do_total_sum = True 673 | 674 | if options.b_w: 675 | normal_colour = header_colour = local_fs_colour = remote_fs_colour = readonly_fs_colour = special_fs_colour = filled_fs_colour = full_fs_colour = 'none' 676 | if options.mounts_file: 677 | mountfile = options.mounts_file 678 | 679 | terminal_width = get_terminal_width() 680 | 681 | mountpoints = get_all_mountpoints() 682 | 683 | if args: 684 | mp_to_display = [find_mountpoint(os.path.realpath(x)) for x in args] 685 | mp_to_display = [x for x in mp_to_display if x is not None] 686 | else: 687 | mp_to_display = list(mountpoints.keys()) 688 | if localonly: 689 | mp_to_display = [x for x in mp_to_display if not is_remote_fs(mountpoints[x][1])] 690 | mp_to_display.sort() 691 | 692 | table = get_table(mp_to_display) 693 | display_table(table, terminal_width) 694 | 695 | -------------------------------------------------------------------------------- /pydf.1: -------------------------------------------------------------------------------- 1 | .TH PYDF 1 2 | .SH NAME 3 | pydf \- report colourised filesystem disk space usage 4 | .SH SYNOPSIS 5 | .B pydf 6 | .I "[options]" 7 | .I "[file]" 8 | .SH "DESCRIPTION" 9 | .B pydf 10 | is a python script that displays the amount of disk space available 11 | on the mounted filesystems, using different colours for different 12 | types of filesystems. Output format is completely customizable. 13 | .TP 14 | If an optional 15 | .I "file" 16 | argument is given, pydf displays just information about filesystem 17 | containing the file(s), otherwise it displays information about all 18 | mounted filesystems. 19 | 20 | .SH OPTIONS 21 | .TP 22 | .B \-\-help 23 | Show summary of options. 24 | .TP 25 | .B \-v, \-\-version 26 | Show version of program. 27 | .TP 28 | .B \-a, \-\-all 29 | include filesystems having 0 blocks 30 | .TP 31 | .B \-h, \-\-human-readable 32 | print sizes in human readable format (e.g., 133K 2341M 2448G) 33 | .TP 34 | .B \-H, \-\-si 35 | likewise, but use powers of 1000 not 1024 36 | .TP 37 | .B \-\-block-size=SIZE 38 | use SIZE-byte blocks 39 | .TP 40 | .B \-k, \-\-kilobytes 41 | like --block-size=1024 42 | .TP 43 | .B \-i, \-\-inodes 44 | show information about inodes instead of blocks 45 | .TP 46 | .B \-l, \-\-local 47 | limit listing to local filesystems 48 | .TP 49 | .B \-m, \-\-megabytes 50 | like --block-size=1048576 51 | .TP 52 | .B \-g, \-\-gigabytes 53 | like --block-size=1073741824 54 | .TP 55 | .B \-\-blocks 56 | use filesystem native block size 57 | .TP 58 | .B \-\-bw 59 | do not use colours 60 | .TP 61 | .B --mounts=FILE 62 | file to get mount information from. 63 | On normal linux system, only /etc/mtab or /proc/mounts make sense. 64 | Use /proc/mounts when /etc/mtab is corrupted or inaccessible 65 | (the output looks a bit weird in this case though) 66 | .TP 67 | .B \-B, \-\-show\-binds 68 | Show also mount --bind mounted filesystems. 69 | .SH "BUGS" 70 | POSIX mandates to have f_blocks and f_bfree to be the number in units of f_frsize. However, 71 | many programs are buggy, including df(1) from coreutils, and Linux kernel often lies and reports 72 | f_frsize == f_bsize. Some filesystem and some other operating systems don't, and then the size 73 | reported by pydf is incorrect. As a stopgap measure, there is a parameter 74 | .I statvfs_block 75 | in 76 | .B /etc/pydfrc 77 | where you can force f_frsize or f_bsize. 78 | .SH "FILES" 79 | .TP 80 | .B /etc/pydfrc 81 | main configuration file 82 | .TP 83 | .B ~/.pydfrc 84 | per-user configuration file 85 | .SH "SEE ALSO" 86 | .BR df "(1) 87 | .SH AUTHOR 88 | Radovan Garab\('ik 89 | -------------------------------------------------------------------------------- /pydfrc: -------------------------------------------------------------------------------- 1 | # Configuration file for pydf 2 | # 3 | # 4 | # colours can be: 5 | # 'none' - no change from previous colour 6 | # 'default' - default system colour 7 | # 8 | # special attributes: 9 | # 'bold' 10 | # 'underline' 11 | # 'blink' 12 | # 'reverse' 13 | # 'concealed' 14 | # 15 | # foreground: 16 | # 'black' 17 | # 'red' 18 | # 'green' 19 | # 'yellow' 20 | # 'blue' 21 | # 'magenta' 22 | # 'cyan' 23 | # 'white' 24 | # 25 | # background: 26 | # 'on_black' 27 | # 'on_red' 28 | # 'on_green' 29 | # 'on_yellow' 30 | # 'on_blue' 31 | # 'on_magenta' 32 | # 'on_cyan' 33 | # 'on_white' 34 | # 35 | # beep: 36 | # 'beep' 37 | # 38 | # 39 | # or any combination of these, separated with commas 40 | 41 | 42 | # normal text colour - used to switch to after one row is displayed 43 | normal_colour = 'default' 44 | 45 | # colour of the header 46 | header_colour = 'yellow' 47 | 48 | # colour for local filesystems 49 | local_fs_colour = 'default' 50 | 51 | # colour for remote filesystems (such as nfs, samba, afs....) 52 | remote_fs_colour = 'green' 53 | 54 | # colour for special filesystems (such as proc, pty) 55 | special_fs_colour = 'blue' 56 | 57 | # colour for readonly mounted filesystems 58 | readonly_fs_colour = 'cyan' 59 | 60 | # colour for filesystems with usage > FILL_THRESH 61 | filled_fs_colour = 'red' 62 | 63 | # colour for filesystems with usage > FULL_THRESH 64 | full_fs_colour = 'on_red', 'green', 'blink' 65 | 66 | # custom device names - not implemented yet 67 | #custom_devices_colour = { 68 | # '/dev/loop' : ('green', 'blink') 69 | #} 70 | 71 | 72 | # default format for displaying sizes "-h" or "-H" or "-m" or "-k" or "--blocks" 73 | sizeformat = "-h" 74 | 75 | # string used to separace columns in the table 76 | column_separator = ' ' 77 | 78 | # colour of the string 79 | column_separator_colour = 'none' 80 | 81 | # if the screen is wider than necessary, stretch the bar: 82 | # 0 - do not stretch 83 | # 1 - stretch to fill the whole screen 84 | # real number in between - stretch by this ratio of free space 85 | stretch_screen = 0.3 86 | 87 | # filesystem filled up over this limit (in percents) is displayed 88 | # with filled_fs_colour (to show it is dangerously filled up) 89 | FILL_THRESH = 95.0 90 | 91 | # filesystem filled up over this limit is displayed with 92 | # full_fs_colour (to show it is FULL) 93 | FULL_THRESH = 99.0 94 | 95 | # Format used to display information: (keyword, size, justify). 96 | # keyword - one of 'fs' 'fstype' 'size' 'used' 'avail' 'perc' 'bar' 'on'. 97 | # size - if 'size' is integer, it is a minimal possible column width of the entry 98 | # if 'size' is float, it is a minimal column width in percent of screen width 99 | # 100 | # justify is either "l" for left justify, "r" for right justify or "c" for 101 | # center. 102 | # You can use any order and any combination of keywords, but 103 | # be careful not to exceed the size of your screen 104 | 105 | 106 | #format = [ 107 | # ('fs', 15, "l"), ('size', 9, "r"), 108 | # ('used', 9, "r"), ('avail', 9, "r"), ('perc', 5, "r"), 109 | # ('bar', 8, "l"), ('on', 16, "l") 110 | # ] 111 | 112 | # this is somewhat conservative 113 | # use fixed width for everything, since you want it readable 114 | # only the bar is specified by percentage, because you want it dynamic 115 | format = [ 116 | ('fs', 10, "l"), ('size', 5, "r"), 117 | ('used', 5, "r"), ('avail', 5, "r"), ('perc', 5, "r"), 118 | ('bar', 0.1, "l"), ('on', 11, "l") 119 | ] 120 | 121 | 122 | # character to display filesystem size bar 123 | barchar = '#' 124 | 125 | # fill the empty space of the size bar with this character 126 | bar_fillchar = '.' 127 | 128 | # hide 'mount --bind' binds? 129 | hidebinds = True 130 | 131 | # list of files to try to get mount information from 132 | # on normal linux systems only /etc/mtab or /proc/mounts make sense 133 | mountfile = ['/etc/mtab', '/etc/mnttab', '/proc/mounts'] 134 | 135 | # use f_bsize or f_frsize 136 | # possible values: bsize, frsize, auto 137 | # auto means frsize if running on Linux, otherwise bsize 138 | statvfs_block = 'auto' 139 | 140 | --------------------------------------------------------------------------------