Created
December 15, 2010 13:42
-
-
Save itayd/741949 to your computer and use it in GitHub Desktop.
xmonad grid browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- grid browser | |
-- excerpt from xmonad.hs | |
gridBrowse cwd' = do | |
refresh | |
cwd <- liftIO $ canonicalizePath cwd' | |
isdir <- liftIO $ doesDirectoryExist cwd | |
if isdir | |
then do | |
ls <- liftIO $ getDirectoryContents cwd >>= markdirs | |
let ls' = if cwd == "/" then togs ls else ("../",cwd ++ "/.."):togs ls | |
gridselect (buildDefaultGSConfig colorizer) ls' >>= flip whenJust gridBrowse | |
else do | |
perms <- liftIO $ getPermissions cwd | |
spawn $ if executable perms then cwd | |
else "/usr/bin/xdg-open \"" ++ cwd ++ "\"" | |
where | |
togs = map (\l -> (l,cwd' ++ "/" ++ l)) . filter (not . isPrefixOf ".") | |
markdirs = mapM $ \l -> do | |
isdir <- doesDirectoryExist (cwd' ++ "/" ++ l) | |
return $ l ++ if isdir then "/" else "" | |
colorizer s b = do | |
c <- stringColorizer s b | |
return $ if last s == '/' then (fst c, "black") else c | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment