From 081f6beb8d040b960fdc51ceed7911fa619b281e Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 13 Aug 2023 15:21:32 +0200 Subject: feat(users/Profpatsch): add my xmonad config Change-Id: I41d7c3029990f5f1ae56a767331781b38e69997c Reviewed-on: https://cl.tvl.fyi/c/depot/+/9077 Autosubmit: Profpatsch Reviewed-by: Profpatsch Tested-by: BuildkiteCI --- users/Profpatsch/my-xmonad/Xmonad.hs | 127 +++++++++++++++++++++++++++++ users/Profpatsch/my-xmonad/default.nix | 25 ++++++ users/Profpatsch/my-xmonad/my-xmonad.cabal | 62 ++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 users/Profpatsch/my-xmonad/Xmonad.hs create mode 100644 users/Profpatsch/my-xmonad/default.nix create mode 100644 users/Profpatsch/my-xmonad/my-xmonad.cabal (limited to 'users/Profpatsch/my-xmonad') diff --git a/users/Profpatsch/my-xmonad/Xmonad.hs b/users/Profpatsch/my-xmonad/Xmonad.hs new file mode 100644 index 000000000000..bb727ac2f1f2 --- /dev/null +++ b/users/Profpatsch/my-xmonad/Xmonad.hs @@ -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 I’m spoiled + ("M-S-x", kill), + -- exchange M-Ret and M-S-Ret + ("M-", spawn $ term Normal), + ("C-M-", spawn $ term Presentation), + ("M-S-", 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 diff --git a/users/Profpatsch/my-xmonad/default.nix b/users/Profpatsch/my-xmonad/default.nix new file mode 100644 index 000000000000..708d50e9608c --- /dev/null +++ b/users/Profpatsch/my-xmonad/default.nix @@ -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 diff --git a/users/Profpatsch/my-xmonad/my-xmonad.cabal b/users/Profpatsch/my-xmonad/my-xmonad.cabal new file mode 100644 index 000000000000..175c6c163387 --- /dev/null +++ b/users/Profpatsch/my-xmonad/my-xmonad.cabal @@ -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 -- cgit 1.4.1