diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-14 19:59:46 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-09-14 19:59:46 +0200 |
commit | c0b549b5775a4c026925795356ce10c6b97c6c5d (patch) | |
tree | a1bacace20942041531a6f3010b98101485750ab | |
parent | 9734b2f51f9c94ec802820bc57fe50297a5dec77 (diff) | |
parent | 1a40e23790fe41d3048d841166e17428c7c06644 (diff) | |
download | xmonad-config-c0b549b5775a4c026925795356ce10c6b97c6c5d.tar.gz xmonad-config-c0b549b5775a4c026925795356ce10c6b97c6c5d.tar.xz xmonad-config-c0b549b5775a4c026925795356ce10c6b97c6c5d.zip |
Merge remote-tracking branch 'origin/master'
* origin/master:
xmonad.hs: Add confirmation to logout.
xmonad.hs: Do not use M5 on host "Australien"
lib/Pass: Code style.
lib/Confirm: Add simple confirmation with grid select.
shorter xpropmatches
Australien does not have a key for mod4
use our font for all prompts
add M-M5-q for clean logout
remove stuff for taffybar
-rw-r--r-- | lib/Confirm.hs | 11 | ||||
-rw-r--r-- | lib/Pass.hs | 7 | ||||
-rw-r--r-- | xmonad.hs | 155 |
3 files changed, 100 insertions, 73 deletions
diff --git a/lib/Confirm.hs b/lib/Confirm.hs new file mode 100644 index 0000000..47e3388 --- /dev/null +++ b/lib/Confirm.hs @@ -0,0 +1,11 @@ +module Confirm (confirm) where + +import Control.Monad + +import XMonad.Core +import XMonad.Actions.GridSelect + +confirm :: GSConfig Bool -> String -> X() -> X() +confirm config string action = do + res <- gridselect config [(string, True), ("No", False)] + whenJust res (\x -> when x action) diff --git a/lib/Pass.hs b/lib/Pass.hs index f29df27..c9b70df 100644 --- a/lib/Pass.hs +++ b/lib/Pass.hs @@ -1,4 +1,3 @@ - ----------------------------------------------------------------------------- -- | -- Module : Pass @@ -131,7 +130,11 @@ generatePassword passLabel = safeSpawn "pass" ["generate", "--force", passLabel, getPasswords :: IO [String] getPasswords = do home <- getHomeDirectory - files <- runProcessWithInput "find" [home ++ "/.password-store","-type", "f", "-name", "*.gpg", "-printf", "%P\n"] [] + files <- runProcessWithInput "find" [ + home ++ "/.password-store", + "-type", "f", + "-name", "*.gpg", + "-printf", "%P\n"] [] return $ map removeGpgExtension $ lines files removeGpgExtension :: String -> String @@ -1,5 +1,7 @@ import System.IO import System.Directory +import System.Exit (exitWith, ExitCode(ExitSuccess)) +import Codec.Binary.UTF8.String as UTF8 (decodeString) import Data.Ratio ((%)) import Data.List import qualified Data.Map as M @@ -53,9 +55,6 @@ import XMonad.Prompt.XMonad import XMonad.Util.NamedScratchpad --- taffybar -import System.Taffybar.Hooks.PagerHints (pagerHints) - -- --replace handling import XMonad.Util.Replace (replace) import Control.Monad (when) @@ -64,10 +63,14 @@ import System.Environment (getArgs) import Data.Maybe (fromMaybe, fromJust, isNothing, isJust) import Data.Ord (comparing) +-- for hostname handling (no windows key on "Australien") +import Network.HostName + -- custom modules import HistoryGrid import EZConfig import Pass +import qualified Confirm font :: String font = "xft:Hack:size=10" @@ -79,7 +82,10 @@ browser :: String browser = "browser" -modM = mod4Mask -- mod1Mask = Alt, mod2Mask = , mod3Mask= , mod4Mask = Win, mod5Mask = AltGr +modM :: String -> KeyMask +-- mod1Mask = Alt, mod2Mask = , mod3Mask= , mod4Mask = Win, mod5Mask = AltGrk +modM "Australien" = mod1Mask +modM _ = mod4Mask myDzenUrgencyConfig = DzenUrgencyHook { args = ["-bg", "red", "-fg", "black", "-fn", font, @@ -96,26 +102,27 @@ main = do dzenStatusDir <- getAppUserDataDirectory "xmonad" dzenStatusFile <- openFile (dzenStatusDir ++ "/dzenStatus") WriteMode + hostname <- getHostName xmonad -- Do _not_ use "ewhm" here, this would add the ewhm hooks to the -- end of your custom hooks (esp. the startup hook) and this would -- overwrite the setWMName "LG3D" and some Java apps will not work. - $ pagerHints $ withUrgencyHook myDzenUrgencyConfig - $ defaultConfig { modMask = modM + $ defaultConfig { modMask = modM hostname , terminal = term , borderWidth = 1 , normalBorderColor = "#545454" , focusedBorderColor = "#A00000" , logHook = myLogHook dzenStatusFile , manageHook = myManageHook - , keys = \c -> mkKeymap c $ myKeys c - , mouseBindings = \c -> M.union (M.fromList $ myMouse c) $ mouseBindings defaultConfig c + , keys = \c -> mkKeymap c $ myKeys c hostname + , mouseBindings = \c -> M.union (M.fromList $ myMouse (modM hostname) c) $ mouseBindings defaultConfig c , layoutHook = myLayout , workspaces = topics , handleEventHook = myEventHook , startupHook = myStartupHook } + --}}} --{{{ TopicSpaces @@ -256,6 +263,11 @@ alexTheme = defaultTheme , decoHeight = 19 } +alexXPConfig :: XPConfig +alexXPConfig = P.defaultXPConfig + { P.font = font + } + historyGridConfig = defaultGSConfig { gs_cellheight = 50 , gs_cellwidth = 300 @@ -273,6 +285,19 @@ topicsGridConfig = defaultGSConfig | selected = return ("#839596", "#002b36") | otherwise = return ("#002b36", "#839496") +confirmConfig :: HasColorizer a => GSConfig a +confirmConfig = defaultGSConfig + { gs_cellheight = 150 + , gs_cellwidth = 300 + , gs_cellpadding = 50 + , gs_font = "xft:Droid Sans Mono Slashed Bold-35" + , gs_originFractX = (1/2) + , gs_originFractY = (1/3) + } + +confirm :: String -> X() -> X() +confirm = Confirm.confirm confirmConfig + --}}} --{{{ Hooks @@ -350,62 +375,47 @@ myManageHook = xPropMatches :: [XPropMatch] xPropMatches = - [ ([ (xprop, any (app `op`))], pmP (W.shift target)) | (xprop, op, app, target) <- myShifts] ++ - [ ([ (xprop, any (app ==))], pmX (float)) | (xprop, app) <- myFloats] + [ (match, pmP $ W.shift target) | (target, match) <- shifts] ++ + [ (match, pmX $ float) | match <- floats] where - myFloats = - [ (wM_CLASS, "vlc") - , (wM_CLASS, "Xmessage") - , (wM_CLASS, "XVkbd") - , (wM_CLASS, "Xdialog") - , (wM_CLASS, "Pinentry") - , (wM_CLASS, "Pinentry-gtk-2") - , (wM_CLASS, "Tiemu") - , (wM_CLASS, "ultrastardx") - , (wM_CLASS, "Ediff") - , (wM_CLASS, "xtensoftphone") - , (wM_CLASS, "Pqiv") - , (wM_CLASS, "XNots") - , (wM_CLASS, "TeamViewer.exe") - , (wM_CLASS, "AmsnWebcam") - , (wM_NAME, "glxgears") - , (wM_NAME, "Passphrase Required") - , (wM_NAME, "Mark all as read") - , (wM_NAME, "Xplanet 1.2.0") - , (wM_NAME, "Eclipse") - ] - - myShifts = - [ (wM_CLASS, (==), "Opera", "web") - , (wM_CLASS, (==), "Chrome", "web") - , (wM_CLASS, (==), "Chromium-browser", "web") - , (wM_CLASS, (==), "Firefox-bin", "web") - - , (wM_CLASS, (==), "Claws-mail", "mail") - , (wM_CLASS, (==), "Mitter", "mail") - , (wM_CLASS, (==), "wanderlust", "mail") - , (wM_NAME, (==), "newsbeuter", "mail") - - , (wM_CLASS, (==), "Hexchat", "irc") - - -- tkabber roater - , (wM_CLASS, (==), "Tkabber", "im") - -- tkabber single messages - , (wM_CLASS, (==), "headlines", "im") - , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_zedatconferencejabberfuberlinde", "im") - , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_mailanimuxdeSyslogBot", "im") - - , (wM_CLASS, (==), "MPlayer", "video") - , (wM_CLASS, (==), "Amarokapp", "music") - ] + floats = [ [(wM_CLASS, anyOf ["vlc", "Xmessage", "XVkbd", "Xdialog", + "Pinentry", "Pinentry-gtk-2", "Tiemu", + "ultrastardx", "Ediff", "xtensoftphone", + "Pqiv", "XNots", "TeamViewer.exe", + "AmsnWebcam"])] + , [(wM_NAME, anyOf ["glxgears", "Passphrase Required", + "Mark all as read", "Xplanet 1.2.0", + "Eclipse"])] + ] + + shifts = [ ("web", [(wM_CLASS, anyOf ["Opera", "Chrome", "Google-chrome", "Chromium-browser", + "Firefox-bin"])]) + , ("mail", [(wM_CLASS, anyOf ["Claws-mail", "Evolution", "Mitter", "wanderlust"])]) + , ("mail", [(wM_NAME, anyOf ["newsbeuter"])]) + , ("irc", [(wM_CLASS, anyOf ["Hexchat"])]) + , ("im", [(wM_CLASS, anyOf ["TKabber", "headlines", "Vacuum"])]) + + -- tkabber single messages + , ("im", [(wM_CLASS, anyOf' isPrefixOf ["chat_##xmpp##1_zedatconferencejabberfuberlinde", + "chat_##xmpp##1_mailanimuxdeSyslogBot"])]) + + , ("code", [(wM_CLASS, anyOf ["emacs"])]) + + , ("video", [(wM_CLASS, anyOf ["MPlayer"])]) + , ("music", [(wM_CLASS, anyOf ["Amarokapp"])]) + ] + + anyOf' op valids tests = any (\test -> any (\valid -> op valid test) valids) tests + anyOf = anyOf' (==) --}}} --{{{ Keys -myKeys c = +myKeys c hostname = -- this line is critical to reload config - DON'T REMOVE [ ("M-q", broadcastMessage ReleaseResources >> restart "xmonad" True) + , (shutdownKey, confirm "Logout?" $ io (exitWith ExitSuccess)) , ("M-S-<Return>", spawn term) , ("M-<Return>", openLastHistoryGrid historyGridConfig 30) @@ -429,8 +439,8 @@ myKeys c = , ("M-S-j", windows W.swapDown) , ("M-S-k", windows W.swapUp) - , ("M-m", selectWorkspace P.defaultXPConfig) - , ("M-S-m", withWorkspace P.defaultXPConfig (windows . W.shift)) + , ("M-m", selectWorkspace alexXPConfig) + , ("M-S-m", withWorkspace alexXPConfig (windows . W.shift)) , ("M-S-<Backspace>", removeWorkspace) , ("M-h", sendMessage Shrink) @@ -458,15 +468,15 @@ myKeys c = , ("M-^", focusUrgent) - , ("M-p", myShellPrompt P.defaultXPConfig) - , ("M-e", launchApp P.defaultXPConfig "emacsclient" >> (windows (W.greedyView "5:code"))) + , ("M-p", myShellPrompt alexXPConfig) + , ("M-e", launchApp alexXPConfig "emacsclient" >> (windows (W.greedyView "5:code"))) - , ("M-o M-k", passPrompt P.defaultXPConfig) - , ("M-o M-S-k", passGeneratePrompt P.defaultXPConfig) - , ("M-o M-m", manPrompt P.defaultXPConfig) - , ("M-o M-b", safePrompt browser P.defaultXPConfig) - , ("M-o M-s", sshPrompt P.defaultXPConfig) - , ("M-o M-x", xmonadPrompt P.defaultXPConfig) + , ("M-o M-k", passPrompt alexXPConfig) + , ("M-o M-S-k", passGeneratePrompt alexXPConfig) + , ("M-o M-m", manPrompt alexXPConfig) + , ("M-o M-b", safePrompt browser alexXPConfig) + , ("M-o M-s", sshPrompt alexXPConfig) + , ("M-o M-x", xmonadPrompt alexXPConfig) , ("M-+", sendMessage Mag.MagnifyMore) , ("M-S-+", sendMessage Mag.MagnifyLess) @@ -492,16 +502,19 @@ myKeys c = | (a, m) <- [(switchNthLastFocused topicsConfig,""), (shiftNthLastFocused, "S-")] , (i, k) <- zip [1..] "123456789" ] + where + shutdownKey = case hostname of + "Australien" -> "M-S-q" + _ -> "M-M5-q" - -myMouse c = - [ ((modM, button1), +myMouse modm c = + [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w >> snapMagicMove (Just 50) (Just 50) w)) - , ((modM .|. shiftMask, button1), + , ((modm .|. shiftMask, button1), (\w -> focus w >> mouseMoveWindow w >> snapMagicMouseResize 0.8 (Just 50) (Just 50) w)) - , ((modM, button3), + , ((modm, button3), (\w -> focus w >> Flex.mouseWindow Flex.resize w)) ] |