xmonad: switched to isaacBrown92 as a base

This commit is contained in:
Serĉanto de Scio 2022-12-07 21:17:00 +10:00
parent 4e8ee48cd2
commit 93031832aa
Signed by: sercanto
GPG key ID: 7DBA9F5689EFB6AA

View file

@ -1,149 +1,269 @@
import XMonad
import XMonad.Config.Desktop
import Data.Monoid
import Data.Word
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras
import XMonad.Actions.UpdatePointer (updatePointer)
import XMonad.Actions.CopyWindow
import XMonad.Actions.DynamicProjects
import XMonad.Actions.Navigation2D
import XMonad.Actions.SpawnOn
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.Accordion
import XMonad.Layout.Circle
import XMonad.Layout.GridVariants
import XMonad.Layout.LayoutCombinators hiding ( (|||) )
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Hooks.StatusBar
import XMonad.Layout.Decoration
import XMonad.Layout.Hidden
import XMonad.Layout.Spacing
import XMonad.Prompt
import XMonad.Prompt.Shell ( shellPrompt )
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Util.NamedWindows
import XMonad.Util.Run
import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.SpawnOnce
import System.IO
import qualified XMonad.StackSet as W
----------
-- Init --
----------
colourBackground :: String
colourBackground = "#1c1c1c"
main :: IO ()
main =
xmonad
-- ewmhFullscreen and ewmh don't commute, they MUST be in this order
. dynamicProjects projects
. ewmhFullscreen
. ewmh
. withNavigation2DConfig myNav2DConf
. (`additionalKeysP` myKeybinds)
. withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey
$ myConfig
colourForeground :: String
colourForeground = "#d0d0d0"
myConfig :: XConfig (Choose (ModifiedLayout Spacing Tall) (Choose (Mirror (ModifiedLayout Spacing Tall)) Full))
myConfig =
def
{ borderWidth = 3,
clickJustFocuses = False,
focusFollowsMouse = False,
focusedBorderColor = myFocusedBorderColor,
layoutHook = myLayout,
modMask = mod4Mask,
startupHook = myStartupHook,
normalBorderColor = myNormalBorderColor,
workspaces = myWorkspaces
}
highlightBackground :: String
highlightBackground = "#ffaf00"
myStartupHook :: X ()
myStartupHook = do
spawnOnce "feh --bg-fill ~/.dotfiles/media/backgrounds/forest-1.jpg --bg-fill ~/.dotfiles/media/backgrounds/forest-2.jpg --bg-fill ~/.dotfiles/media/backgrounds/forest-3.jpg"
highlightForeground :: String
highlightForeground = "#1c1c1c"
------------
-- xmobar --
------------
-- Set xmobar as my task bar.
myWsBar :: String
myWsBar = "xmobar -v -d $HOME/.xmobarrc"
myXmobarPP :: PP
myXmobarPP =
def
{ ppCurrent = wrap "" "" . xmobarBorder "Top" blue 2,
ppExtras = [logTitles formatFocused formatUnfocused],
ppHidden = xmobarBase0 . wrap "[" "]",
ppHiddenNoWindows = const "",
ppOrder = \[ws, l, _, wins] -> [" " ++ ws, l], -- and wins to [ws, l] to get window names
ppSep = xmobarMagenta "",
ppTitleSanitize = xmobarStrip,
ppUrgent = xmobarRed . wrap (xmobarYellow "!") (xmobarYellow "!")
}
where
formatFocused :: String -> String
formatFocused = wrap (xmobarBase0 "[") (xmobarBase0 "]") . xmobarBlue . ppWindow
myXPConfig = def -- Configure the prompt's appearance
{ alwaysHighlight = True
, bgColor = colourBackground
, bgHLight = highlightBackground
, fgColor = colourForeground
, fgHLight = highlightForeground
, font = "xft:Open Sans:size=9"
, position = Top
, promptBorderWidth = 0
}
formatUnfocused :: String -> String
formatUnfocused = wrap (xmobarBase0 "[") (xmobarBase0 "]") . xmobarBase0 . ppWindow
backgroundCmd = "feh --bg-scale ~/Documents/Images/Posters/STEVEs.jpeg"
compositeMgr = "xcompmgr -f -C -n -D 3"
hdmi1Off = "xrandr --output eDP-1 --primary --output HDMI-1 --off"
musicCmd = "mpd"
nextcloudCmd = "nextcloud"
notificationCmd = "lxqt-notificationd"
screensaverCmd = "xscreensaver --no-splash"
screensaverLock = "xscreensaver-command -lock"
screenshot = "scrot" -- Screenshot the entire screen
screenshotWindow = "sleep 0.2; scrot -s" -- Screenshot the selected window
settingsDaemon = "xsettingsd"
terminalCmd = "termonad"
trayerCmd = "trayer --edge top --SetPartialStrut false --width 7 --transparent true --alpha 0 --tint 0x1C1C1C --height 20 --monitor primary"
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
xmobarBase0, xmobarBase2, xmobarYellow, xmobarRed, xmobarMagenta, xmobarBlue :: String -> String
xmobarBase0 = xmobarColor base0 ""
xmobarBase2 = xmobarColor base2 ""
xmobarYellow = xmobarColor yellow ""
xmobarRed = xmobarColor red ""
xmobarMagenta = xmobarColor magenta ""
xmobarBlue = xmobarColor blue ""
----------------
-- Workspaces --
----------------
myWorkspaces :: [String]
myWorkspaces = [wsGEN, wsCOM, wsINT]
wsCOM, wsDOT, wsGEN, wsINT, wsLOG, wsMUS, wsREC, wsVID :: String
wsCOM = "com"
wsDOT = "dot"
wsGEN = "gen"
wsINT = "int"
wsLOG = "log"
wsMUS = "mus"
wsREC = "rec"
wsVID = "vid"
--------------
-- Projects --
--------------
projects :: [Project]
projects =
[ Project
{ projectName = wsCOM,
projectDirectory = "~/",
projectStartHook = Just $ do
spawnOn wsCOM element
},
Project
{ projectName = wsDOT,
projectDirectory = "~/.dotfiles",
projectStartHook = Just $ do spawnOn wsDOT $ editor ++ " ."
},
Project
{ projectName = wsGEN,
projectDirectory = "~/",
projectStartHook = Nothing
},
Project
{ projectName = wsINT,
projectDirectory = "~/",
projectStartHook = Just $ do spawnOn wsINT browser
},
Project
{ projectName = wsLOG,
projectDirectory = "~/",
projectStartHook = Just $ do spawnOn wsLOG logseq
},
Project
{ projectName = wsMUS,
projectDirectory = "~/",
projectStartHook = Just $ do spawnOn wsMUS musicPlayer
},
Project
{ projectName = wsREC,
projectDirectory = "~/Videos/obs-recordings",
projectStartHook = Just $ do spawnOn wsREC obs
},
Project
{ projectName = wsVID,
projectDirectory = "~/",
projectStartHook = Nothing
}
]
promptTheme :: XPConfig
promptTheme =
def
{ bgColor = base03,
bgHLight = base02,
fgColor = base0,
fgHLight = base1,
height = 31,
position = Top,
promptBorderWidth = 0
}
------------------
-- Applications --
------------------
browser, discord, editor, element, incognitoBrowser, launcher, logseq, musicPlayer, obs, screenshot, terminal :: String
browser = "brave"
discord = "discord"
editor = "codium"
element = "element-desktop"
incognitoBrowser = "brave -incognito"
launcher = "rofi -show drun -m DisplayPort-1"
logseq = "logseq"
musicPlayer = "spotify"
obs = "obs"
screenshot = "flameshot gui"
terminal = "wezterm"
--------------
-- Keybinds --
--------------
myKeybinds :: [(String, X ())]
myKeybinds =
[ -- Spawn/kill
("M-b", spawn browser),
("M-i", spawn incognitoBrowser),
("M-f", spawn screenshot),
("M-<Space>", spawn launcher),
("M-<Return>", spawn Main.terminal),
("M-<Backspace>", kill1),
-- Layout control
("M-z", sendMessage Expand),
("M-d", sendMessage NextLayout),
("M-v", sendMessage Shrink),
("M-C-d", setLayout $ Layout (layoutHook myConfig)),
("M-C-w", shiftToProjectPrompt promptTheme),
("M-w", switchProjectPrompt promptTheme)
]
-- Navigation
++ zipWith (makeKeybindZipper "M-" windowGo) htnsKeys dirs
++ zipWith (makeKeybindZipper "M-" windowSwap) gcrlKeys dirs
++ zipWith (makeKeybindZipper "M-C-" screenGo) htnsKeys dirs
++ zipWith (makeKeybindZipper "M-C-" windowToScreen) gcrlKeys dirs
where
makeKeybindZipper :: String -> (direction2D -> Bool -> xUnit) -> String -> direction2D -> (String, xUnit)
makeKeybindZipper startOfCmd func restOfCmd dir = (startOfCmd ++ restOfCmd, func dir True)
dirs :: [Direction2D]
dirs = [L, D, U, R]
gcrlKeys :: [String]
gcrlKeys = ["g", "c", "r", "l"]
htnsKeys :: [String]
htnsKeys = ["h", "t", "n", "s"]
------------
-- Layout --
------------
myLayout :: Choose (ModifiedLayout Spacing Tall) (Choose (Mirror (ModifiedLayout Spacing Tall)) Full) a
myLayout = tiled ||| Mirror tiled ||| Full
where
tiled = spacingWithEdge 5 $ Tall nmaster delta ratio
nmaster = 1
ratio = 1 / 2
delta = 3 / 100
----------------
-- Navigation --L
----------------
myNav2DConf :: Navigation2DConfig
myNav2DConf = def {defaultTiledNavigation = sideNavigation}
-------------
-- Palette --
-------------
-- solarized
base03, base02, base01, base00, base0, base1, base2, base3, yellow, orange, red, magenta, violet, blue, cyan, green :: String
base03 = "#002b36"
base02 = "#073642"
base01 = "#586e75"
base00 = "#657b83"
base0 = "#839496"
base1 = "#93a1a1"
base2 = "#eee8d5"
base3 = "#fdf6e3"
yellow = "#b58900"
orange = "#cb4b16"
red = "#dc322f"
magenta = "#d33682"
violet = "#6c71c4"
blue = "#268bd2"
cyan = "#2aa198"
green = "#859900"
-- uses of palette
myNormalBorderColor :: String
myNormalBorderColor = base03
myFocusedBorderColor :: String
myFocusedBorderColor = base1
main = do
-- Make sure that HDMI is turned off by default
spawn hdmi1Off -- Turn off HDMI-1 before we set the modes
wsbar <- spawnPipe myWsBar
xmonad $ ewmh desktopConfig
{ focusFollowsMouse = False
, terminal = terminalCmd -- Set the default terminal
, startupHook = do
spawnOnce screensaverCmd -- Launch the screen saver
spawnOnce backgroundCmd -- Set the background wallpaper
spawnOnce compositeMgr -- Launch the composite manager
spawnOnce settingsDaemon -- Launch the settings daemon
spawnOnce trayerCmd -- Launch the system tray, configured to work correctly with dual monitors
spawnOnce notificationCmd -- Launch the notification service
spawnOnce musicCmd -- Launch the music playing daemon
spawnOnce nextcloudCmd -- Launch the cloud service
, manageHook = manageDocks <+> manageHook desktopConfig
, layoutHook = avoidStruts $ layoutHook desktopConfig
||| ThreeColMid 1 (3/100) (1/2)
||| spiral (6/7)
||| Grid (16/10)
||| Circle
||| simpleTabbed
||| Accordion
||| SplitGrid T 1 2 (1/3) (16/10) (5/100)
-- ||| (ThreeColMid 1 (3/100) (1/3) *//* Full)
, handleEventHook = handleEventHook desktopConfig <+> docksEventHook
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn wsbar
, ppCurrent = xmobarColor "#ffaf00" "" . wrap "[" "]"
, ppVisible = xmobarColor "#5fafd7" "" . wrap "(" ")"
, ppLayout = xmobarColor "#5fafd7" ""
, ppTitle = xmobarColor "#ffaf00" "" . shorten 50
} >> updatePointer (0.25, 0.25) (0.25, 0.25) -- near the top-left
, modMask = mod4Mask -- Rebind Mod to the Windows key
--, borderWidth = 1
} `additionalKeys`
-- Use Xmonad's built-in launcher
[ ((mod4Mask, xK_p), shellPrompt myXPConfig)
-- Lock the screen
, ((0, 0x1008ff2d), spawn screensaverLock)
-- XF86ScreenSaver
, ((mod4Mask .|. controlMask, xK_l), spawn screensaverLock)
, ((controlMask, xK_Print), spawn screenshotWindow)
, ((0, xK_Print), spawn screenshot)
-- Turn on the eDP-1 port and set it as the primary display
, ((mod4Mask .|. shiftMask, xK_e), spawn
"xrandr --output eDP-1 --primary --auto"
)
-- Turn off the eDP-1 port
, ((mod4Mask .|. controlMask, xK_e), spawn
"xrandr --output eDP-1 --off"
)
-- Turn off the HDMI port
, ((mod4Mask .|. controlMask, xK_h), spawn
"xrandr --output HDMI-1 --off"
)
-- Turn on the HDMI-1 port and set it as the secondary display
, ((mod4Mask .|. shiftMask, xK_h), spawn
"xrandr --newmode 3840x2160 266.75 3840 4056 4456 5072 2160 2163 2168 2192 -hsync +vsync; xrandr --addmode HDMI-1 3840x2160; xrandr --output eDP-1 --off --output HDMI-1 --mode 3840x2160; feh --bg-scale ~/Documents/Images/Posters/STEVEs.jpeg"
)
, ((0 , 0x1008FF11), spawn "amixer set Master 2%-") -- XF86AudioLowerVolume
-- , ((mod4Mask , xK_Down), spawn "amixer set Master 2%-")
, ((0 , 0x1008FF12), spawn "amixer set Master toggle") -- XF86AudioMute
, ((0 , 0x1008FF13), spawn "amixer set Master 2%+") -- XF86AudioRaiseVolume
-- , ((mod4Mask , xK_Up), spawn "amixer set Master 2%+")
, ((0 , 0x1008FF14), spawn "mpc toggle") -- Play/pause
-- , ((mod4Mask , xK_End), spawn "mpc toggle")
, ((mod4Mask .|. controlMask, xK_space), spawn "mpc toggle") -- Play/pause
, ((0 , 0x1008FF15), spawn "mpc stop") -- Stop
, ((0 , 0x1008FF16), spawn "mpc prev") -- XF86AudioPrevious
, ((mod4Mask , xK_Left), spawn "mpc prev") -- prev
, ((0 , 0x1008FF17), spawn "mpc next") -- XF86AudioNext
, ((mod4Mask , xK_Right), spawn "mpc next") -- Next
-- XF86MonBrightnessUp
, ((0 , 0x1008ff02), spawn "xbrightness +5000")
-- XF86MonBrightnessDown
, ((0 , 0x1008ff03), spawn "xbrightness -5000")
]