rcfiles/.xmonad/xmonad.hs

328 lines
9.8 KiB
Haskell
Raw Normal View History

2016-05-29 12:06:32 +00:00
import XMonad
import XMonad.Actions.CopyWindow
import XMonad.Actions.DynamicProjects
import XMonad.Actions.Navigation2D
import XMonad.Actions.SinkAll
import XMonad.Actions.SpawnOn
2016-05-29 12:06:32 +00:00
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.StatusBar
import XMonad.Layout.Decoration
import XMonad.Layout.Hidden
import XMonad.Layout.Spacing
2022-12-11 08:15:25 +00:00
import XMonad.Layout.Spiral
import XMonad.Layout.ThreeColumns
import XMonad.Prompt
import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.SpawnOnce
----------
-- Init --
----------
main :: IO ()
main =
xmonad
-- ewmhFullscreen and ewmh don't commute, they MUST be in this order
. dynamicProjects projects
. ewmhFullscreen
. ewmh
. withNavigation2DConfig myNav2DConf
. (`additionalKeysP` myKeybinds)
2023-08-26 11:51:20 +00:00
. withEasySB (statusBarProp "polybar" (pure myPolybarPP)) defToggleStrutsKey
$ myConfig
-- myConfig :: XConfig (Choose (ModifiedLayout Spacing Tall) (Choose (Mirror (ModifiedLayout Spacing Tall)) Full))
myConfig =
def
2022-12-07 11:34:05 +00:00
{ borderWidth = 1,
clickJustFocuses = False,
focusFollowsMouse = False,
focusedBorderColor = myFocusedBorderColor,
layoutHook = myLayout,
modMask = mod4Mask,
startupHook = myStartupHook,
normalBorderColor = myNormalBorderColor,
workspaces = myWorkspaces
}
myStartupHook :: X ()
myStartupHook = do
spawnOnce myBackground
2022-12-08 11:36:07 +00:00
spawnOnce myScreenLockCmd
2023-10-17 05:21:06 +00:00
spawnOnce notificationDaemon
------------
2023-08-26 11:51:20 +00:00
-- polybar --
------------
2023-08-26 11:51:20 +00:00
myPolybarPP :: PP
myPolybarPP =
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
formatUnfocused :: String -> String
formatUnfocused = wrap (xmobarBase0 "[") (xmobarBase0 "]") . xmobarBase0 . ppWindow
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]
2023-08-29 03:33:11 +00:00
myWorkspaces = [wsSIG, wsIOG, wsMIO, wsSEC, wsLOG, wsMUS, wsREC, wsVID, wsADA]
2023-08-29 03:33:11 +00:00
wsIOG, wsSEC, wsSIG, wsMIO, wsLOG, wsMUS, wsREC, wsVID, wsADA :: String
2022-12-18 12:33:45 +00:00
wsIOG = "iog"
2023-08-29 03:33:11 +00:00
wsSEC = "sec"
2022-12-18 12:33:45 +00:00
wsSIG = "sig"
wsMIO = "mio"
wsLOG = "log"
wsMUS = "mus"
wsREC = "rec"
wsVID = "vid"
2022-12-18 12:33:45 +00:00
wsADA = "ada"
--------------
-- Projects --
--------------
projects :: [Project]
projects =
[ Project
2022-12-18 12:33:45 +00:00
{ projectName = wsIOG,
2023-08-29 03:33:11 +00:00
projectDirectory = "~/source/IOG",
projectStartHook = Just $ do
2022-12-18 12:33:45 +00:00
spawnOn wsIOG iogBrowser
spawnOn wsIOG slack
2023-10-19 04:18:54 +00:00
spawnOn wsIOG iogTerminal
spawnOn wsIOG iogNeomuttTerminal
},
Project
2023-08-29 03:33:11 +00:00
{ projectName = wsSEC,
projectDirectory = "~/.dotfiles",
2023-08-29 03:33:11 +00:00
projectStartHook = Just $ do spawnOn wsSEC incognitoBrowser
},
Project
2022-12-18 12:33:45 +00:00
{ projectName = wsSIG,
projectDirectory = "~/",
2022-12-18 15:03:06 +00:00
projectStartHook = Just $ do
spawnOn wsSIG signal
},
Project
2022-12-18 12:33:45 +00:00
{ projectName = wsMIO,
2023-08-29 03:33:11 +00:00
projectDirectory = "~/forge/mio-ops",
projectStartHook = Just $ do
spawnOn wsMIO browser
spawnOn wsMIO element
spawnOn wsMIO mastodon
2023-12-05 10:41:20 +00:00
spawnOn wsMIO mioTerminal
spawnOn wsMIO myNeomuttTerminal
},
Project
{ projectName = wsLOG,
projectDirectory = "~/",
2022-12-18 12:33:45 +00:00
projectStartHook = Just $ do spawnOn wsIOG myTerminal
},
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
2022-12-18 12:33:45 +00:00
},
Project
{ projectName = wsADA,
projectDirectory = "~/",
projectStartHook = Just $ do spawnOn wsADA daedalus
2022-12-18 14:30:47 +00:00
}
]
promptTheme :: XPConfig
promptTheme =
def
{ bgColor = base03,
bgHLight = base02,
fgColor = base0,
fgHLight = base1,
height = 31,
position = Top,
promptBorderWidth = 0
}
------------------
-- Applications --
------------------
2023-12-05 10:41:20 +00:00
brightnessDown, brightnessUp, browser, discord, editor, element, hibernate, incognitoBrowser, iogBrowser, launcher, logseq, musicPlayer, notificationDaemon, obs, screenshot, signal, slack, iogNeomuttTerminal, iogTerminal, mioTerminal, myNeomuttTerminal, myTerminal, volumeDown, volumeMute, volumeUp :: String
brightnessDown = "light -U 10 ; notify-send -h int:value:$(light -G) \"Brightness\""
brightnessUp = "light -A 10 ; notify-send -h int:value:$(light -G) \"Brightness\""
2023-09-18 04:07:59 +00:00
browser = "firefox"
2022-12-18 12:33:45 +00:00
daedalus = "daedalus"
discord = "discord"
editor = "codium"
element = "element-desktop"
2022-12-11 08:16:57 +00:00
enableEDP1 = "xrandr --output eDP-1 --primary --auto --output HDMI-1 --off"
enableHDMI1 = "xrandr --output eDP-1 --off --output HDMI-1 --primary --mode 3840x2160"
2022-12-20 08:50:41 +00:00
hibernate = "sudo systemctl hibernate"
2023-09-18 04:07:59 +00:00
incognitoBrowser = "firefox --private-window"
iogBrowser = "brave --profile-directory='Profile 1'"
2022-12-07 11:54:20 +00:00
launcher = "rofi -show drun"
logseq = "logseq"
musicPlayer = "spotify"
myBackground = "feh --bg-fill ~/Documents/images/posters/auroraAustralis.jpg"
2023-10-17 05:21:06 +00:00
notificationDaemon = "dunst"
obs = "obs"
screenshot = "flameshot gui"
2022-12-18 15:03:06 +00:00
signal = "signal-desktop"
2022-12-18 12:33:45 +00:00
slack = "slack"
2023-08-29 03:33:11 +00:00
mastodon = "whalebird"
2023-10-19 04:18:54 +00:00
iogNeomuttTerminal = "terminology -e neomutt -F ~/.mutt/profile.IOHK"
iogTerminal = "terminology -e 'tmux new-session -f /etc/tmux.conf -c ~/source/IOG -s IOG'"
2023-12-05 10:41:20 +00:00
mioTerminal = "terminology -e 'tmux new-session -f /etc/tmux.conf -c ~/forge/mio-ops -s mio'"
myNeomuttTerminal = "terminology -e neomutt"
2023-08-29 03:33:11 +00:00
myTerminal = "terminology"
2022-12-08 11:36:07 +00:00
myScreenLockCmd = "xscreensaver --no-splash"
myScreenLock = "xscreensaver-command -lock"
2023-09-18 01:18:27 +00:00
volumeDown = "amixer set Master 2%- ; notify-send \"Volume\" -h int:value:$(amixer sget Master | awk '$0~/%/{print $5}' | tr -d '[]') -h string:x-canonical-private-synchronous:volume"
2022-12-18 14:50:10 +00:00
volumeMute = "amixer set Master toggle"
2023-09-18 01:18:27 +00:00
volumeUp = "amixer set Master 2%+ ; notify-send \"Volume\" -h int:value:$(amixer sget Master | awk '$0~/%/{print $5}' | tr -d '[]') -h string:x-canonical-private-synchronous:volume"
--------------
-- Keybinds --
--------------
myKeybinds :: [(String, X ())]
myKeybinds =
[ -- Spawn/kill
("M-b", spawn browser),
("M-i", spawn incognitoBrowser),
("M-f", spawn screenshot),
2022-12-07 11:54:20 +00:00
("M-p", spawn launcher),
("M-S-e", spawn enableEDP1 >> spawn myBackground ),
("M-S-h", spawn enableHDMI1 >> spawn myBackground ),
2022-12-18 12:33:45 +00:00
("M-S-<Return>", spawn myTerminal),
("M-<Backspace>", kill1),
-- Layout control
("M-z", sendMessage Expand),
("M-d", sendMessage NextLayout),
("M-v", sendMessage Shrink),
2022-12-08 11:36:07 +00:00
("M-C-S-l", spawn myScreenLock),
("M-C-d", setLayout $ Layout (layoutHook myConfig)),
("M-C-w", shiftToProjectPrompt promptTheme),
2022-12-18 14:30:47 +00:00
("M-w", switchProjectPrompt promptTheme),
("M-S-f", sinkAll), -- re-tile all floating windows
2022-12-18 14:30:47 +00:00
-- Environment controls
2022-12-18 14:50:10 +00:00
("<XF86AudioLowerVolume>", spawn volumeDown),
("<XF86AudioMute>", spawn volumeMute),
("<XF86AudioRaiseVolume>", spawn volumeUp),
2022-12-18 14:30:47 +00:00
("<XF86MonBrightnessDown>", spawn brightnessDown),
2022-12-20 08:50:41 +00:00
("<XF86MonBrightnessUp>", spawn brightnessUp),
("<XF86Sleep>", spawn hibernate)
]
-- 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
2022-12-12 21:54:13 +00:00
myLayout = spacedThreeColMid
||| spacedSpiral
||| tiled
||| Mirror tiled
||| Full
where
2022-12-12 21:54:13 +00:00
tiled = spacing 3 $ Tall nmaster delta ratio
spacedSpiral = spacing 3 $ spiral (6/7)
spacedThreeColMid = spacing 3 $ ThreeColMid nmaster delta ratio
nmaster = 1
ratio = 1 / 2
delta = 3 / 100
----------------
2022-12-18 12:33:45 +00:00
-- Navigation --
----------------
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
2022-12-07 11:34:05 +00:00
myNormalBorderColor = violet
myFocusedBorderColor :: String
2022-12-07 11:34:05 +00:00
myFocusedBorderColor = red