forked from colonelpanic/dotfiles
[XMonad] Use window class names to name workspaces
This commit is contained in:
parent
a89dbb8d18
commit
3c4088912b
@ -1,4 +1,12 @@
|
|||||||
|
import Control.Monad
|
||||||
|
import Data.Aeson
|
||||||
|
import qualified Data.ByteString.Lazy as B
|
||||||
|
import Data.List
|
||||||
|
import qualified Data.Map as M
|
||||||
|
import Data.Maybe
|
||||||
import Graphics.X11.ExtraTypes.XF86
|
import Graphics.X11.ExtraTypes.XF86
|
||||||
|
import System.Directory
|
||||||
|
import System.FilePath.Posix
|
||||||
import System.Taffybar.Hooks.PagerHints (pagerHints)
|
import System.Taffybar.Hooks.PagerHints (pagerHints)
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|
||||||
@ -38,6 +46,12 @@ myWindowBringerConfig = WindowBringerConfig { menuCommand = "rofi"
|
|||||||
, windowTitler = myDecorateName
|
, windowTitler = myDecorateName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getClassRemap :: IO (M.Map String String)
|
||||||
|
getClassRemap = do
|
||||||
|
home <- getHomeDirectory
|
||||||
|
text <- B.readFile (home </> ".lib/class_remap.json")
|
||||||
|
return $ fromMaybe M.empty (decode text)
|
||||||
|
|
||||||
main = xmonad $ ewmh $ pagerHints def
|
main = xmonad $ ewmh $ pagerHints def
|
||||||
{ modMask = mod4Mask
|
{ modMask = mod4Mask
|
||||||
, terminal = "urxvt"
|
, terminal = "urxvt"
|
||||||
@ -52,10 +66,18 @@ main = xmonad $ ewmh $ pagerHints def
|
|||||||
myLogHook = fadeInactiveLogHook 0.9
|
myLogHook = fadeInactiveLogHook 0.9
|
||||||
|
|
||||||
setWorkspaceNameToFocusedWindow workspace = do
|
setWorkspaceNameToFocusedWindow workspace = do
|
||||||
namedWindows <- mapM getName $ take 2 $ W.integrate' $ W.stack workspace
|
namedWindows <- mapM getClass $ take 2 $ W.integrate' $ W.stack workspace
|
||||||
setWorkspaceName (W.tag workspace) (concatMap show namedWindows)
|
workspaceToName <- getWorkspaceNames
|
||||||
|
renamedWindows <- remapNames namedWindows
|
||||||
|
let newName = intercalate "|" namedWindows
|
||||||
|
when (workspaceToName (W.tag workspace) /= newName) $
|
||||||
|
setWorkspaceName (W.tag workspace) (intercalate "|" renamedWindows)
|
||||||
|
|
||||||
automaticallySetWorkspaceNames = do
|
remapNames namedWindows = do
|
||||||
|
remap <- io getClassRemap
|
||||||
|
return $ map (\original -> M.findWithDefault original original remap) namedWindows
|
||||||
|
|
||||||
|
setWorkspaceNames = do
|
||||||
ws <- gets windowset
|
ws <- gets windowset
|
||||||
mapM_ setWorkspaceNameToFocusedWindow (W.workspaces ws)
|
mapM_ setWorkspaceNameToFocusedWindow (W.workspaces ws)
|
||||||
|
|
||||||
@ -83,6 +105,7 @@ addKeys conf@XConfig {modMask = modm} =
|
|||||||
, ((modm .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin)
|
, ((modm .|. shiftMask, xK_m), sendMessage RestoreNextMinimizedWin)
|
||||||
|
|
||||||
-- Hyper bindings
|
-- Hyper bindings
|
||||||
|
, ((mod3Mask, xK_1), setWorkspaceNames)
|
||||||
, ((mod3Mask, xK_e), moveTo Next EmptyWS)
|
, ((mod3Mask, xK_e), moveTo Next EmptyWS)
|
||||||
, ((mod3Mask .|. shiftMask, xK_e), shiftTo Next EmptyWS)
|
, ((mod3Mask .|. shiftMask, xK_e), shiftTo Next EmptyWS)
|
||||||
, ((mod3Mask, xK_v), spawn "copyq_rofi.sh")
|
, ((mod3Mask, xK_v), spawn "copyq_rofi.sh")
|
||||||
|
Loading…
Reference in New Issue
Block a user