2022-12-30 14:58:23 -05:00
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2020-03-28 19:58:26 -04:00
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
2022-12-30 14:58:23 -05:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2022-12-31 23:56:23 -05:00
|
|
|
{-# LANGUAGE RankNTypes #-}
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- XMonad binary
|
2020-04-01 22:06:00 -04:00
|
|
|
|
2020-03-15 15:50:07 -04:00
|
|
|
module Main (main) where
|
|
|
|
|
2022-12-30 14:58:23 -05:00
|
|
|
import Data.Internal.DBus
|
2023-01-01 18:33:02 -05:00
|
|
|
import Data.Internal.XIO
|
2022-12-30 14:58:23 -05:00
|
|
|
import Data.Monoid
|
|
|
|
import Data.Text.IO (hPutStrLn)
|
|
|
|
import Graphics.X11.Types
|
|
|
|
import Graphics.X11.Xlib.Atom
|
|
|
|
import Graphics.X11.Xlib.Extras
|
2023-01-01 11:41:04 -05:00
|
|
|
import Options.Applicative hiding (action)
|
2022-12-30 14:58:23 -05:00
|
|
|
import RIO
|
|
|
|
import RIO.Directory
|
2022-12-31 19:47:02 -05:00
|
|
|
import RIO.List
|
2022-12-30 14:58:23 -05:00
|
|
|
import RIO.Process
|
|
|
|
import qualified RIO.Text as T
|
|
|
|
import System.Posix.Signals
|
|
|
|
import System.Process
|
|
|
|
( getPid
|
|
|
|
, getProcessExitCode
|
|
|
|
)
|
|
|
|
import XMonad
|
|
|
|
import XMonad.Actions.CopyWindow
|
|
|
|
import XMonad.Actions.CycleWS
|
|
|
|
import XMonad.Actions.PhysicalScreens
|
|
|
|
import XMonad.Actions.Warp
|
|
|
|
import XMonad.Hooks.DynamicLog
|
|
|
|
import XMonad.Hooks.EwmhDesktops
|
|
|
|
import XMonad.Hooks.ManageDocks
|
|
|
|
import XMonad.Hooks.ManageHelpers
|
|
|
|
import XMonad.Internal.Command.DMenu
|
|
|
|
import XMonad.Internal.Command.Desktop
|
|
|
|
import XMonad.Internal.Command.Power
|
|
|
|
import XMonad.Internal.Concurrent.ACPIEvent
|
|
|
|
import XMonad.Internal.Concurrent.ClientMessage
|
|
|
|
import XMonad.Internal.Concurrent.DynamicWorkspaces
|
|
|
|
import XMonad.Internal.Concurrent.VirtualBox
|
|
|
|
import XMonad.Internal.DBus.Brightness.ClevoKeyboard
|
|
|
|
import XMonad.Internal.DBus.Brightness.Common
|
|
|
|
import XMonad.Internal.DBus.Brightness.IntelBacklight
|
|
|
|
import XMonad.Internal.DBus.Control
|
|
|
|
import XMonad.Internal.DBus.Removable
|
|
|
|
import XMonad.Internal.DBus.Screensaver
|
|
|
|
import XMonad.Internal.Shell hiding (proc)
|
|
|
|
import qualified XMonad.Internal.Theme as XT
|
|
|
|
import XMonad.Layout.MultiToggle
|
|
|
|
import XMonad.Layout.NoBorders
|
|
|
|
import XMonad.Layout.NoFrillsDecoration
|
|
|
|
import XMonad.Layout.PerWorkspace
|
|
|
|
import XMonad.Layout.Renamed
|
|
|
|
import XMonad.Layout.Tabbed
|
|
|
|
import qualified XMonad.Operations as O
|
|
|
|
import qualified XMonad.StackSet as W
|
|
|
|
import XMonad.Util.Cursor
|
|
|
|
import XMonad.Util.EZConfig
|
|
|
|
import qualified XMonad.Util.ExtensibleState as E
|
|
|
|
import XMonad.Util.NamedActions
|
|
|
|
import XMonad.Util.WorkspaceCompare
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2020-03-20 01:15:22 -04:00
|
|
|
main :: IO ()
|
2023-01-01 11:41:04 -05:00
|
|
|
main = parse >>= xio
|
2022-06-14 23:46:24 -04:00
|
|
|
|
2023-01-01 11:41:04 -05:00
|
|
|
parse :: IO XOpts
|
|
|
|
parse = execParser opts
|
|
|
|
where
|
|
|
|
parseOpts = parseDeps <|> parseTest <|> pure XRun
|
|
|
|
opts =
|
|
|
|
info (parseOpts <**> helper) $
|
|
|
|
fullDesc <> header "xmonad: the best window manager ever"
|
|
|
|
|
|
|
|
data XOpts = XDeps | XTest | XRun
|
|
|
|
|
|
|
|
parseDeps :: Parser XOpts
|
|
|
|
parseDeps =
|
|
|
|
flag'
|
|
|
|
XDeps
|
|
|
|
(long "deps" <> short 'd' <> help "print dependencies")
|
2022-06-14 23:46:24 -04:00
|
|
|
|
2023-01-01 11:41:04 -05:00
|
|
|
parseTest :: Parser XOpts
|
|
|
|
parseTest =
|
|
|
|
flag'
|
|
|
|
XTest
|
|
|
|
(long "test" <> short 't' <> help "test dependencies without running")
|
|
|
|
|
|
|
|
xio :: XOpts -> IO ()
|
2023-01-01 15:00:40 -05:00
|
|
|
xio o = runXIO $
|
2023-01-01 11:41:04 -05:00
|
|
|
case o of
|
|
|
|
XDeps -> printDeps
|
|
|
|
XTest -> undefined
|
|
|
|
XRun -> run
|
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
run :: XIO ()
|
2022-06-14 23:46:24 -04:00
|
|
|
run = do
|
2022-12-27 14:13:13 -05:00
|
|
|
-- These first two commands are only significant when xmonad is restarted.
|
|
|
|
-- The 'launch' function below this will turn off buffering (so flushes are
|
|
|
|
-- required to see stdout) and will also install xmonad's silly signal
|
|
|
|
-- handlers (which set the handlers for sigCHLD and sigPIPE to SIG_IGN).
|
|
|
|
-- Ignoring sigCHLD is particularly bad since most of my setup entails
|
|
|
|
-- spawning processes and waiting for their exit code, which totally breaks
|
|
|
|
-- when sigCHLD is ignored (since children are killed immediately without
|
|
|
|
-- the parent invoking 'wait'). Since the 'launch' function is called last
|
|
|
|
-- here, everything before should be fine except for the case where xmonad
|
|
|
|
-- is restarted, which uses 'exec' and thus should cause the buffering and
|
|
|
|
-- signal handlers to carry over to the top.
|
|
|
|
uninstallSignalHandlers
|
|
|
|
hSetBuffering stdout LineBuffering
|
2023-01-01 11:41:04 -05:00
|
|
|
withDBusX_ $ \db -> do
|
|
|
|
let fs = features $ dbSysClient db
|
2023-01-01 13:07:10 -05:00
|
|
|
withDBusInterfaces db (fsDBusExporters fs) $ \unexporters -> do
|
2023-01-01 12:43:54 -05:00
|
|
|
withXmobar $ \xmobarP -> do
|
|
|
|
withChildDaemons fs $ \ds -> do
|
2023-01-01 13:07:10 -05:00
|
|
|
let toClean = Cleanup ds (Just xmobarP) unexporters
|
2023-01-01 12:43:54 -05:00
|
|
|
void $ executeSometimes $ fsRemovableMon fs $ dbSysClient db
|
|
|
|
void $ async $ void $ executeSometimes $ fsPowerMon fs
|
|
|
|
dws <- startDynWorkspaces fs
|
|
|
|
runIO <- askRunInIO
|
2023-01-01 13:07:10 -05:00
|
|
|
let cleanup = runCleanup runIO toClean db
|
2023-01-02 12:33:37 -05:00
|
|
|
kbs <- filterExternal <$> evalExternal (fsKeys fs runIO cleanup db)
|
2023-01-01 12:43:54 -05:00
|
|
|
sk <- evalAlways $ fsShowKeys fs
|
|
|
|
ha <- evalAlways $ fsACPIHandler fs
|
|
|
|
tt <- evalAlways $ fsTabbedTheme fs
|
|
|
|
let conf =
|
|
|
|
ewmh $
|
2023-01-02 19:44:17 -05:00
|
|
|
addKeymap dws (liftIO . runIO . sk) kbs $
|
2023-01-01 12:43:54 -05:00
|
|
|
docks $
|
|
|
|
def
|
|
|
|
{ terminal = myTerm
|
|
|
|
, modMask = myModMask
|
|
|
|
, layoutHook = myLayouts tt
|
|
|
|
, manageHook = myManageHook dws
|
|
|
|
, handleEventHook = myEventHook runIO ha
|
|
|
|
, startupHook = myStartupHook
|
|
|
|
, workspaces = myWorkspaces
|
|
|
|
, logHook = myLoghook xmobarP
|
|
|
|
, clickJustFocuses = False
|
|
|
|
, focusFollowsMouse = False
|
|
|
|
, normalBorderColor = T.unpack XT.bordersColor
|
|
|
|
, focusedBorderColor = T.unpack XT.selectedBordersColor
|
|
|
|
}
|
|
|
|
io $ runXMonad conf
|
2022-12-28 00:46:48 -05:00
|
|
|
where
|
|
|
|
startDynWorkspaces fs = do
|
|
|
|
dws <- catMaybes <$> mapM evalSometimes (fsDynWorkspaces fs)
|
2023-01-01 19:23:31 -05:00
|
|
|
void $ async $ runWorkspaceMon dws
|
2022-12-28 00:46:48 -05:00
|
|
|
return dws
|
|
|
|
|
2022-12-28 12:19:44 -05:00
|
|
|
runXMonad :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO ()
|
|
|
|
runXMonad conf = do
|
|
|
|
dirs <- getCreateDirectories
|
|
|
|
launch conf dirs
|
|
|
|
|
2022-07-24 13:28:33 -04:00
|
|
|
getCreateDirectories :: IO Directories
|
|
|
|
getCreateDirectories = do
|
|
|
|
ds <- getDirectories
|
|
|
|
mapM_ (createIfMissing ds) [dataDir, cfgDir, cacheDir]
|
|
|
|
return ds
|
|
|
|
where
|
|
|
|
createIfMissing ds f = do
|
|
|
|
let d = f ds
|
2022-12-28 12:19:44 -05:00
|
|
|
r <- tryIO $ createDirectoryIfMissing True d
|
2022-07-24 13:28:33 -04:00
|
|
|
case r of
|
|
|
|
(Left e) -> print e
|
2022-12-30 14:58:23 -05:00
|
|
|
_ -> return ()
|
2022-07-24 13:28:33 -04:00
|
|
|
|
2022-07-03 18:23:32 -04:00
|
|
|
data FeatureSet = FeatureSet
|
2023-01-02 12:33:37 -05:00
|
|
|
{ fsKeys :: (XIO () -> IO ()) -> X () -> DBusState -> [KeyGroup FeatureX]
|
2023-01-01 15:00:40 -05:00
|
|
|
, fsDBusExporters :: [Maybe SesClient -> Sometimes (XIO (), XIO ())]
|
2022-12-30 14:58:23 -05:00
|
|
|
, fsPowerMon :: SometimesIO
|
|
|
|
, fsRemovableMon :: Maybe SysClient -> SometimesIO
|
2023-01-01 15:00:40 -05:00
|
|
|
, fsDaemons :: [Sometimes (XIO (Process () () ()))]
|
2022-12-30 14:58:23 -05:00
|
|
|
, fsACPIHandler :: Always (String -> X ())
|
|
|
|
, fsTabbedTheme :: Always Theme
|
2022-07-03 18:23:32 -04:00
|
|
|
, fsDynWorkspaces :: [Sometimes DynWorkspace]
|
2023-01-02 19:44:17 -05:00
|
|
|
, fsShowKeys :: Always ([((KeyMask, KeySym), NamedAction)] -> XIO ())
|
2022-07-03 18:23:32 -04:00
|
|
|
}
|
|
|
|
|
2022-07-06 18:54:10 -04:00
|
|
|
tabbedFeature :: Always Theme
|
|
|
|
tabbedFeature = Always "theme for tabbed windows" $ Option sf fallback
|
|
|
|
where
|
2022-07-08 19:02:49 -04:00
|
|
|
sf = Subfeature niceTheme "theme with nice font"
|
2022-12-26 14:45:49 -05:00
|
|
|
niceTheme = IORoot XT.tabbedTheme $ fontTree XT.defFontFamily defFontPkgs
|
|
|
|
fallback = Always_ $ FallbackAlone $ XT.tabbedTheme XT.fallbackFont
|
2022-07-06 18:54:10 -04:00
|
|
|
|
2022-07-09 17:08:10 -04:00
|
|
|
features :: Maybe SysClient -> FeatureSet
|
2022-12-30 14:58:23 -05:00
|
|
|
features cl =
|
|
|
|
FeatureSet
|
|
|
|
{ fsKeys = externalBindings
|
|
|
|
, fsDBusExporters = dbusExporters
|
|
|
|
, fsPowerMon = runPowermon
|
|
|
|
, fsRemovableMon = runRemovableMon
|
|
|
|
, fsACPIHandler = runHandleACPI
|
|
|
|
, fsDynWorkspaces = allDWs'
|
|
|
|
, fsTabbedTheme = tabbedFeature
|
|
|
|
, fsShowKeys = runShowKeys
|
|
|
|
, fsDaemons = [runNetAppDaemon cl, runAutolock]
|
|
|
|
}
|
2022-07-03 18:23:32 -04:00
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
withXmobar :: (Process Handle () () -> XIO a) -> XIO a
|
2023-01-01 12:07:43 -05:00
|
|
|
withXmobar = bracket startXmobar stopXmobar
|
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
startXmobar :: XIO (Process Handle () ())
|
2022-12-28 00:46:48 -05:00
|
|
|
startXmobar = do
|
2023-01-01 14:57:23 -05:00
|
|
|
logInfo "starting xmobar child process"
|
2022-12-28 14:18:39 -05:00
|
|
|
p <- proc "xmobar" [] start
|
2022-12-28 00:46:48 -05:00
|
|
|
io $ hSetBuffering (getStdin p) LineBuffering
|
|
|
|
return p
|
2022-12-28 14:18:39 -05:00
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
start =
|
|
|
|
startProcess
|
|
|
|
. setStdin createPipe
|
|
|
|
. setCreateGroup True
|
2022-12-28 00:46:48 -05:00
|
|
|
|
2023-01-01 12:07:43 -05:00
|
|
|
stopXmobar
|
|
|
|
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
|
|
|
=> Process Handle () ()
|
|
|
|
-> m ()
|
|
|
|
stopXmobar p = do
|
|
|
|
logInfo "stopping xmobar child process"
|
|
|
|
io $ killNoWait p
|
2022-12-28 00:46:48 -05:00
|
|
|
|
2023-01-01 14:57:23 -05:00
|
|
|
withChildDaemons
|
|
|
|
:: FeatureSet
|
2023-01-01 15:00:40 -05:00
|
|
|
-> ([(Utf8Builder, Process () () ())] -> XIO a)
|
|
|
|
-> XIO a
|
2023-01-01 12:07:43 -05:00
|
|
|
withChildDaemons fs = bracket (startChildDaemons fs) stopChildDaemons
|
2022-12-28 00:46:48 -05:00
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
startChildDaemons :: FeatureSet -> XIO [(Utf8Builder, Process () () ())]
|
2023-01-01 14:57:23 -05:00
|
|
|
startChildDaemons fs = catMaybes <$> mapM start (fsDaemons fs)
|
|
|
|
where
|
|
|
|
start s@(Sometimes sname _ _) = do
|
|
|
|
let sname_ = Utf8Builder $ encodeUtf8Builder sname
|
|
|
|
res <- executeSometimes s
|
|
|
|
case res of
|
|
|
|
Just p -> do
|
|
|
|
logInfo $ "starting child process: " <> sname_
|
|
|
|
return $ Just (sname_, p)
|
|
|
|
-- don't log anything here since presumably the feature itself will log
|
|
|
|
-- an error if it fails during execution
|
|
|
|
_ -> return Nothing
|
2023-01-01 12:07:43 -05:00
|
|
|
|
|
|
|
stopChildDaemons
|
|
|
|
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
2023-01-01 14:57:23 -05:00
|
|
|
=> [(Utf8Builder, Process () () ())]
|
2023-01-01 12:07:43 -05:00
|
|
|
-> m ()
|
2023-01-01 14:57:23 -05:00
|
|
|
stopChildDaemons = mapM_ stop
|
|
|
|
where
|
|
|
|
stop (n, p) = do
|
|
|
|
logInfo $ "stopping child process: " <> n
|
|
|
|
liftIO $ killNoWait p
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
printDeps :: XIO ()
|
2022-12-31 22:55:32 -05:00
|
|
|
printDeps = withDBus_ $ \db -> do
|
2023-01-01 13:07:10 -05:00
|
|
|
runIO <- askRunInIO
|
|
|
|
let mockCleanup = runCleanup runIO mockClean db
|
|
|
|
let bfs =
|
|
|
|
concatMap (fmap kbMaybeAction . kgBindings) $
|
2023-01-02 12:33:37 -05:00
|
|
|
externalBindings runIO mockCleanup db
|
2023-01-01 13:07:10 -05:00
|
|
|
let dbus =
|
|
|
|
fmap (\f -> f $ dbSesClient db) dbusExporters
|
2023-01-01 15:00:40 -05:00
|
|
|
:: [Sometimes (XIO (), XIO ())]
|
2023-01-01 13:07:10 -05:00
|
|
|
let others = [runRemovableMon $ dbSysClient db, runPowermon]
|
2023-01-01 11:20:15 -05:00
|
|
|
-- TODO might be better to use glog for this?
|
2023-01-01 11:14:58 -05:00
|
|
|
mapM_ logInfo $
|
2022-12-31 22:55:32 -05:00
|
|
|
fmap showFulfillment $
|
|
|
|
sort $
|
|
|
|
nub $
|
|
|
|
concat $
|
2023-01-01 13:07:10 -05:00
|
|
|
fmap dumpSometimes dbus
|
|
|
|
++ fmap dumpSometimes others
|
|
|
|
++ fmap dumpSometimes allDWs'
|
|
|
|
++ fmap dumpFeature bfs
|
2022-06-28 21:24:21 -04:00
|
|
|
where
|
2023-01-01 13:07:10 -05:00
|
|
|
mockClean = Cleanup {clChildren = [], clXmobar = Nothing, clDBusUnexporters = []}
|
2022-06-14 23:46:24 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Concurrency configuration
|
2020-03-28 18:38:38 -04:00
|
|
|
|
2023-01-01 13:07:10 -05:00
|
|
|
data Cleanup = Cleanup
|
2023-01-01 14:57:23 -05:00
|
|
|
{ clChildren :: [(Utf8Builder, Process () () ())]
|
2023-01-01 13:07:10 -05:00
|
|
|
, clXmobar :: Maybe (Process Handle () ())
|
2023-01-01 15:00:40 -05:00
|
|
|
, clDBusUnexporters :: [XIO ()]
|
2022-12-30 14:58:23 -05:00
|
|
|
}
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-12-31 23:56:23 -05:00
|
|
|
runCleanup
|
2023-01-01 15:00:40 -05:00
|
|
|
:: (XIO () -> IO ())
|
2023-01-01 13:07:10 -05:00
|
|
|
-> Cleanup
|
2022-12-31 23:56:23 -05:00
|
|
|
-> DBusState
|
|
|
|
-> X ()
|
2023-01-01 12:07:43 -05:00
|
|
|
runCleanup runIO ts db = liftIO $ runIO $ do
|
2023-01-01 13:07:10 -05:00
|
|
|
mapM_ stopXmobar $ clXmobar ts
|
|
|
|
stopChildDaemons $ clChildren ts
|
|
|
|
sequence_ $ clDBusUnexporters ts
|
2023-01-01 12:07:43 -05:00
|
|
|
disconnectDBusX db
|
2022-12-28 14:18:39 -05:00
|
|
|
|
|
|
|
-- | Kill a process (group) after xmonad has already started
|
|
|
|
-- This is necessary (as opposed to 'stopProcess' from rio) because a) xmonad
|
|
|
|
-- sets the handler for sigCHLD to Ignore which breaks 'waitForProcess' (which
|
|
|
|
-- in turn will break 'stopProcess') and b) because I want to kill off entire
|
|
|
|
-- process groups since they may spawn child processes themselves. NOTE:
|
|
|
|
-- for reasons unknown I cannot just turn off/on the signal handlers here.
|
|
|
|
killNoWait :: Process a () () -> IO ()
|
|
|
|
killNoWait p = do
|
|
|
|
-- this strategy is outlined/sanctioned in RIO.Process under
|
|
|
|
-- 'unsafeProcessHandle':
|
|
|
|
--
|
|
|
|
-- get the handle (unsafely, since it breaks the semantics of RIO)
|
|
|
|
let ph = unsafeProcessHandle p
|
|
|
|
-- check if the process has already exited (if so, do nothing since trying
|
|
|
|
-- to kill it will open wormholes
|
|
|
|
ec <- getProcessExitCode ph
|
|
|
|
unless (isJust ec) $ do
|
|
|
|
-- send SIGTERM to the entire group (NOTE: 'System.Process.terminateProcess'
|
|
|
|
-- does not actually do this despite what the docs say)
|
|
|
|
i <- getPid ph
|
|
|
|
forM_ i $ signalProcessGroup sigTERM
|
|
|
|
-- actually call 'stopProcess' which will clean up associated data and
|
|
|
|
-- then try to wait for the exit, which will fail because we are assuming
|
|
|
|
-- this function is called when the handler for SIGCHLD is Ignore. Ignore
|
|
|
|
-- the failure and move on with life.
|
|
|
|
handleIO (\_ -> return ()) $ stopProcess p
|
2020-03-28 18:38:38 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Startuphook configuration
|
2020-03-28 17:29:43 -04:00
|
|
|
|
2020-07-06 03:06:44 -04:00
|
|
|
-- TODO add _NET_DESKTOP_VIEWPORTS to _NET_SUPPORTED?
|
2021-06-20 20:54:23 -04:00
|
|
|
myStartupHook :: X ()
|
2022-12-30 14:58:23 -05:00
|
|
|
myStartupHook =
|
|
|
|
setDefaultCursor xC_left_ptr
|
|
|
|
<+> startupHook def
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Workspace configuration
|
2020-03-28 17:29:43 -04:00
|
|
|
|
|
|
|
myWorkspaces :: [WorkspaceId]
|
2022-12-30 14:58:23 -05:00
|
|
|
myWorkspaces = map show [1 .. 10 :: Int]
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
gimpTag :: String
|
|
|
|
gimpTag = "GIMP"
|
|
|
|
|
|
|
|
vmTag :: String
|
|
|
|
vmTag = "VM"
|
|
|
|
|
|
|
|
xsaneTag :: String
|
|
|
|
xsaneTag = "XSANE"
|
|
|
|
|
|
|
|
f5Tag :: String
|
|
|
|
f5Tag = "F5VPN"
|
|
|
|
|
|
|
|
gimpDynamicWorkspace :: Sometimes DynWorkspace
|
|
|
|
gimpDynamicWorkspace = sometimesIO_ "gimp workspace" "gimp" tree dw
|
2020-03-28 17:29:43 -04:00
|
|
|
where
|
2022-07-09 14:59:42 -04:00
|
|
|
tree = Only_ $ sysExe [Package Official "gimp"] exe
|
2022-12-30 14:58:23 -05:00
|
|
|
dw =
|
|
|
|
DynWorkspace
|
|
|
|
{ dwName = "Gimp"
|
|
|
|
, dwTag = gimpTag
|
|
|
|
, dwClass = c
|
|
|
|
, dwHook =
|
|
|
|
[ matchGimpRole "gimp-image-window" -?> appendViewShift gimpTag
|
|
|
|
, matchGimpRole "gimp-dock" -?> doF W.swapDown
|
|
|
|
, matchGimpRole "gimp-toolbox" -?> doF W.swapDown
|
|
|
|
, className =? c -?> appendViewShift gimpTag
|
|
|
|
]
|
|
|
|
, dwKey = 'g'
|
|
|
|
, dwCmd = Just $ spawnCmd exe []
|
|
|
|
}
|
2022-07-09 01:11:02 -04:00
|
|
|
exe = "gimp-2.10"
|
2022-12-30 14:58:23 -05:00
|
|
|
matchGimpRole role =
|
|
|
|
isPrefixOf role
|
|
|
|
<$> stringProperty "WM_WINDOW_ROLE"
|
|
|
|
<&&> className
|
|
|
|
=? c
|
2020-03-28 17:29:43 -04:00
|
|
|
c = "Gimp-2.10" -- TODO I don't feel like changing the version long term
|
|
|
|
|
2022-08-30 00:21:21 -04:00
|
|
|
-- TODO don't hardcode the VM name/title/shortcut
|
2022-07-02 20:02:26 -04:00
|
|
|
vmDynamicWorkspace :: Sometimes DynWorkspace
|
2022-12-30 14:58:23 -05:00
|
|
|
vmDynamicWorkspace =
|
|
|
|
Sometimes
|
|
|
|
"virtualbox workspace"
|
|
|
|
xpfVirtualBox
|
|
|
|
[Subfeature root "windows 8 VM"]
|
2020-03-28 17:29:43 -04:00
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
root =
|
|
|
|
IORoot_ dw $
|
|
|
|
toAnd_ (sysExe [Package Official "virtualbox"] "VBoxManage") $
|
|
|
|
IOTest_ name [] $
|
|
|
|
io $
|
|
|
|
vmExists vm
|
2022-12-26 14:45:49 -05:00
|
|
|
name = T.unwords ["test if", vm, "exists"]
|
2020-03-28 17:29:43 -04:00
|
|
|
c = "VirtualBoxVM"
|
2022-07-02 20:02:26 -04:00
|
|
|
vm = "win8raw"
|
2022-12-30 14:58:23 -05:00
|
|
|
dw =
|
|
|
|
DynWorkspace
|
|
|
|
{ dwName = "Windows VirtualBox"
|
|
|
|
, dwTag = vmTag
|
|
|
|
, dwClass = c
|
|
|
|
, dwHook = [className =? c -?> appendViewShift vmTag]
|
|
|
|
, dwKey = 'v'
|
|
|
|
, dwCmd = Just $ spawnCmd "vbox-start" [vm]
|
|
|
|
}
|
2022-07-02 20:02:26 -04:00
|
|
|
|
|
|
|
xsaneDynamicWorkspace :: Sometimes DynWorkspace
|
2022-12-30 14:58:23 -05:00
|
|
|
xsaneDynamicWorkspace =
|
|
|
|
Sometimes
|
|
|
|
"scanner workspace"
|
|
|
|
xpfXSANE
|
|
|
|
[Subfeature (IORoot_ dw tree) "xsane"]
|
2020-03-28 17:29:43 -04:00
|
|
|
where
|
2022-07-09 14:59:42 -04:00
|
|
|
tree = Only_ $ sysExe [Package Official "xsane"] "xsane"
|
2022-12-30 14:58:23 -05:00
|
|
|
dw =
|
|
|
|
DynWorkspace
|
|
|
|
{ dwName = "XSane"
|
|
|
|
, dwTag = xsaneTag
|
|
|
|
, dwClass = c
|
|
|
|
, dwHook = [className =? c -?> appendViewShift xsaneTag >> doFloat]
|
|
|
|
, dwKey = 'x'
|
|
|
|
, dwCmd = Just $ spawnCmd "xsane" []
|
|
|
|
}
|
2020-03-28 17:29:43 -04:00
|
|
|
c = "Xsane"
|
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
f5vpnDynamicWorkspace :: Sometimes DynWorkspace
|
2022-12-30 14:58:23 -05:00
|
|
|
f5vpnDynamicWorkspace =
|
|
|
|
Sometimes
|
|
|
|
"F5 VPN workspace"
|
|
|
|
xpfF5VPN
|
|
|
|
[Subfeature (IORoot_ dw tree) "f5vpn"]
|
2021-11-03 23:57:10 -04:00
|
|
|
where
|
2022-07-09 14:59:42 -04:00
|
|
|
tree = Only_ $ sysExe [Package AUR "f5vpn"] "f5vpn"
|
2022-12-30 14:58:23 -05:00
|
|
|
dw =
|
|
|
|
DynWorkspace
|
|
|
|
{ dwName = "F5Vpn"
|
|
|
|
, dwTag = f5Tag
|
|
|
|
, dwClass = c
|
|
|
|
, dwHook = [className =? c -?> appendShift f5Tag]
|
|
|
|
, dwKey = 'i'
|
|
|
|
, dwCmd = Just skip
|
|
|
|
}
|
2021-11-03 23:57:10 -04:00
|
|
|
c = "F5 VPN"
|
|
|
|
|
2022-07-02 20:08:37 -04:00
|
|
|
allDWs' :: [Sometimes DynWorkspace]
|
2022-12-30 14:58:23 -05:00
|
|
|
allDWs' =
|
|
|
|
[ xsaneDynamicWorkspace
|
|
|
|
, vmDynamicWorkspace
|
|
|
|
, gimpDynamicWorkspace
|
|
|
|
, f5vpnDynamicWorkspace
|
|
|
|
]
|
2022-07-02 20:08:37 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Layout configuration
|
2020-03-28 17:29:43 -04:00
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
-- NOTE this will have all available layouts, even those that may be for
|
|
|
|
-- features that failed. Trying to dynamically take out a layout seems to
|
|
|
|
-- make a new type :/
|
2022-12-30 14:58:23 -05:00
|
|
|
myLayouts tt =
|
|
|
|
onWorkspace vmTag vmLayout $
|
|
|
|
onWorkspace gimpTag gimpLayout $
|
|
|
|
mkToggle (single HIDE) $
|
|
|
|
tall ||| fulltab ||| full
|
2020-03-15 15:50:07 -04:00
|
|
|
where
|
2022-07-03 18:23:32 -04:00
|
|
|
addTopBar = noFrillsDeco shrinkText tt
|
2022-12-30 14:58:23 -05:00
|
|
|
tall =
|
|
|
|
renamed [Replace "Tall"] $
|
|
|
|
avoidStruts $
|
|
|
|
addTopBar $
|
|
|
|
noBorders $
|
|
|
|
Tall 1 0.03 0.5
|
|
|
|
fulltab =
|
|
|
|
renamed [Replace "Tabbed"] $
|
|
|
|
avoidStruts $
|
|
|
|
noBorders $
|
|
|
|
tabbedAlways shrinkText tt
|
|
|
|
full =
|
|
|
|
renamed [Replace "Full"] $
|
|
|
|
noBorders Full
|
2020-03-27 19:58:16 -04:00
|
|
|
vmLayout = noBorders Full
|
|
|
|
-- TODO use a tabbed layout for multiple master windows
|
2022-12-30 14:58:23 -05:00
|
|
|
gimpLayout =
|
|
|
|
renamed [Replace "Gimp Layout"] $
|
|
|
|
avoidStruts $
|
|
|
|
noBorders $
|
|
|
|
addTopBar $
|
|
|
|
Tall 1 0.025 0.8
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
-- | Make a new empty layout and add a message to show/hide it. This is useful
|
|
|
|
-- for quickly showing conky.
|
2020-03-28 19:58:26 -04:00
|
|
|
data EmptyLayout a = EmptyLayout
|
2022-12-30 14:58:23 -05:00
|
|
|
deriving (Show, Read)
|
2020-03-28 19:58:26 -04:00
|
|
|
|
|
|
|
instance LayoutClass EmptyLayout a where
|
|
|
|
doLayout a b _ = emptyLayout a b
|
|
|
|
description _ = "Desktop"
|
|
|
|
|
|
|
|
data HIDE = HIDE
|
2022-12-30 14:58:23 -05:00
|
|
|
deriving (Read, Show, Eq, Typeable)
|
2020-03-28 19:58:26 -04:00
|
|
|
|
|
|
|
instance Transformer HIDE Window where
|
|
|
|
transform _ x k = k EmptyLayout (\EmptyLayout -> x)
|
|
|
|
|
2020-04-06 00:14:56 -04:00
|
|
|
-- TODO toggle back to normal when a new window is opened
|
2020-03-28 19:58:26 -04:00
|
|
|
runHide :: X ()
|
|
|
|
runHide = sendMessage $ Toggle HIDE
|
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Loghook configuration
|
2020-07-06 03:06:44 -04:00
|
|
|
|
2022-12-27 22:09:23 -05:00
|
|
|
myLoghook :: Process Handle () () -> X ()
|
2020-07-06 03:06:44 -04:00
|
|
|
myLoghook h = do
|
|
|
|
logXinerama h
|
|
|
|
logViewports
|
|
|
|
|
|
|
|
-- | Viewports loghook
|
|
|
|
-- This is all stuff that should probably be added to the EVMH contrib module.
|
|
|
|
-- Basically, this will send the workspace "viewport" positions to
|
|
|
|
-- _NET_DESKTOP_VIEWPORT which can be further processed by tools such as
|
|
|
|
-- 'wmctrl' to figure out which workspaces are on what monitor outside of
|
|
|
|
-- xmomad. This is more or less the way i3 does this, where the current
|
|
|
|
-- workspace has a valid position and everything else is just (0, 0). Also, I
|
|
|
|
-- probably should set the _NET_SUPPORT atom to reflect the existance of
|
|
|
|
-- _NET_DESKTOP_VIEWPORT, but for now there seems to be no ill effects so why
|
|
|
|
-- bother...(if that were necessary it would go in the startup hook)
|
|
|
|
newtype DesktopViewports = DesktopViewports [Int]
|
2022-12-30 14:58:23 -05:00
|
|
|
deriving (Eq)
|
2020-07-06 03:06:44 -04:00
|
|
|
|
|
|
|
instance ExtensionClass DesktopViewports where
|
2022-12-30 14:58:23 -05:00
|
|
|
initialValue = DesktopViewports []
|
2020-07-06 03:06:44 -04:00
|
|
|
|
|
|
|
logViewports :: X ()
|
|
|
|
logViewports = withWindowSet $ \s -> do
|
|
|
|
sort' <- getSortByIndex
|
|
|
|
let ws = sort' $ W.workspaces s
|
|
|
|
let desktopViewports = concatMap (wsToViewports s) ws
|
|
|
|
whenChanged (DesktopViewports desktopViewports) $
|
2022-12-30 14:58:23 -05:00
|
|
|
setDesktopViewports desktopViewports
|
2020-07-06 03:06:44 -04:00
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
wsToViewports s w =
|
|
|
|
let cur = W.current s
|
|
|
|
in if W.tag w == currentTag cur then currentPos cur else [0, 0]
|
2020-07-06 03:06:44 -04:00
|
|
|
currentTag = W.tag . W.workspace
|
|
|
|
currentPos = rectXY . screenRect . W.screenDetail
|
|
|
|
rectXY (Rectangle x y _ _) = [fromIntegral x, fromIntegral y]
|
|
|
|
|
|
|
|
setDesktopViewports :: [Int] -> X ()
|
|
|
|
setDesktopViewports vps = withDisplay $ \dpy -> do
|
2022-12-30 14:58:23 -05:00
|
|
|
r <- asks theRoot
|
|
|
|
a <- getAtom "_NET_DESKTOP_VIEWPORT"
|
|
|
|
c <- getAtom "CARDINAL"
|
|
|
|
io $ changeProperty32 dpy r a c propModeReplace $ map fromIntegral vps
|
2020-07-06 03:06:44 -04:00
|
|
|
|
|
|
|
-- stolen from XMonad.Hooks.EwmhDesktops
|
|
|
|
whenChanged :: (Eq a, ExtensionClass a) => a -> X () -> X ()
|
|
|
|
whenChanged v action = do
|
2022-12-30 14:58:23 -05:00
|
|
|
v0 <- E.get
|
|
|
|
unless (v == v0) $ do
|
|
|
|
action
|
|
|
|
E.put v
|
2020-07-06 03:06:44 -04:00
|
|
|
|
|
|
|
-- | Xinerama loghook (for xmobar)
|
2020-04-01 22:06:00 -04:00
|
|
|
-- The format will be like "[<1> 2 3] 4 5 | LAYOUT (N)" where each digit is the
|
|
|
|
-- workspace and LAYOUT is the current layout. Each workspace in the brackets is
|
|
|
|
-- currently visible and the order reflects the physical location of each
|
|
|
|
-- screen. The "<>" is the workspace that currently has focus. N is the number
|
|
|
|
-- of windows on the current workspace.
|
2022-12-27 22:09:23 -05:00
|
|
|
logXinerama :: Process Handle () () -> X ()
|
2022-12-30 14:58:23 -05:00
|
|
|
logXinerama p = withWindowSet $ \ws ->
|
|
|
|
io $
|
|
|
|
hPutStrLn (getStdin p) $
|
|
|
|
T.unwords $
|
|
|
|
filter (not . T.null) [onScreen ws, offScreen ws, sep, layout ws, nWindows ws]
|
2020-03-15 15:50:07 -04:00
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
onScreen ws =
|
|
|
|
xmobarColor_ hilightFgColor hilightBgColor $
|
|
|
|
(T.pack . pad . T.unpack) $
|
|
|
|
T.unwords $
|
|
|
|
map (fmtTags ws . W.tag . W.workspace) $
|
|
|
|
sortBy compareXCoord $
|
|
|
|
W.current ws : W.visible ws
|
|
|
|
offScreen =
|
|
|
|
xmobarColor_ XT.backdropFgColor ""
|
|
|
|
. T.unwords
|
|
|
|
. fmap (T.pack . W.tag)
|
|
|
|
. filter (isJust . W.stack)
|
|
|
|
. sortOn W.tag
|
|
|
|
. W.hidden
|
2022-12-26 14:45:49 -05:00
|
|
|
sep = xmobarColor_ XT.backdropFgColor "" ":"
|
|
|
|
layout = T.pack . description . W.layout . W.workspace . W.current
|
2022-12-30 14:58:23 -05:00
|
|
|
nWindows =
|
|
|
|
(\x -> T.concat ["(", x, ")"])
|
|
|
|
. T.pack
|
|
|
|
. show
|
|
|
|
. length
|
|
|
|
. W.integrate'
|
|
|
|
. W.stack
|
|
|
|
. W.workspace
|
|
|
|
. W.current
|
2021-09-06 00:30:06 -04:00
|
|
|
hilightBgColor = "#A6D3FF"
|
2022-12-26 14:45:49 -05:00
|
|
|
hilightFgColor = XT.blend' 0.4 hilightBgColor XT.fgColor
|
2022-12-30 14:58:23 -05:00
|
|
|
fmtTags ws t =
|
|
|
|
let t_ = T.pack t
|
|
|
|
in if t == W.currentTag ws
|
|
|
|
then xmobarColor_ XT.fgColor hilightBgColor t_
|
|
|
|
else t_
|
2022-12-26 14:45:49 -05:00
|
|
|
xmobarColor_ a b c = T.pack $ xmobarColor (T.unpack a) (T.unpack b) (T.unpack c)
|
2020-04-01 18:51:30 -04:00
|
|
|
|
|
|
|
compareXCoord
|
|
|
|
:: W.Screen i1 l1 a1 ScreenId ScreenDetail
|
2022-12-30 14:58:23 -05:00
|
|
|
-> W.Screen i2 l2 a2 ScreenId ScreenDetail
|
|
|
|
-> Ordering
|
2022-08-06 00:10:29 -04:00
|
|
|
compareXCoord s0 s1 = compare (go s0) (go s1)
|
2020-04-01 18:51:30 -04:00
|
|
|
where
|
2022-08-06 00:10:29 -04:00
|
|
|
go = (\(Rectangle x _ _ _) -> x) . snd . getScreenIdAndRectangle
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Managehook configuration
|
2020-03-27 19:58:16 -04:00
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
myManageHook :: [DynWorkspace] -> ManageHook
|
|
|
|
myManageHook dws = manageApps dws <+> manageHook def
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
manageApps :: [DynWorkspace] -> ManageHook
|
2022-12-30 14:58:23 -05:00
|
|
|
manageApps dws =
|
|
|
|
composeOne $
|
|
|
|
concatMap dwHook dws
|
|
|
|
++ [ isDialog -?> doCenterFloat
|
|
|
|
, -- the seafile applet
|
|
|
|
className =? "Seafile Client" -?> doFloat
|
|
|
|
, -- gnucash
|
|
|
|
(className =? "Gnucash" <&&> title =? "Transaction Import Assistant") -?> doFloat
|
|
|
|
, -- plots and graphics
|
|
|
|
className =? "R_x11" -?> doFloat
|
|
|
|
, className =? "Matplotlib" -?> doFloat
|
|
|
|
, className =? "mpv" -?> doFloat
|
|
|
|
, -- the floating windows created by the brave browser
|
|
|
|
stringProperty "WM_NAME" =? "Brave" -?> doFloat
|
|
|
|
, -- , (stringProperty "WM_WINDOW_ROLE" =? "pop-up"
|
|
|
|
-- <&&> className =? "Brave-browser") -?> doFloat
|
|
|
|
-- the dialog windows created by the zotero addon in Google Docs
|
|
|
|
(className =? "Zotero" <&&> resource =? "Toplevel") -?> doFloat
|
|
|
|
]
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Eventhook configuration
|
2020-03-28 17:29:43 -04:00
|
|
|
|
2023-01-01 11:50:17 -05:00
|
|
|
myEventHook
|
|
|
|
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
|
|
|
=> (m () -> IO ())
|
|
|
|
-> (String -> X ())
|
|
|
|
-> Event
|
|
|
|
-> X All
|
|
|
|
myEventHook runIO handler = xMsgEventHook runIO handler <+> handleEventHook def
|
2020-03-28 14:44:50 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
-- | React to ClientMessage events from concurrent threads
|
2023-01-01 11:50:17 -05:00
|
|
|
xMsgEventHook
|
|
|
|
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
|
|
|
=> (m () -> IO ())
|
|
|
|
-> (String -> X ())
|
|
|
|
-> Event
|
|
|
|
-> X All
|
|
|
|
xMsgEventHook runIO handler ClientMessageEvent {ev_message_type = t, ev_data = d}
|
2020-03-15 15:50:07 -04:00
|
|
|
| t == bITMAP = do
|
2022-12-30 14:58:23 -05:00
|
|
|
let (xtype, tag) = splitXMsg d
|
|
|
|
case xtype of
|
|
|
|
Workspace -> removeDynamicWorkspace tag
|
|
|
|
ACPI -> handler tag
|
2023-01-01 11:50:17 -05:00
|
|
|
Unknown -> liftIO $ runIO $ logWarn "unknown concurrent message"
|
2022-12-30 14:58:23 -05:00
|
|
|
return (All True)
|
2023-01-01 11:50:17 -05:00
|
|
|
xMsgEventHook _ _ _ = return (All True)
|
2020-03-15 15:50:07 -04:00
|
|
|
|
2020-04-01 22:06:00 -04:00
|
|
|
--------------------------------------------------------------------------------
|
2022-12-30 14:58:23 -05:00
|
|
|
-- Keymap configuration
|
2020-03-27 20:27:26 -04:00
|
|
|
|
2020-03-15 15:50:07 -04:00
|
|
|
myModMask :: KeyMask
|
|
|
|
myModMask = mod4Mask
|
|
|
|
|
2022-12-30 14:58:23 -05:00
|
|
|
addKeymap
|
|
|
|
:: [DynWorkspace]
|
|
|
|
-> ([((KeyMask, KeySym), NamedAction)] -> X ())
|
|
|
|
-> [KeyGroup (X ())]
|
|
|
|
-> XConfig l
|
|
|
|
-> XConfig l
|
|
|
|
addKeymap dws showKeys external =
|
|
|
|
addDescrKeys'
|
|
|
|
((myModMask, xK_F1), showKeys)
|
|
|
|
(\c -> concatMap (mkNamedSubmap c) $ internalBindings dws c ++ external)
|
2021-06-19 00:17:47 -04:00
|
|
|
|
2022-07-02 20:02:26 -04:00
|
|
|
internalBindings :: [DynWorkspace] -> XConfig Layout -> [KeyGroup (X ())]
|
|
|
|
internalBindings dws c =
|
2022-12-30 14:58:23 -05:00
|
|
|
[ KeyGroup
|
|
|
|
"Window Layouts"
|
|
|
|
[ KeyBinding "M-j" "focus down" $ windows W.focusDown
|
|
|
|
, KeyBinding "M-k" "focus up" $ windows W.focusUp
|
|
|
|
, KeyBinding "M-m" "focus master" $ windows W.focusMaster
|
|
|
|
, KeyBinding "M-d" "focus master" runHide
|
|
|
|
, KeyBinding "M-S-j" "swap down" $ windows W.swapDown
|
|
|
|
, KeyBinding "M-S-k" "swap up" $ windows W.swapUp
|
|
|
|
, KeyBinding "M-S-m" "swap master" $ windows W.swapMaster
|
|
|
|
, KeyBinding "M-<Return>" "next layout" $ sendMessage NextLayout
|
|
|
|
, KeyBinding "M-S-<Return>" "reset layout" $ setLayout $ layoutHook c
|
|
|
|
, KeyBinding "M-t" "sink tiling" $ withFocused $ windows . W.sink
|
|
|
|
, KeyBinding "M-S-t" "float tiling" $ withFocused O.float
|
|
|
|
, KeyBinding "M--" "shrink" $ sendMessage Shrink
|
|
|
|
, KeyBinding "M-=" "expand" $ sendMessage Expand
|
|
|
|
, KeyBinding "M-S--" "remove master window" $ sendMessage $ IncMasterN (-1)
|
|
|
|
, KeyBinding "M-S-=" "add master window" $ sendMessage $ IncMasterN 1
|
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"Workspaces"
|
|
|
|
-- ASSUME standard workspaces only use numbers 0-9 (otherwise we won't get
|
|
|
|
-- valid keysyms)
|
|
|
|
( [ KeyBinding (mods ++ n) (msg ++ n) (f n) | n <- myWorkspaces, (mods, msg, f) <-
|
|
|
|
[ ("M-", "switch to workspace ", windows . W.view)
|
|
|
|
, ("M-S-", "move client to workspace ", windows . W.shift)
|
|
|
|
,
|
|
|
|
( "M-C-"
|
|
|
|
, "follow client to workspace "
|
|
|
|
, \n' -> do
|
|
|
|
windows $ W.shift n'
|
|
|
|
windows $ W.view n'
|
|
|
|
)
|
|
|
|
]
|
2021-06-19 00:17:47 -04:00
|
|
|
]
|
2022-12-30 14:58:23 -05:00
|
|
|
++ [ KeyBinding "M-M1-l" "move up workspace" $ moveTo Next (hiddenWS :&: Not emptyWS)
|
|
|
|
, KeyBinding "M-M1-h" "move down workspace" $ moveTo Prev (hiddenWS :&: Not emptyWS)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
, KeyGroup
|
|
|
|
"Dynamic Workspaces"
|
|
|
|
[ KeyBinding ("M-C-" ++ [k]) ("launch/switch to " ++ n) cmd
|
|
|
|
| DynWorkspace {dwTag = t, dwKey = k, dwCmd = a, dwName = n} <- dws
|
|
|
|
, let cmd = case a of
|
|
|
|
Just a' -> spawnOrSwitch t a'
|
|
|
|
Nothing -> windows $ W.view t
|
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"Screens"
|
|
|
|
[ KeyBinding "M-l" "move up screen" nextScr
|
|
|
|
, KeyBinding "M-h" "move down screen" prevScr
|
|
|
|
, KeyBinding "M-C-l" "follow client up screen" $ nextScr' W.shift
|
|
|
|
, KeyBinding "M-C-h" "follow client down screen" $ prevScr' W.shift
|
|
|
|
, KeyBinding "M-S-l" "shift workspace up screen" $ nextScr' W.greedyView
|
|
|
|
, KeyBinding "M-S-h" "shift workspace down screen" $ prevScr' W.greedyView
|
|
|
|
]
|
2020-03-15 15:50:07 -04:00
|
|
|
]
|
2022-08-06 00:10:35 -04:00
|
|
|
where
|
|
|
|
prev = onPrevNeighbour horizontalScreenOrderer
|
|
|
|
next = onNextNeighbour horizontalScreenOrderer
|
|
|
|
prevScr = prev W.view
|
|
|
|
nextScr = next W.view
|
|
|
|
prevScr' f = prev f >> prevScr
|
|
|
|
nextScr' f = next f >> nextScr
|
2021-06-19 00:17:47 -04:00
|
|
|
|
2022-12-30 14:58:23 -05:00
|
|
|
mkNamedSubmap :: XConfig Layout -> KeyGroup (X ()) -> [((KeyMask, KeySym), NamedAction)]
|
|
|
|
mkNamedSubmap c KeyGroup {kgHeader = h, kgBindings = b} =
|
|
|
|
(subtitle h :) $
|
|
|
|
mkNamedKeymap c $
|
|
|
|
(\KeyBinding {kbSyms = s, kbDesc = d, kbMaybeAction = a} -> (s, addName d a))
|
|
|
|
<$> b
|
2021-06-19 00:17:47 -04:00
|
|
|
|
|
|
|
data KeyBinding a = KeyBinding
|
2022-12-30 14:58:23 -05:00
|
|
|
{ kbSyms :: String
|
|
|
|
, kbDesc :: String
|
2021-11-21 10:26:28 -05:00
|
|
|
, kbMaybeAction :: a
|
2021-06-19 00:17:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
data KeyGroup a = KeyGroup
|
2022-12-30 14:58:23 -05:00
|
|
|
{ kgHeader :: String
|
2021-06-19 00:17:47 -04:00
|
|
|
, kgBindings :: [KeyBinding a]
|
|
|
|
}
|
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
evalExternal :: [KeyGroup FeatureX] -> XIO [KeyGroup MaybeX]
|
2021-06-19 00:17:47 -04:00
|
|
|
evalExternal = mapM go
|
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
go k@KeyGroup {kgBindings = bs} =
|
|
|
|
(\bs' -> k {kgBindings = bs'}) <$> mapM evalKeyBinding bs
|
2021-06-19 00:17:47 -04:00
|
|
|
|
2023-01-01 15:00:40 -05:00
|
|
|
evalKeyBinding :: KeyBinding FeatureX -> XIO (KeyBinding MaybeX)
|
2022-12-30 14:58:23 -05:00
|
|
|
evalKeyBinding k@KeyBinding {kbMaybeAction = a} =
|
|
|
|
(\f -> k {kbMaybeAction = f}) <$> evalFeature a
|
2021-06-19 00:17:47 -04:00
|
|
|
|
2021-11-07 18:41:25 -05:00
|
|
|
filterExternal :: [KeyGroup MaybeX] -> [KeyGroup (X ())]
|
|
|
|
filterExternal = fmap go
|
2020-03-28 14:44:50 -04:00
|
|
|
where
|
2022-12-30 14:58:23 -05:00
|
|
|
go k@KeyGroup {kgBindings = bs} =
|
|
|
|
k
|
|
|
|
{ kgBindings =
|
|
|
|
[ kb {kbMaybeAction = x}
|
|
|
|
| kb@KeyBinding {kbMaybeAction = Just x} <- bs
|
|
|
|
]
|
2022-07-08 20:08:17 -04:00
|
|
|
}
|
2021-11-07 18:41:25 -05:00
|
|
|
|
2023-01-02 12:33:37 -05:00
|
|
|
externalBindings :: (XIO () -> IO ()) -> X () -> DBusState -> [KeyGroup FeatureX]
|
|
|
|
externalBindings runIO cleanup db =
|
2022-12-30 14:58:23 -05:00
|
|
|
[ KeyGroup
|
|
|
|
"Launchers"
|
2023-01-02 19:32:12 -05:00
|
|
|
[ KeyBinding "<XF86Search>" "select/launch app" $ Left $ toX runAppMenu
|
|
|
|
, KeyBinding "M-g" "launch clipboard manager" $ Left $ toX runClipMenu
|
|
|
|
, KeyBinding "M-a" "launch network selector" $ Left $ toX $ runNetMenu sys
|
|
|
|
, KeyBinding "M-w" "launch window selector" $ Left $ toX runWinMenu
|
|
|
|
, KeyBinding "M-u" "launch device selector" $ Left $ toX runDevMenu
|
|
|
|
, KeyBinding "M-b" "launch bitwarden selector" $ Left $ toX $ runBwMenu ses
|
|
|
|
, KeyBinding "M-v" "launch ExpressVPN selector" $ Left $ toX runVPNMenu
|
|
|
|
, KeyBinding "M-e" "launch bluetooth selector" $ Left $ toX runBTMenu
|
2023-01-02 19:28:41 -05:00
|
|
|
, KeyBinding "M-C-e" "launch editor" $ Left $ toX runEditor
|
|
|
|
, KeyBinding "M-C-w" "launch browser" $ Left $ toX runBrowser
|
|
|
|
, KeyBinding "M-C-t" "launch terminal with tmux" $ Left $ toX runTMux
|
|
|
|
, KeyBinding "M-C-S-t" "launch terminal" $ Left $ toX runTerm
|
|
|
|
, KeyBinding "M-C-q" "launch calc" $ Left $ toX runCalc
|
|
|
|
, KeyBinding "M-C-f" "launch file manager" $ Left $ toX runFileManager
|
2022-12-30 14:58:23 -05:00
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"Actions"
|
|
|
|
[ KeyBinding "M-q" "close window" $ ftrAlways "kill window function" kill1
|
2023-01-02 19:32:12 -05:00
|
|
|
, KeyBinding "M-r" "run program" $ Left $ toX runCmdMenu
|
2022-12-30 14:58:23 -05:00
|
|
|
, KeyBinding "M-<Space>" "warp pointer" $ ftrAlways "warp function" $ warpToWindow 0.5 0.5
|
2023-01-02 19:28:41 -05:00
|
|
|
, KeyBinding "M-C-s" "capture area" $ Left $ toX $ runAreaCapture ses
|
|
|
|
, KeyBinding "M-C-S-s" "capture screen" $ Left $ toX $ runScreenCapture ses
|
|
|
|
, KeyBinding "M-C-d" "capture desktop" $ Left $ toX $ runDesktopCapture ses
|
|
|
|
, KeyBinding "M-C-b" "browse captures" $ Left $ toX runCaptureBrowser
|
2022-12-30 14:58:23 -05:00
|
|
|
-- , ("M-C-S-s", "capture focused window", spawn myWindowCap)
|
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"Multimedia"
|
2023-01-02 19:28:41 -05:00
|
|
|
[ KeyBinding "<XF86AudioPlay>" "toggle play/pause" $ Left $ toX runTogglePlay
|
|
|
|
, KeyBinding "<XF86AudioPrev>" "previous track" $ Left $ toX runPrevTrack
|
|
|
|
, KeyBinding "<XF86AudioNext>" "next track" $ Left $ toX runNextTrack
|
|
|
|
, KeyBinding "<XF86AudioStop>" "stop" $ Left $ toX runStopPlay
|
|
|
|
, KeyBinding "<XF86AudioLowerVolume>" "volume down" $ Left $ toX runVolumeDown
|
|
|
|
, KeyBinding "<XF86AudioRaiseVolume>" "volume up" $ Left $ toX runVolumeUp
|
|
|
|
, KeyBinding "<XF86AudioMute>" "volume mute" $ Left $ toX runVolumeMute
|
2022-12-30 14:58:23 -05:00
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"Dunst"
|
2023-01-02 19:28:41 -05:00
|
|
|
[ KeyBinding "M-`" "dunst history" $ Left $ toX $ runNotificationHistory ses
|
|
|
|
, KeyBinding "M-S-`" "dunst close" $ Left $ toX $ runNotificationClose ses
|
|
|
|
, KeyBinding "M-M1-`" "dunst context menu" $ Left $ toX $ runNotificationContext ses
|
|
|
|
, KeyBinding "M-C-`" "dunst close all" $ Left $ toX $ runNotificationCloseAll ses
|
2022-12-30 14:58:23 -05:00
|
|
|
]
|
|
|
|
, KeyGroup
|
|
|
|
"System"
|
|
|
|
[ KeyBinding "M-." "backlight up" $ ib bctlInc
|
|
|
|
, KeyBinding "M-," "backlight down" $ ib bctlDec
|
|
|
|
, KeyBinding "M-M1-," "backlight min" $ ib bctlMin
|
|
|
|
, KeyBinding "M-M1-." "backlight max" $ ib bctlMax
|
|
|
|
, KeyBinding "M-S-." "keyboard up" $ ck bctlInc
|
|
|
|
, KeyBinding "M-S-," "keyboard down" $ ck bctlDec
|
|
|
|
, KeyBinding "M-S-M1-," "keyboard min" $ ck bctlMin
|
|
|
|
, KeyBinding "M-S-M1-." "keyboard max" $ ck bctlMax
|
|
|
|
, KeyBinding "M-<End>" "power menu" $ Left runPowerPrompt
|
|
|
|
, KeyBinding "M-<Home>" "quit xmonad" $ Left runQuitPrompt
|
|
|
|
, KeyBinding "M-<Delete>" "lock screen" $ Left runScreenLock
|
|
|
|
, -- M-<F1> reserved for showing the keymap
|
|
|
|
KeyBinding "M-<F2>" "restart xmonad" restartf
|
|
|
|
, KeyBinding "M-<F3>" "recompile xmonad" recompilef
|
2023-01-02 19:32:12 -05:00
|
|
|
, KeyBinding "M-<F8>" "select autorandr profile" $ Left $ toX runAutorandrMenu
|
2023-01-02 19:28:41 -05:00
|
|
|
, KeyBinding "M-<F9>" "toggle ethernet" $ Left $ toX runToggleEthernet
|
|
|
|
, KeyBinding "M-<F10>" "toggle bluetooth" $ Left $ toX $ runToggleBluetooth sys
|
|
|
|
, KeyBinding "M-<F11>" "toggle screensaver" $ Left $ toX $ callToggle ses
|
2022-12-30 14:58:23 -05:00
|
|
|
, KeyBinding "M-<F12>" "switch gpu" $ Left runOptimusPrompt
|
|
|
|
]
|
2021-06-19 00:17:47 -04:00
|
|
|
]
|
2021-11-21 17:54:00 -05:00
|
|
|
where
|
2022-07-07 19:20:21 -04:00
|
|
|
ses = dbSesClient db
|
|
|
|
sys = dbSysClient db
|
2023-01-02 19:28:41 -05:00
|
|
|
brightessControls ctl getter = (toX . getter . ctl) ses
|
2022-06-22 01:28:46 -04:00
|
|
|
ib = Left . brightessControls intelBacklightControls
|
|
|
|
ck = Left . brightessControls clevoKeyboardControls
|
2022-07-02 00:09:16 -04:00
|
|
|
ftrAlways n = Right . Always n . Always_ . FallbackAlone
|
2022-12-31 23:56:23 -05:00
|
|
|
restartf = ftrAlways "restart function" (cleanup >> runRestart)
|
2022-06-28 23:27:55 -04:00
|
|
|
recompilef = ftrAlways "recompile function" runRecompile
|
2023-01-02 19:28:41 -05:00
|
|
|
toX_ = liftIO . runIO
|
|
|
|
toX = fmap toX_
|
2022-06-22 01:28:46 -04:00
|
|
|
|
|
|
|
type MaybeX = Maybe (X ())
|
|
|
|
|
|
|
|
type FeatureX = Feature (X ())
|