Created
July 26, 2019 14:08
-
-
Save zentrification/c889820a33c3dca29fee66a18a64377b to your computer and use it in GitHub Desktop.
Xmonad Topic's applied to multiple monitors
This file contains 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
module Topics.Topics where | |
import Data.Maybe | |
import Text.Printf (printf) | |
import XMonad | |
import XMonad.Actions.DynamicWorkspaceGroups | |
import XMonad.Actions.TopicSpace | |
import XMonad.Actions.GridSelect | |
import XMonad.Prompt | |
import XMonad.Prompt.Workspace | |
import qualified Data.Map as M | |
import qualified XMonad.StackSet as W | |
import Control.Arrow | |
-- meh duplicated | |
myTerminal2 = "sakura" | |
myXPConfig = defaultXPConfig | |
data TopicItem = TI | |
{ | |
topicName :: Topic | |
, topicDir :: Dir | |
, topicAct :: X () | |
} | |
topicGroups :: [TopicItem] | |
topicGroups = | |
[ TI "home" "workspace" (spawnInTopicDir "./home.sh") | |
, TI "courtroom" "workspace/courtroom" (spawnInTopicDir "./workspace.sh") | |
, TI "cyclist" "workspace/cyclist" (spawnInTopicDir "./workspace.sh") | |
, TI "espiritu" "workspace/espiritu" (return()) | |
, TI "misc" "workspace" (return()) | |
] | |
topicWithScreen :: Int -> TopicItem -> TopicItem | |
topicWithScreen sid (TI n d a) = TI (show sid ++ '_':n) d a | |
topicsWithScreens :: Int -> [TopicItem] -> [TopicItem] | |
topicsWithScreens n topics = [topicWithScreen sid topic | topic <- topics, sid <- [0..n-1]] | |
myTopics :: [TopicItem] | |
myTopics = topicsWithScreens 3 topicGroups | |
myTopicNames :: [Topic] | |
myTopicNames = map topicName myTopics | |
topicGroupNames :: [Topic] | |
topicGroupNames = map topicName topicGroups | |
myTopicConfig = TopicConfig | |
{ topicDirs = M.fromList $ map (topicName &&& topicDir) myTopics | |
, defaultTopicAction = const $ return () | |
, defaultTopic = "home" | |
, topicActions = M.fromList $ map (topicName &&& topicAct) myTopics | |
, maxTopicHistory = 10 | |
} | |
goto :: Topic -> X () | |
goto = switchTopic myTopicConfig | |
spawnShell :: X () | |
spawnShell = currentTopicDir myTopicConfig >>= spawnShellIn | |
spawnShellIn :: Dir -> X () | |
spawnShellIn dir = spawn $ "cd " ++ dir ++ " && " ++ myTerminal2 | |
spawnShellWith :: String -> X () | |
spawnShellWith what = spawn $ myTerminal2 ++ printf " -e '%s'" what | |
spawnInTopicDir act = currentTopicDir myTopicConfig >>= spawnIn act | |
spawnIn act dir = spawn $ "cd " ++ dir ++ "; " ++ act | |
promptedGoto :: X () | |
promptedGoto = workspacePrompt myXPConfig goto | |
promptedTopic = do | |
g <- gridselect defaultGSConfig $ zip topicGroupNames topicGroupNames | |
whenJust g viewWSGroup | |
myMarshall :: ScreenId -> Topic -> Topic | |
myMarshall s t = show s ++ '_':t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment