Skip to content

Commit

Permalink
migrate old xmonad config
Browse files Browse the repository at this point in the history
  • Loading branch information
WeissP committed Jan 21, 2024
1 parent 6fa93ca commit f6b35d4
Show file tree
Hide file tree
Showing 14 changed files with 1,288 additions and 43 deletions.
7 changes: 7 additions & 0 deletions devshell.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[commands]]
name = "doc"
command = '''
echo http://127.0.0.1:9898
hoogle serve -p 9898 --local
'''
help = "run hoogle server locally for documentation"
73 changes: 71 additions & 2 deletions flake.lock

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

65 changes: 42 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
description = "weiss-xmonad";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
};

outputs = inputs:
outputs = { self, flake-utils, devshell, nixpkgs, ... }:
let
overlay = final: prev: {
haskell = prev.haskell // {
Expand All @@ -13,33 +16,49 @@
weiss-xmonad = hfinal.callCabal2nix "weiss-xmonad" ./. { };
};
};
weiss-xmonad = final.haskell.lib.compose.justStaticExecutables final.haskellPackages.weiss-xmonad;
weiss-xmonad = final.haskell.lib.compose.justStaticExecutables
final.haskellPackages.weiss-xmonad;
};
perSystem = system:
let
pkgs = import inputs.nixpkgs { inherit system; overlays = [ overlay ]; };
hspkgs = pkgs.haskellPackages;
in
{
devShells = rec {
default = weiss-xmonad-shell;
weiss-xmonad-shell = hspkgs.shellFor {
withHoogle = true;
packages = p: [ p.weiss-xmonad ];
buildInputs = [
hspkgs.cabal-install
hspkgs.haskell-language-server
hspkgs.hlint
hspkgs.ormolu
pkgs.bashInteractive
];
};
pkgs = import nixpkgs {
inherit system;
overlays = [ overlay devshell.overlays.default ];
};
ghcVersion = "ghc948";
hspkgs = pkgs.haskell.packages.${ghcVersion};
devShells.shellFor = hspkgs.shellFor {
packages = p: [ p.weiss-xmonad ];
withHoogle = true;
};
in {
devShells.default = pkgs.devshell.mkShell {
name = "weiss-xmonad";
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
# packages = [ pkgs.hpack ];
packagesFrom = [ devShells.shellFor ];
commands = [
(let cabal = pkgs.cabal-install;
in {
name = cabal.pname;
help = cabal.meta.description;
package = cabal;
category = "tools";
})
(let hls = hspkgs.haskell-language-server;
in {
name = hls.pname;
help = hls.meta.description;
package = hls;
category = "tools";
})
];
packages = [ hspkgs.hlint hspkgs.fourmolu hspkgs.cabal-fmt ];
};
packages = rec {
default = weiss-xmonad;
weiss-xmonad = pkgs.weiss-xmonad;
};
};
in
{ inherit overlay; } // inputs.flake-utils.lib.eachDefaultSystem perSystem;
in { inherit overlay; } // flake-utils.lib.eachDefaultSystem perSystem;
}
8 changes: 8 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
indentation: 2
comma-style: leading
record-brace-space: true
indent-wheres: true
diff-friendly-import-export: true
respectful: true
haddock-style: multi-line
newlines-between-decls: 1
7 changes: 0 additions & 7 deletions src/Lib.hs

This file was deleted.

71 changes: 71 additions & 0 deletions src/MyLogger.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module MyLogger where

import Data.List
import Data.Maybe
import Text.Regex
import XMonad
import XMonad.Hooks.StatusBar.PP
import qualified XMonad.StackSet as W
import XMonad.Util.Loggers
import XMonad.Util.NamedWindows

totalTitlesLength, unfocusedTitleLength :: Int
totalTitlesLength = 90
unfocusedTitleLength = 30

-- receive one sperate and three funs to format count, focused window and unfocused window
myLogTitles
:: String
-> String
-> (Int -> String)
-> (String -> String)
-> ([String] -> String)
-> Logger
myLogTitles sep1 sep2 formatCount formatFoc formatUnfoc = do
winset <- gets windowset
let focWin = W.peek winset
wins = W.index winset
winsUnfoc = filter (\w -> Just w /= focWin) wins
count = length wins
winNamesUnfoc <- case winsUnfoc of
[] -> pure ""
xs -> (sep2 ++) . formatUnfoc <$> traverse (fmap show . getName) xs
focWinName <- case focWin of
Just justFoc ->
(sep1 ++)
. formatFoc
. shorten (totalTitlesLength - (count - 1) * unfocusedTitleLength)
. show
<$> getName justFoc
Nothing -> pure ""
pure . Just $ formatCount count ++ focWinName ++ winNamesUnfoc


logWindowCount :: X (Maybe String)
logWindowCount = withWindowSet ct where
ct ss =
return
$ Just
$ show
$ length
$ W.integrate'
$ W.stack
$ W.workspace
$ W.current ss


logMaster :: X Bool
logMaster = withWindowSet isMaster where
isMaster ss = return $ case W.stack . W.workspace . W.current $ ss of
Just (W.Stack _ [] _) -> True
_ -> False

trimPrefixWithList :: [String] -> Maybe String -> Maybe String
trimPrefixWithList _ Nothing = Nothing
trimPrefixWithList xs (Just s) = case mapMaybe (`stripPrefix` s) xs of
[] -> Just s
n : _ -> trimPrefixWithList xs (Just n)

trimLayoutModifiers :: Maybe String -> Maybe String
trimLayoutModifiers = trimPrefixWithList ["Spacing", " "]

Loading

0 comments on commit f6b35d4

Please sign in to comment.