import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageHelpers import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar.PP import XMonad.Actions.MouseResize import XMonad.Util.EZConfig import XMonad.Util.Loggers import XMonad.Util.Ungrab import XMonad.Layout.Magnifier import XMonad.Layout.ThreeColumns import XMonad.Layout.Spacing import XMonad.Hooks.EwmhDesktops import XMonad.Util.SpawnOnce (spawnOnce) -- run or raise import XMonad.Actions.WindowGo (raiseMaybe, runOrRaise) import XMonad.ManageHook (className) -- import XMonad.Layout.Decoration import XMonad.Layout.Simplest import XMonad.Layout.SimplestFloat import XMonad.Layout.Spacing import XMonad.Actions.PerWindowKeys import XMonad.Actions.FindEmptyWorkspace import XMonad.Layout.Grid import XMonad.Layout.PerScreen (ifWider) import XMonad.Layout import XMonad.Layout.Reflect import XMonad.Layout.WindowArranger -- Window Rearragement import Data.List (find) import XMonad.Actions.EasyMotion (selectWindow) import XMonad.Actions.FocusNth (swapNth) import XMonad.Layout.LimitWindows import XMonad.Actions.CopyWindow import qualified XMonad.StackSet as W import XMonad.Actions.SpawnOn main :: IO () main = xmonad . ewmhFullscreen . ewmh . withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey $ myConfig workspacen :: [String] workspacen = ["ws1", "ws2", "ws3", "ws4", "ws5", "ws6", "ws7", "ws8", "ws9", "ws10"] myKeys = [ (otherModMasks ++ "M-" ++ key, action tag) | (tag, key) <- zip workspacen (words "1 2 3 4 5 6 7 8 9 0") , (otherModMasks, action) <- [ ("z-" , windows . W.greedyView) , ("S-", windows . W.shift) , ("C-", windows .copy) ] ] ++ [ ("M-d", spawn "rofi -show run") , ("M-s", spawn "bash -c dictpopup") , ("M-S-e", spawnAndShift "ws7" "goldendict") , ("M-e", runOrRaise "goldendict" (className =? "GoldenDict-ng")) , ("M-p", runOrRaise "librewolf" (className =? "librewolf-default")) , ("M-S-g", easySwap) , ("M-S-c", spawnAndShift "ws8" "qbittorrent") , ("M-S-p", runOrRaise "nyxt" (className =? "Nyxt")) , ("M-t", withFocused $ windows . W.sink) -- Toggle float for the focused window , ("M-`", runOrRaise "emacs" (className =? "Emacs")) , ("M-S-q", return ()) -- Unbind Mod + Shift + Q, to avoid quiting the wm. , ("M-q", kill) -- Change the keybinding for closing windows to Mod + Q , ("M-m", spawn "mpv --idle") , ("M-S-r", spawn "~/.local/bin/run_anki.sh") , ("M-S-d", spawn "~/.local/bin/recent_journal.py | popup") , ("M-r", runOrRaise "~/.local/bin/run_anki.sh" (className =? "Anki")) , ("M-g", runOrRaise "foliate" (className =? "com.github.johnfactotum.Foliate")) , ("M-S-f", sendToEmptyWorkspace) -- View an empty workspace , ("M-f", viewEmptyWorkspace) -- View an empty workspace , ("M-S-w", spawn "flameshot gui --path=/mnt/Data/mpv-screenshots/screenshots") , ("M-w", spawn "~/.local/bin/copy_image.sh") , ("M-S-b", spawn "kill -9 $(pgrep mpv)") , ("M-v", spawn "maim --select --hidecursor --format=png --quality 1 /tmp/manga/screenshot.png") ] myConfig = def { modMask = mod4Mask -- Rebind Mod to the Super key , layoutHook = windowArrange myLayout -- Use custom layouts , terminal = "kitty" , focusedBorderColor = "#000000" , workspaces = workspacen , manageHook = myManageHook -- Match on certain windows , startupHook = do -- other startup commands -- spawnOnce "xrandr --output DisplayPort-0 --mode 1366x768 --pos 1366x0 --rotate left --output HDMI-A-0 --primary --mode 1366x768 --pos 0x0 --rotate normal --output DVI-D-0 --off" spawnOnce "xrandr --output HDMI-A-0 --mode 1366x768 --pos 0x0 --rotate normal" spawnOnce "xrdb /home/hashirama/.Xresources" spawnOnce "feh --bg-fill wallpaper.jpg" spawnOnce "picom -b" spawnOnce "polybar top-monitor-1" spawnOnce "fcitx5 -d -r" spawnOnce "emacs --daemon" } `additionalKeysP` myKeys easySwap :: X () easySwap = do win <- selectWindow def stack <- gets $ W.index . windowset let match = find ((win ==) . Just . fst) $ zip stack [0 ..] whenJust match $ swapNth . snd myManageHook :: ManageHook myManageHook = composeAll [ className =? "Gimp" --> doFloat , isDialog --> doFloat , className =? "GoldenDict-ng" --> doShift "ws7" , className =? "qBittorrent" --> doShift "ws8" , manageSpawn ] spawnAndShift :: WorkspaceId -> String -> X () spawnAndShift ws app = do spawn app windows $ W.shift ws myTheme :: Theme myTheme = def { decoHeight = 20 -- Add other theme properties as needed } myLayout = limitWindows 2 $ Tall 1 0.03 0.5 ||| Full toggleLayout :: X () toggleLayout = do currentLayout <- gets (W.layout . W.workspace . W.current . windowset) case description currentLayout of "Tall" -> sendMessage $ JumpToLayout "Mirror Tall" _ -> sendMessage $ JumpToLayout "Tall" myXmobarPP :: PP myXmobarPP = def { ppSep = cyan " • " , ppTitleSanitize = xmobarStrip , ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2 , ppHidden = white . wrap " " "" , ppHiddenNoWindows = lowWhite . wrap " " "" , ppUrgent = red . wrap (yellow "!") (yellow "!") , ppOrder = \[ws, l, _, wins] -> [ws, l, wins] , ppExtras = [logTitles formatFocused formatUnfocused] } where formatFocused = wrap (white "[") (white "]") . cyan . ppWindow formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . vividGreen . ppWindow -- | Windows should have *some* title, which should not exceed a -- sane length. ppWindow :: String -> String ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30 cyan, vividGreen, lowWhite, red, white, yellow :: String -> String cyan = xmobarColor "#8be9fd" "" vividGreen = xmobarColor "#50fa7b" "" white = xmobarColor "#f8f8f2" "" yellow = xmobarColor "#f1fa8c" "" red = xmobarColor "#ff5555" "" lowWhite = xmobarColor "#bbbbbb" ""