{-# OPTIONS_HADDOCK ignore-exports, prune #-} ---------------------------------------------------------------------- -- | -- Module : LaNinpreConfig -- Description : personal stuff for xmonad -- Maintainer : la-ninpre -- -- this module exists because i find it more convenient to manage some things -- from here instead of doing it right in xmonad config -- ---------------------------------------------------------------------- module LaNinpreConfig ( -- * global -- $global myFonts, myColor, myModMask, myTerminal, myBrowser, myGeminiClient, myFileMgr, myMocp, myEditor, myBorderWidth, myNormColor, myFocusColor, myAppGrid, myWorkspaces, myScratchPads, myManageHook, myStartupHook ) where import Data.List import Data.Map as M import Data.Maybe import Data.Monoid import XMonad import qualified XMonad.StackSet as W import XMonad.Hooks.ManageHelpers import XMonad.Hooks.SetWMName import XMonad.Util.NamedScratchpad import XMonad.Util.SpawnOnce -- $global -- -- constants and functions starting with \'my\' are exported and used in -- xmonad config. -- * constants -- $constants -- these are set up to avoid unnecessary repetition of replacements, when -- things change. -- ** fonts -- -- $fonts -- default fonts and helper functions for them. -- | default lato font fontLatoDef = fontXft "Lato" "regular" 14 -- | font for @ShowWMName@ -- -- normal variant -- -- > fontSWN = fontXft "Press Start 2P" "regular" 60 -- -- sitelen pona pona variant -- -- > fontSWN = fontXft "sitelen\\-pona" "regular" 80 fontSWN = fontXft "linja pona" "regular" 80 -- | fonts list myFonts :: [String] myFonts = [ fontLatoDef , fontSWN ] -- *** helper functions -- -- | font constructor -- -- it is just a helper function to simplify the process of specifying font -- with xft. fontXft :: String -- ^ font family -> String -- ^ font style -> Int -- ^ font style -> String fontXft font style size = intercalate ":" [ "xft" , font , style , "size=" ++ show size , "antialias=true" , "hinting=true" ] -- ** colors -- $colorTheme -- -- > bg #19191a -- > fg #cadcde -- > grey0 #232324 -- > grey1 #363638 -- > grey2 #66666a -- > black #393838 -- > red #c74444 -- > green #7f9848 -- > yellow #d7a06d -- > blue #4e96d5 -- > magenta #bc5fa7 -- > cyan #55b795 -- > white #c3b2f7 -- > black-bright #5a514b -- > red-bright #ed7c68 -- > green-bright #c7ea76 -- > yellow-bright #ffdb9d -- > blue-bright #a6d5fe -- > magenta-bright #edbbe9 -- > cyan-bright #7fe2c5 -- > white-bright #e2d6ff -- | color theme structure myColorTheme :: [(String,String)] myColorTheme = [ ("bg", "#19191a") , ("fg", "#cadcde") , ("gray0", "#232324") , ("gray1", "#363638") , ("gray2", "#5c5c60") , ("gray3", "#66666a") , ("gray4", "#ececf0") , ("black", "#393838") , ("red", "#c74444") , ("green", "#7f9848") , ("yellow", "#d7a06d") , ("blue", "#4e96d5") , ("magenta", "#bc5fa7") , ("cyan", "#55b795") , ("white", "#c3b2f7") , ("black-bright", "#5a514b") , ("red-bright", "#ed7c68") , ("green-bright", "#c7ea76") , ("yellow-bright", "#ffdb9d") , ("blue-bright", "#a6d5fe") , ("magenta-bright", "#edbbe9") , ("cyan-bright", "#7fe2c5") , ("white-bright", "#e2d6ff") ] -- | unfocused window border colour myNormColor :: String myNormColor = myColor "gray0" -- | focused window border colour myFocusColor :: String myFocusColor = myColor "blue" -- *** helper functions -- -- | get color from color theme myColor :: String -> String myColor c = fromMaybe "" (M.lookup c theme) where theme = fromList myColorTheme -- ** software constants -- -- | set terminal emulator myTerminal :: String myTerminal = "alacritty" -- | set default browser myBrowser :: String myBrowser = "brave" -- | set gemini client myGeminiClient :: String myGeminiClient = "amfora" -- | set file manager myFileMgr :: String myFileMgr = "thunar" -- | music on console -- -- this is to avoid spamming strings everywhere. @moc@ doesn't comply with -- XDG_CONFIG_HOME, so we force it to do so. myMocp :: String myMocp = "mocp -M '~/.config/moc'" -- | set editor myEditor :: String myEditor = myTerminal ++ " -e vim" -- ** other constants -- -- | set windows key as modkey myModMask :: KeyMask myModMask = mod4Mask -- | specify border width myBorderWidth :: Dimension myBorderWidth = 1 -- | app grid for @GridSelect@ layout myAppGrid :: [(String,String)] myAppGrid = [ ("discord", "discord") , ("steam", "steam") , ("cadence", "cadence") , ("blender", "blender") , ("inkscape", "inkscape") , ("obs", "obs") , ("gimp", "gimp") , ("element", "element-desktop") , ("ardour", "ardour6") , ("kdenlive", "kdenlive") , ("writer", "lowriter") ] -- * hooks -- -- ** startup hook -- -- $startupHook -- -- start things at login. -- | actual instance myStartupHook :: X () myStartupHook = do spawnOnce "dunst &" spawnOnce "lxsession &" spawnOnce "picom &" spawnOnce "nm-applet &" spawnOnce "volumeicon &" spawnOnce "setxkbmap -layout us,ru -option 'grp:alt_shift_toggle'" spawnOnce "kbdd" spawnOnce ("trayer --edge top " ++ "--align right " ++ "--widthtype request " ++ "--SetDockType true --SetPartialStrut true --expand false " ++ "--monitor 0 --transparent true --alpha 0 " ++ "--tint 0x19191a --height 24 &" ) spawnOnce "~/.fehbg &" setWMName "LG3D" -- ** manage hook -- -- $managehook -- -- @doFloat@ forces a window to float. useful for dialog boxes and such. -- using @doShift (myWorkspaces !! 7)@ sends program to workspace 8 -- i'm doing it this way because otherwise i would have to write out the full -- name of my workspaces and the names would be very long if using clickable workspaces. -- | manage hook myManageHook :: Query (Endo WindowSet) myManageHook = composeAll [ className =? "confirm" --> doFloat , className =? "file_progress" --> doFloat , className =? "dialog" --> doFloat , className =? "download" --> doFloat , className =? "error" --> doFloat , className =? "Gimp" --> doFloat , className =? "notification" --> doFloat , className =? "pinentry-gtk-2" --> doFloat , className =? "splash" --> doFloat , className =? "toolbar" --> doFloat , className =? "Cadence" --> doFloat , className =? "Steam" --> doFloat , className =? "Image Lounge" --> doFloat , title =? "Oracle VM VirtualBox Manager" --> doFloat -- web workspace , title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 1 ) , className =? "Brave-browser" --> doShift ( myWorkspaces !! 1 ) , className =? "amfora" --> doShift ( myWorkspaces !! 1 ) , className =? "qutebrowser" --> doShift ( myWorkspaces !! 1 ) -- doc workspace , className =? "Geary" --> doShift ( myWorkspaces !! 3 ) , className =? "libreoffice-writer" --> doShift ( myWorkspaces !! 3 ) , className =? "libreoffice-impress" --> doShift ( myWorkspaces !! 3 ) -- vm workspace , className =? "VirtualBox Manager" --> doShift ( myWorkspaces !! 4 ) -- chat workspace , className =? "discord" --> doShift ( myWorkspaces !! 5 ) , className =? "TelegramDesktop" --> doShift ( myWorkspaces !! 5 ) , className =? "Element" --> doShift ( myWorkspaces !! 5 ) , className =? "Steam" --> doShift ( myWorkspaces !! 5 ) -- full workspace , isFullscreen --> doShift ( myWorkspaces !! 6 ) -- vid workspace , className =? "Deadbeef" --> doShift ( myWorkspaces !! 7 ) , appName =? "mpv" --> doShift ( myWorkspaces !! 7 ) , className =? "vlc" --> doShift ( myWorkspaces !! 7 ) -- gfx workspace , className =? "Gimp" --> doShift ( myWorkspaces !! 8 ) , className =? "Blender" --> doShift ( myWorkspaces !! 8 ) , className =? "obs" --> doShift ( myWorkspaces !! 8 ) , isFullscreen --> doFullFloat ] <+> namedScratchpadManageHook myScratchPads -- * scratchpads -- -- $scratchpads -- -- currently i have: -- -- * plain terminal scratchpad -- -- * music on console -- -- * calculator (qalculate-gtk) -- -- * mpv instance that plays playlist in @~\/Video\/sp_playlist.m3u@ -- | scratchpad list myScratchPads :: [NamedScratchpad] myScratchPads = [ NS "terminal" spawnTerm findTerm manageTerm , NS "mocp" spawnMocp findMocp manageMocp , NS "calculator" spawnCalc findCalc manageCalc , NS "mpvfloat" spawnMpv findMpv manageMpv ] where -- terminal spawnTerm = myTerminal ++ " -t scratchpad" findTerm = title =? "scratchpad" manageTerm = customFloating $ W.RationalRect l t w h where h = 0.9 w = 0.9 t = 0.95 - h l = 0.95 - w -- music on console spawnMocp = myTerminal ++ " -t mocp -e " ++ myMocp findMocp = title =? "mocp" manageMocp = customFloating $ W.RationalRect l t w h where h = 0.9 w = 0.9 t = 0.95 - h l = 0.95 - w -- calculator spawnCalc = "qalculate-gtk" findCalc = className =? "Qalculate-gtk" manageCalc = customFloating $ W.RationalRect l t w h where h = 0.5 w = 0.4 t = 0.75 - h l = 0.70 - w -- mpv scratchpad to watch some stuff listed in ~/Video/sp_playlist.m3u spawnMpv = "mpv --pause -x11-name mpv-sp ~/Video/sp_playlist.m3u" ++ mpvGeometry mpvPercentage mpvPercentage findMpv = appName =? "mpv-sp" manageMpv = customFloating $ W.RationalRect l t w h where h = mpvPercentage w = mpvPercentage t = 0.03 l = 0.996 - w -- ** helper functions -- -- | percentage of mpv scratchpad at start mpvPercentage :: Rational mpvPercentage = 1/4 -- | mpv needs geometry of window at start, so it won't resize itself, when -- playing next video on a playlist mpvGeometry :: RealFrac a => a -- ^ relative height of window -> a -- ^ relative width of window -> String mpvGeometry h w = " --geometry=" ++ show pw ++ "x" ++ show ph where pw = ceiling (1920 * w) ph = ceiling (1080 * h) -- * workspaces -- -- $workspaces -- -- i've got three ways of specifying them. first one is pretty close to the -- original dt's config. second is using sitelen pona pona font by jackhumbert -- (check it out [here](https://jackhumbert.github.io/sitelen-pona-pona/)). -- and third one is using linja pona font by jan same -- (check it out [here](http://musilili.net/linja-pona/)). -- -- * normal variant -- -- > myWorkspaces = [ "dev" -- > , "www" -- > , "sys" -- > , "doc" -- > , "vm" -- > , "chat" -- > , "full" -- > , "vid" -- > , "gfx" -- > ] -- -- * one using sitelen pona pona by jackhumbert -- -- this is specified with actual glyph codes because xmobar -- don't allow for ligatures and otf features. -- -- > myWorkspaces = [ "\xee3d" -- nanpa -- > , "\xee3b" -- musi -- > , "\xee49" -- pali -- > , "\xee2a" -- lipu -- > , "\xee53" -- poki -- > , "\xee6c" -- toki -- > , "\xee63" -- suli -- > , "\xee60" -- sitelen -- > , "\xee1e" -- kule -- > ] -- | workspaces container myWorkspaces = [ "\xe661\xe921" -- sona nanpa , "\xe63b" -- musi , "\xe649" -- pali , "\xe62a\xf105" -- lipu ale , "\xe653\xf115" -- poki ilo , "\xe66c" -- toki , "\xe62a\xf200" -- lipu suli , "\xf010\xe915" -- sitelen tawa , "\xf010\xf107" -- sitelen ante ]