Skip to content

Commit

Permalink
feat: add xmonad configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-talalai committed Apr 11, 2024
1 parent a9ab6f6 commit 467bee3
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 83 deletions.
11 changes: 0 additions & 11 deletions .vscode/extensions.json

This file was deleted.

9 changes: 0 additions & 9 deletions .vscode/settings.json

This file was deleted.

96 changes: 84 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
fourmolu-nix.url = "github:jedimahdi/fourmolu-nix";
east-gate.url = "github:head-gardener/east-gate";
};

outputs = inputs:
Expand All @@ -29,7 +30,7 @@
root = ./.;
fileset = lib.fileset.unions [
./src
./xmonad-nix.cabal
./myxmonad.cabal
./LICENSE
./README.md
];
Expand All @@ -46,6 +47,7 @@
aeson.source = "1.5.0.0" # Hackage version
shower.source = inputs.shower; # Flake input
*/
east-gate.source = inputs.east-gate;
};

# Add your package overrides here
Expand Down Expand Up @@ -96,8 +98,8 @@
};

# Default package & app.
packages.default = self'.packages.xmonad-nix;
apps.default = self'.apps.xmonad-nix;
packages.default = self'.packages.myxmonad;
apps.default = self'.apps.myxmonad;

# Default shell.
devShells.default = pkgs.mkShell {
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ fmt:

# Run ghcid -- auto-recompile and run `main` function
run:
ghcid -c "cabal repl exe:xmonad-nix" --warnings -T :main
ghcid -c "cabal repl exe:myxmonad" --warnings -T :main
43 changes: 7 additions & 36 deletions xmonad-nix.cabal → myxmonad.cabal
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
cabal-version: 2.4
name: xmonad-nix
name: myxmonad
version: 0.1.0.0
license: MIT
copyright: 2022 Sridhar Ratnakumar
maintainer: srid@srid.ca
author: Sridhar Ratnakumar
category: Web
homepage: https://srid.ca/xmonad-nix

-- TODO: Before hackage release.
-- A short (one-line) description of the package.
synopsis: A template for Haskell projects using Nix

-- A longer description of the package.
-- description:

-- A URL where users can report bugs.
-- bug-reports:

extra-source-files:
LICENSE
Expand All @@ -28,11 +12,6 @@ common shared
-Wmissing-deriving-strategies -Wunused-foralls -Wunused-foralls
-fprint-explicit-foralls -fprint-explicit-kinds

mixins:
base hiding (Prelude),
relude (Relude as Prelude, Relude.Container.One),
relude

default-extensions:
BangPatterns
ConstraintKinds
Expand Down Expand Up @@ -75,23 +54,15 @@ common shared
ViewPatterns

build-depends:
, aeson
, async
, base >=4 && <5
, data-default
, directory
, filepath
, mtl
, optics-core
, profunctors
, relude >=1.0
, shower
, time
, with-utf8
, base >=4 && <5
, containers
, xmonad
, xmonad-contrib
, east-gate

hs-source-dirs: src
default-language: Haskell2010

executable xmonad-nix
executable myxmonad
import: shared
main-is: Main.hs
81 changes: 70 additions & 11 deletions src/Main.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,73 @@
module Main where
import XMonad
import Data.Monoid
import System.Exit
import XMonad.Layout.Tabbed
import XMonad.Util.EZConfig
import XMonad.Hooks.EastGate
import XMonad.Util.NamedScratchpad

import Main.Utf8 qualified as Utf8
import qualified XMonad.StackSet as W
import qualified Data.Map as M

{- |
Main entry point.
myTerminal = "alacritty"

The `, run` script will invoke this function.
-}
main :: IO ()
main = do
-- For withUtf8, see https://serokell.io/blog/haskell-with-utf8
Utf8.withUtf8 $ do
putTextLn "Hello 🌎"
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = False

myBorderWidth = 1

myModMask = mod4Mask

myWorkspaces = ["1","2","3","4","5","6","7","8","9"]

myNormalBorderColor = "#dddddd"
myFocusedBorderColor = "#ff0000"

myLayout = tiled ||| Mirror tiled ||| Full ||| simpleTabbed
where
tiled = Tall nmaster delta ratio
nmaster = 1
ratio = 1/2
delta = 3/100

scratchpads = [ NS "term" "alacritty -T scratchpad" queryTerm manageTerm]
where
queryTerm = title =? "scratchpad"
manageTerm = customFloating $ W.RationalRect xOffset yOffset width height
where
width = 0.9
height = 0.9
xOffset = 0.05
yOffset = 0.05

myManageHook = composeAll
[ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore
, resource =? "kdesktop" --> doIgnore
, namedScratchpadManageHook scratchpads
]

myStartupHook :: X ()
myStartupHook =
spawn "myxmobar"

main = xmonad $ (withMetrics def) $ myConfig

myConfig = def
{ terminal = myTerminal
, modMask = mod4Mask
, layoutHook = myLayout
, focusFollowsMouse = False
, borderWidth = 1
, workspaces = myWorkspaces
, normalBorderColor = "#dddddd"
, focusedBorderColor = "#ff0000"
, manageHook = myManageHook
, startupHook = myStartupHook
}
`additionalKeysP`
[ ("M-f", spawn "firefox")
, ("M-r", spawn "rofi -show drun")
, ("M-o", namedScratchpadAction scratchpads "term")
]

0 comments on commit 467bee3

Please sign in to comment.