feat(users/Profpatsch): add my xmonad config

Change-Id: I41d7c3029990f5f1ae56a767331781b38e69997c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9077
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2023-08-13 15:21:32 +02:00 committed by clbot
parent 8fb4c949dc
commit 081f6beb8d
6 changed files with 221 additions and 0 deletions

View file

@ -11,3 +11,5 @@ packages:
./whatcd-resolver/whatcd-resolver.cabal ./whatcd-resolver/whatcd-resolver.cabal
./ircmail/ircmail.cabal ./ircmail/ircmail.cabal
./httzip/httzip.cabal ./httzip/httzip.cabal
./declib/declib.cabal
./my-xmonad/my-xmonad.cabal

View file

@ -28,3 +28,7 @@ cradle:
component: "lib:ircmail" component: "lib:ircmail"
- path: "./httzip/Httzip.hs" - path: "./httzip/Httzip.hs"
component: "httzip:exe:httzip" component: "httzip:exe:httzip"
- path: "./declib/Declib.hs"
component: "declib:exe:declib"
- path: "./my-xmonad/Xmonad.hs"
component: "my-xmonad:exe:xmonad"

View file

@ -0,0 +1,127 @@
module Main where
import Data.Function ((&))
import XMonad
import XMonad qualified as Xmonad
import XMonad.Hooks.EwmhDesktops (ewmh)
import XMonad.Layout.Decoration
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances (StdTransformers (..))
import XMonad.Layout.Tabbed (TabbedDecoration)
import XMonad.Layout.Tabbed qualified as Tabbed
import XMonad.StackSet qualified as StackSet
import XMonad.Util.Cursor (setDefaultCursor)
import XMonad.Util.EZConfig (additionalKeys, additionalKeysP, removeKeysP)
data Mode = Normal | Presentation
main :: IO ()
main = do
let config = ewmh myConfig
dirs <- Xmonad.getDirectories
Xmonad.launch config dirs
myConfig ::
XConfig
( MultiToggle
( HCons
StdTransformers
XMonad.Layout.MultiToggle.EOT
)
( ModifiedLayout
( Decoration
TabbedDecoration
DefaultShrinker
)
Tall
)
)
myConfig =
conf
{ modMask = modKey,
terminal = term Normal,
focusedBorderColor = "#859900",
layoutHook = layout,
startupHook = setDefaultCursor xC_heart,
workspaces = workspaceNames
}
`additionalKeysP` ( [
-- fullscreen
("M-e", sendMessage $ Toggle NBFULL),
-- i3-like keybindings, because Im spoiled
("M-S-x", kill),
-- exchange M-Ret and M-S-Ret
("M-<Return>", spawn $ term Normal),
("C-M-<Return>", spawn $ term Presentation),
("M-S-<Return>", windows StackSet.swapMaster)
-- open simple exec dmenu
]
++
-- something something workspaces
[ (otherModMasks ++ "M-" ++ [key], action tag)
| (tag, key) <- zip workspaceNames "123456789",
(otherModMasks, action) <-
[ ("", windows . StackSet.greedyView),
("S-", windows . StackSet.shift)
]
]
++
-- mod-{w,e,r} %! Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r} %! Move client to screen 1, 2, or 3
[ ("M-v", focusToScreen 0),
-- , ("M-l", focusToScreen 1)
("M-c", focusToScreen 2),
("M-S-v", windowToScreen 0),
("M-S-l", windowToScreen 1),
("M-S-c", windowToScreen 2)
]
-- ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
-- | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
-- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
)
`additionalKeys`
-- arrow keys should move as well (hjkl blindness)
[ ((modKey, xK_Up), windows StackSet.focusUp),
((modKey, xK_Down), windows StackSet.focusDown)
]
`removeKeysP` [
-- previous kill command
"M-S-c",
-- It is way to easy to kill everything by default
"M-S-q",
-- no idea, I want to use it for Mozc
"M-n"
]
where
conf = def
workspaceNames = conf & workspaces
modKey = mod4Mask
-- TODO: meh
term :: Mode -> String
-- TODO: get terminal-emulator from the system config (currently alacritty)
term Normal = "terminal-emulator"
term Presentation = "notify-send TODO: currently not terminal presentation mode implemented" -- "terminal- -u ~/.config/lilyterm/pres.conf"
toScreen with _number = screenWorkspace 0 >>= \ws -> whenJust ws (windows . with)
focusToScreen = toScreen StackSet.view
windowToScreen = toScreen StackSet.shift
-- copied from Xmonad.Config
layout ::
MultiToggle
(HCons StdTransformers EOT)
(ModifiedLayout (Decoration TabbedDecoration DefaultShrinker) Tall)
Window
layout =
tiled
& Tabbed.addTabsBottom Tabbed.shrinkText def
& toggleFullscreen
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1 / 2
-- Percent of screen to increment by when resizing panes
delta = 3 / 100
toggleFullscreen = mkToggle1 NBFULL

View file

@ -0,0 +1,25 @@
{ depot, pkgs, lib, ... }:
let
# bins = depot.nix.getBins pkgs.sqlite ["sqlite3"];
my-xmonad = pkgs.haskellPackages.mkDerivation {
pname = "my-xmonad";
version = "0.1.0";
src = depot.users.Profpatsch.exactSource ./. [
./my-xmonad.cabal
./Xmonad.hs
];
libraryHaskellDepends = [
pkgs.haskellPackages.xmonad-contrib
];
isExecutable = true;
isLibrary = false;
license = lib.licenses.mit;
};
in
my-xmonad

View file

@ -0,0 +1,62 @@
cabal-version: 3.0
name: my-xmonad
version: 0.1.0.0
author: Profpatsch
maintainer: mail@profpatsch.de
common common-options
ghc-options:
-Wall
-Wno-type-defaults
-Wunused-packages
-Wredundant-constraints
-fwarn-missing-deriving-strategies
-- See https://downloads.haskell.org/ghc/latest/docs/users_guide/exts.html
-- for a description of all these extensions
default-extensions:
-- Infer Applicative instead of Monad where possible
ApplicativeDo
-- Allow literal strings to be Text
OverloadedStrings
-- Syntactic sugar improvements
LambdaCase
MultiWayIf
-- Makes the (deprecated) usage of * instead of Data.Kind.Type an error
NoStarIsType
-- Convenient and crucial to deal with ambiguous field names, commonly
-- known as RecordDotSyntax
OverloadedRecordDot
-- does not export record fields as functions, use OverloadedRecordDot to access instead
NoFieldSelectors
-- Record punning
RecordWildCards
-- Improved Deriving
DerivingStrategies
DerivingVia
-- Type-level strings
DataKinds
-- to enable the `type` keyword in import lists (ormolu uses this automatically)
ExplicitNamespaces
default-language: GHC2021
executable xmonad
import: common-options
main-is: Xmonad.hs
build-depends:
base >=4.15 && <5,
xmonad,
xmonad-contrib

View file

@ -54,6 +54,7 @@ pkgs.mkShell {
h.tmp-postgres h.tmp-postgres
h.postgresql-simple h.postgresql-simple
h.resource-pool h.resource-pool
h.xmonad-contrib
])) ]))
pkgs.rustup pkgs.rustup