about summary refs log tree commit diff stats
path: root/config.def.h
Commit message (Expand)AuthorAgeFilesLines
...
* changed config.def.hAnselm R Garbe2008-03-051-32/+9
* integrated the new -x -y -w toggles of dmenu into my setupAnselm R Garbe2008-03-051-1/+6
* implemented the stuff as I discussed on dwm@Anselm R Garbe2008-03-051-6/+55
* renamed maximise to monocle again.Anselm R Garbe2008-03-051-4/+2
* renamed MAXLEN into MAXTAGLEN (backward compliance)anselm@anselm12008-03-041-1/+1
* renamed monocle into maxmise, documented the keybindings in dwm(1)anselm@anselm12008-03-041-5/+7
* monocle goes mainstreamAnselm R Garbe2008-03-041-1/+3
* removed View cruft, now back to the rootsanselm@anselm12008-03-031-1/+0
* made tag names snappierAnselm R Garbe2008-02-291-1/+1
* removed initags -- we autoselect the first tag in each view insteadanselm@anselm12008-02-281-1/+0
* some more changes towards a better dwmAnselm R Garbe2008-02-281-1/+1
* proceeded, though we still miss a real Tag structanselm@anselm12008-02-271-2/+4
* disabled AIM_XINERAMAanselm@anselm12008-02-261-1/+1
* simplified dwmanselm@anselm12008-02-261-2/+2
* pushing my changes of tonight upstream (hg tip is NOW very UNSTABLE -- but th...anselm@anselm12008-02-231-7/+7
* changed arrange functions to contain the Monitor as first argumentAnselm R Garbe2008-02-211-1/+1
* proceeded with multihead/Xinerama supportanselm@anselm12007-12-221-5/+5
* removed maximize, there will be monocle soonanselm@anselm12007-12-221-1/+0
* fixed wrong tagging stuffanselm@anselm12007-12-221-1/+1
* added dmenu_run to config.hanselm@anselm12007-12-221-2/+1
* simplified Mod-mAnselm R. Garbe2007-12-091-1/+1
* implemented reapply for re-applying the tagging rules during runtime, Mod-rAnselm R. Garbe2007-12-081-0/+1
* Using a new tags definition (const char [][MAXTAGLEN] - thanks go to Szabolcs!Anselm R. Garbe2007-11-101-58/+57
* moved LENGTH to dwm.c, moved prevtags to dwm.carg@suckless.org2007-11-071-4/+0
* revival of RESIZEHINTSAnselm R. Garbe2007-11-021-0/+1
* replaced Nmacros with LENGTH(x) macroAnselm R. Garbe2007-10-281-6/+5
* replaced ISTILE with domwfact/dozoom bools, removed nrules, nlayouts and ltid...Anselm R. Garbe2007-10-281-1/+3
* going toward 4.7Anselm R. Garbe2007-10-271-0/+3
* removed RESIZEHINTS and enhanced tile for fixed or aspect-ratio'ed clientsarg@suckless.org2007-10-241-1/+0
* added antoszka's viewprev patch with some minor modifications, restored Clien...Anselm R. Garbe2007-10-101-0/+1
* removing NULL-terminating **tags definition in config.hAnselm R. Garbe2007-10-051-1/+1
* s/xterm/uxterm/Anselm R. Garbe2007-10-011-1/+1
* fixed font definitionAnselm R. Garbe2007-10-011-1/+1
* applied Peter Hartlich's border collapse patchAnselm R. Garbe2007-09-301-7/+7
* fixed colorsAnselm R. Garbe2007-09-271-3/+3
* updated with my favorite colorschemeAnselm R. Garbe2007-09-261-7/+6
* applied colors depend from lavishs proposalAnselm R. Garbe2007-09-251-6/+6
* switching to white normal bg, renaming tag 9 into www, for static use in conj...Anselm R. Garbe2007-09-231-9/+9
* renamed config.h into config.def.h, config.h will be created if not present, ...Anselm R. Garbe2007-09-231-0/+94
#39;.split() DOCUMENT_BASENAMES = 'README TODO LICENSE COPYING INSTALL'.split() import time from . import T_FILE, T_DIRECTORY, T_UNKNOWN, T_NONEXISTANT, BAD_INFO from ranger.shared import MimeTypeAware, FileManagerAware from ranger.ext.shell_escape import shell_escape class FileSystemObject(MimeTypeAware, FileManagerAware): is_file = False is_directory = False content_loaded = False force_load = False path = None basename = None basename_lower = None _shell_escaped_basename = None _filetype = None dirname = None extension = None exists = False accessible = False marked = False tagged = False loaded = False runnable = False islink = False readlink = None stat = None infostring = None permissions = None type = T_UNKNOWN size = 0 last_used = None stopped = False video = False image = False audio = False media = False document = False container = False mimetype_tuple = () def __init__(self, path): MimeTypeAware.__init__(self) if type(self) == FileSystemObject: raise TypeError("Cannot initialize abstract class FileSystemObject") from os.path import abspath, basename, dirname, realpath path = abspath(path) self.path = path self.basename = basename(path) self.basename_lower = self.basename.lower() self.dirname = dirname(path) self.realpath = realpath(path) try: self.extension = self.basename[self.basename.rindex('.') + 1:].lower() except ValueError: self.extension = None self.set_mimetype() self.use() def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.path) @property def shell_escaped_basename(self): if self._shell_escaped_basename is None: self._shell_escaped_basename = shell_escape(self.basename) return self._shell_escaped_basename @property def filetype(self): if self._filetype is None: import subprocess try: got = subprocess.Popen(["file", '-Lb', '--mime-type',\ self.path], stdout=subprocess.PIPE).communicate()[0] except OSError: self._filetype = '' else: self._filetype = got return self._filetype def get_description(self): return "Loading " + str(self) def __str__(self): """returns a string containing the absolute path""" return str(self.path) def use(self): """mark the filesystem-object as used at the current time""" self.last_used = time.time() def is_older_than(self, seconds): """returns whether this object wasn't use()d in the last n seconds""" if seconds < 0: return True return self.last_used + seconds < time.time() def set_mimetype(self): """assign attributes such as self.video according to the mimetype""" self.mimetype = self.mimetypes.guess_type(self.basename, False)[0] if self.mimetype is None: self.mimetype = '' self.video = self.mimetype.startswith('video') self.image = self.mimetype.startswith('image') self.audio = self.mimetype.startswith('audio') self.media = self.video or self.image or self.audio self.document = self.mimetype.startswith('text') \ or (self.extension in DOCUMENT_EXTENSIONS) \ or (self.basename in DOCUMENT_BASENAMES) self.container = self.extension in CONTAINER_EXTENSIONS keys = ('video', 'audio', 'image', 'media', 'document', 'container') self.mimetype_tuple = tuple(key for key in keys if getattr(self, key)) if self.mimetype == '': self.mimetype = None def mark(self, boolean): directory = self.env.get_directory(self.dirname) directory.mark_item(self) def _mark(self, boolean): """Called by directory.mark_item() and similar functions""" self.marked = bool(boolean) def load(self): """ reads useful information about the filesystem-object from the filesystem and caches it for later use """ import os import stat from ranger.ext.human_readable import human_readable self.loaded = True try: self.stat = os.lstat(self.path) except OSError: self.stat = None self.islink = False self.accessible = False else: self.islink = stat.S_ISLNK(self.stat.st_mode) self.accessible = True if self.accessible and os.access(self.path, os.F_OK): self.exists = True self.accessible = True if os.path.isdir(self.path): self.type = T_DIRECTORY try: self.size = len(os.listdir(self.path)) self.infostring = ' %d' % self.size self.runnable = True except OSError: self.infostring = BAD_INFO self.runnable = False self.accessible = False elif os.path.isfile(self.path): self.type = T_FILE self.size = self.stat.st_size self.infostring = ' ' + human_readable(self.stat.st_size) else: self.type = T_UNKNOWN self.infostring = None else: if self.islink: self.infostring = '->' else: self.infostring = None self.type = T_NONEXISTANT self.exists = False self.runnable = False if self.islink: self.readlink = os.readlink(self.path) def get_permission_string(self): if self.permissions is not None: return self.permissions if self.accessible is False: return '----------' import stat mode = self.stat.st_mode if stat.S_ISDIR(mode): perms = ['d'] elif stat.S_ISLNK(mode): perms = ['l'] else: perms = ['-'] for who in ("USR", "GRP", "OTH"): for what in "RWX": if mode & getattr(stat, "S_I" + what + who): perms.append(what.lower()) else: perms.append('-') self.permissions = ''.join(perms) return self.permissions def load_once(self): """calls load() if it has not been called at least once yet""" if not self.loaded: self.load() return True return False def go(self): """enter the directory if the filemanager is running""" if self.fm: return self.fm.enter_dir(self.path) return False def load_if_outdated(self): """ Calls load() if the currently cached information is outdated or nonexistant. """ if self.load_once(): return True import os try: real_mtime = os.lstat(self.path).st_mtime except OSError: real_mtime = None if self.stat: cached_mtime = self.stat.st_mtime else: cached_mtime = 0 if real_mtime != cached_mtime: self.load() return True return False