aboutsummaryrefslogtreecommitdiffstats
path: root/WmiiActions.hs
diff options
context:
space:
mode:
authorJuraj Hercek <juhe_xmonad@hck.sk>2007-10-10 22:14:52 +0200
committerJuraj Hercek <juhe_xmonad@hck.sk>2007-10-10 22:14:52 +0200
commitb86fbb245fd7ff0af9fda7958cd2b80fffb09150 (patch)
tree32a3094c5281ad5e578cc02f479f5f7a9bdb82e3 /WmiiActions.hs
parent7d051febc2ac8d9b8f2c87f9cdfde808ba057a4c (diff)
downloadXMonadContrib-b86fbb245fd7ff0af9fda7958cd2b80fffb09150.tar.gz
XMonadContrib-b86fbb245fd7ff0af9fda7958cd2b80fffb09150.tar.xz
XMonadContrib-b86fbb245fd7ff0af9fda7958cd2b80fffb09150.zip
Added wmii like actions extension.
darcs-hash:20071010201452-69f16-8e1614d6ed8e8f0b7e8a407c0c5699906887fcc3.gz
Diffstat (limited to 'WmiiActions.hs')
-rw-r--r--WmiiActions.hs101
1 files changed, 101 insertions, 0 deletions
diff --git a/WmiiActions.hs b/WmiiActions.hs
new file mode 100644
index 0000000..85c0f73
--- /dev/null
+++ b/WmiiActions.hs
@@ -0,0 +1,101 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonadContrib.WmiiActions
+-- Copyright : (c) Juraj Hercek <juhe_xmonad@hck.sk>
+-- License : BSD3
+--
+-- Maintainer : Juraj Hercek <juhe_xmonad@hck.sk>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Provides `actions' as known from Wmii window manager (
+-- <http://wmii.suckless.org>). It also provides slightly better interface for
+-- running dmenu on xinerama screens. If you want to use xinerama functions,
+-- you have to apply following patch (see Dmenu.hs extension):
+-- <http://www.jcreigh.com/dmenu/dmenu-3.2-xinerama.patch>. Don't forget to
+-- recompile dmenu afterwards ;-).
+-----------------------------------------------------------------------------
+
+module XMonadContrib.WmiiActions (
+ -- * Usage
+ -- $usage
+ wmiiActions
+ , wmiiActionsXinerama
+ , executables
+ , executablesXinerama
+ ) where
+
+import XMonad
+import XMonadContrib.Dmenu (dmenu, dmenuXinerama, runProcessWithInput)
+
+import Control.Monad (filterM, liftM, liftM2)
+import System.Directory (getDirectoryContents, doesFileExist, getPermissions, executable)
+
+-- $usage
+--
+-- You can use this module with the following in your Config.hs file:
+--
+-- > import XMonadContrib.WmiiActions
+--
+-- and add following to the list of keyboard bindings:
+--
+-- > ,((modMask, xK_a), wmiiActions "/home/joe/.wmii-3.5/")
+--
+-- or, if you are using xinerama, you can use
+--
+-- > ,((modMask, xK_a), wmiiActionsXinerama "/home/joe/.wmii-3.5/")
+--
+-- however, make sure you have also xinerama build of dmenu (for more
+-- information see "XMonadContrib.Dmenu" extension).
+
+-- | The 'wmiiActions' function takes the file path as a first argument and
+-- executes dmenu with all executables found in the provided path.
+wmiiActions :: FilePath -> X ()
+wmiiActions path =
+ wmiiActionsDmenu path dmenu
+
+-- | The 'wmiiActionsXinerama' does the same as 'wmiiActions', but it shows
+-- dmenu only on workspace which currently owns focus.
+wmiiActionsXinerama :: FilePath -> X ()
+wmiiActionsXinerama path =
+ wmiiActionsDmenu path dmenuXinerama
+
+wmiiActionsDmenu :: FilePath -> ([String] -> X String) -> X ()
+wmiiActionsDmenu path dmenuBrand =
+ let path' = path ++ "/" in
+ getExecutableFileList path' >>= dmenuBrand >>= spawn . (path' ++)
+
+getExecutableFileList :: FilePath -> X [String]
+getExecutableFileList path =
+ io $ getDirectoryContents path >>=
+ filterM (\x -> let x' = path ++ x in
+ liftM2 (&&)
+ (doesFileExist x')
+ (liftM executable (getPermissions x')))
+
+{-
+getExecutableFileList :: FilePath -> X [String]
+getExecutableFileList path =
+ io $ getDirectoryContents path >>=
+ filterM (doesFileExist . (path ++)) >>=
+ filterM (liftM executable . getPermissions . (path ++))
+-}
+
+-- | The 'executables' function runs dmenu_path script providing list of
+-- executable files accessible from $PATH variable.
+executables :: X ()
+executables = executablesDmenu dmenu
+
+-- | The 'executablesXinerama' function does the same as 'executables' function
+-- but on workspace which currently owns focus.
+executablesXinerama :: X ()
+executablesXinerama = executablesDmenu dmenuXinerama
+
+executablesDmenu :: ([String] -> X String) -> X ()
+executablesDmenu dmenuBrand =
+ getExecutablesList >>= dmenuBrand >>= spawn
+
+getExecutablesList :: X [String]
+getExecutablesList =
+ io $ liftM lines $ runProcessWithInput "dmenu_path" [] ""
+