REF linted config

This commit is contained in:
Nathan Dwarshuis 2020-03-06 09:25:06 -05:00
parent f03e50662a
commit a6c4f84ed4
1 changed files with 30 additions and 22 deletions

View File

@ -1,13 +1,14 @@
module Main (main) where module Main (main) where
import Control.Monad (when, void)
import System.Exit import System.Exit
import System.IO import System.IO
import Data.Char import Data.Char
import Data.List (sortBy) import Data.List (sortBy, sortOn)
import Data.Maybe (fromMaybe, isJust) import Data.Maybe (fromMaybe, isJust)
import Data.Monoid (All(..)) import Data.Monoid (All(..))
import Data.Ord (comparing)
import Graphics.X11.Xlib.Atom import Graphics.X11.Xlib.Atom
import Graphics.X11.Xlib.Extras import Graphics.X11.Xlib.Extras
@ -108,8 +109,7 @@ myLayouts = onWorkspace myVMWorkspace (noBorders Full)
$ noBorders $ noBorders
$ tabbedAlways shrinkText myTabbedTheme $ tabbedAlways shrinkText myTabbedTheme
full = named "Full" full = named "Full"
$ noBorders $ noBorders Full
$ Full
-- gimpLayout = named "Gimp Layout" -- gimpLayout = named "Gimp Layout"
-- $ avoidStruts -- $ avoidStruts
-- $ (tabbedAlways shrinkText defaultTheme) ****||* Full -- $ (tabbedAlways shrinkText defaultTheme) ****||* Full
@ -141,14 +141,14 @@ myWindowSetXinerama ws = wsString ++ sep ++ layout
offscreen = unwords offscreen = unwords
$ map W.tag $ map W.tag
. filter (isJust . W.stack) . filter (isJust . W.stack)
. sortBy (comparing W.tag) . sortOn W.tag
$ W.hidden ws $ W.hidden ws
visColor = "#8fc7ff" visColor = "#8fc7ff"
layout = description . W.layout . W.workspace . W.current $ ws layout = description . W.layout . W.workspace . W.current $ ws
compareXCoord s0 s1 = compare x0 x1 compareXCoord s0 s1 = compare x0 x1
where where
(_, (Rectangle x0 _ _ _)) = getScreenIdAndRectangle s0 (_, Rectangle x0 _ _ _) = getScreenIdAndRectangle s0
(_, (Rectangle x1 _ _ _)) = getScreenIdAndRectangle s1 (_, Rectangle x1 _ _ _) = getScreenIdAndRectangle s1
myManageHook = composeOne myManageHook = composeOne
-- assume virtualbox is not run with the toolbar in fullscreen mode -- assume virtualbox is not run with the toolbar in fullscreen mode
@ -190,21 +190,30 @@ myManageHook = composeOne
-- BITMAP atom (which should do nothing) and a "magic string" in the -- BITMAP atom (which should do nothing) and a "magic string" in the
-- data field that can be intercepted here. When this event is -- data field that can be intercepted here. When this event is
-- registered here, close the dynamic workspaces that are empty. -- registered here, close the dynamic workspaces that are empty.
myEventHook (ClientMessageEvent { ev_message_type = t, ev_data = d }) myEventHook ClientMessageEvent { ev_message_type = t, ev_data = d }
| t == bITMAP = do | t == bITMAP = do
let (magic, tag) = splitAt 5 $ map (chr . fromInteger . toInteger) d let (magic, tag) = splitAt 5 $ map (chr . fromInteger . toInteger) d
io $ putStrLn magic io $ putStrLn magic
if magic == magicString then do when (magic == magicString) $ do
let tag' = filter isAlphaNum tag let tag' = filter isAlphaNum tag
io $ putStrLn (show tag') removeEmptyWorkspaceByTag' tag'
-- TODO this actually won't remove an empty workspace if -- let onscreen = (\w -> W.current w : W.visible w) W.workspaces windows
-- there are the same number of active workspaces as screens -- io $ putStrLn (show tag')
removeEmptyWorkspaceByTag tag' -- -- TODO this actually won't remove an empty workspace if
else return () -- -- there are the same number of active workspaces as screens
-- removeEmptyWorkspaceByTag tag'
return (All True) return (All True)
| otherwise = return (All True) | otherwise = return (All True)
myEventHook _ = do myEventHook _ = return (All True)
return (All True)
removeEmptyWorkspaceByTag' tag = do
-- TODO this function works by first hiding the workspace to be
-- removed and then removing it. This won't work if there are no
-- other hidden workspaces to take it's place. So, need to scan
-- through the list of workspaces and swap the first one that is
-- empty with the workspace to be removed. If it actually is empty,
-- this will be enough to make it disappear.
removeEmptyWorkspaceByTag tag
-- themes -- themes
myFont = "xft:DejaVu Sans:size=11:autohint=false" myFont = "xft:DejaVu Sans:size=11:autohint=false"
@ -267,7 +276,7 @@ myPowerPrompt = mkXPrompt PowerPrompt conf comps
$ fromMaybe (return ()) $ fromMaybe (return ())
. (`lookup` commands) . (`lookup` commands)
where where
comps = (mkComplFunFromList' (map fst commands)) comps = mkComplFunFromList' (map fst commands)
conf = myPromptTheme conf = myPromptTheme
commands = commands =
[ ("poweroff", spawn "systemctl poweroff") [ ("poweroff", spawn "systemctl poweroff")
@ -406,9 +415,9 @@ myKeys c =
, ("<XF86AudioPrev>", addName "previous track" $ spawn "playerctl previous") , ("<XF86AudioPrev>", addName "previous track" $ spawn "playerctl previous")
, ("<XF86AudioNext>", addName "next track" $ spawn "playerctl next") , ("<XF86AudioNext>", addName "next track" $ spawn "playerctl next")
, ("<XF86AudioStop>", addName "stop" $ spawn "playerctl stop") , ("<XF86AudioStop>", addName "stop" $ spawn "playerctl stop")
, ("<XF86AudioLowerVolume>", addName "volume down" $ lowerVolume 2 >> return ()) , ("<XF86AudioLowerVolume>", addName "volume down" $ void (lowerVolume 2))
, ("<XF86AudioRaiseVolume>", addName "volume up" $ raiseVolume 2 >> return ()) , ("<XF86AudioRaiseVolume>", addName "volume up" $ void (raiseVolume 2))
, ("<XF86AudioMute>", addName "volume mute" $ toggleMute >> return ()) , ("<XF86AudioMute>", addName "volume mute" $ void toggleMute)
, ("M-C-b", addName "toggle bluetooth" $ spawn "togglebt") , ("M-C-b", addName "toggle bluetooth" $ spawn "togglebt")
] ++ ] ++
@ -421,6 +430,5 @@ myKeys c =
, ("M-S-<F2>", addName "recompile xmonad" $ spawn "killall xmobar; xmonad --recompile && xmonad --restart") , ("M-S-<F2>", addName "recompile xmonad" $ spawn "killall xmobar; xmonad --recompile && xmonad --restart")
, ("M-<End>", addName "power menu" myPowerPrompt) , ("M-<End>", addName "power menu" myPowerPrompt)
, ("M-<Home>", addName "quit xmonad" $ , ("M-<Home>", addName "quit xmonad" $
confirmPrompt myPromptTheme "Quit XMonad?" $ confirmPrompt myPromptTheme "Quit XMonad?" $ io exitSuccess)
io (exitWith ExitSuccess))
] ]