glorious refactor (part 2

This commit is contained in:
Schrottkatze 2024-03-06 11:09:02 +01:00
parent 2a5e635c0d
commit d002a100dd
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
20 changed files with 308 additions and 347 deletions

View file

@ -0,0 +1,27 @@
{
lib,
pkgs,
...
}: let
xmobarGhc = pkgs.haskellPackages.ghcWithPackages (pkgs:
with pkgs; [
xmobar
statgrab
]);
in {
home = {
packages = [xmobarGhc];
file."xmobar.hs" = rec {
source = ./xmobar.hs;
target = ".config/xmobar/xmobar.hs";
onChange = ''
${xmobarGhc}/bin/ghc -threaded ${target}
${pkgs.busybox}/bin/pkill xmobar
${pkgs.haskellPackages.xmonad}/bin/xmonad --restart
'';
};
};
programs.xmobar = {
enable = true;
};
}

View file

@ -0,0 +1,47 @@
import Xmobar
import System.Statgrab
-- TODOS:
-- - custom cpu module
-- - custom mem module
-- - custom network/ping module with avg of n pings and blah
-- - custom graph rendering based on braille characters
-- - custom "ramp" thingies
-- - newsticker?
-- - mail/message monitoring
-- - if possible, different bars per workspace
data CustomCpu = CustomCpu
deriving (Read, Show)
instance Exec CustomCpu where
alias CustomCpu = "cpu"
run CustomCpu = do
-- return (show :: IO String (snapshot :: Stats CPUPercent))
return "meow"
fc code content = "<fc=" ++ code ++ ">" ++ content ++ "</fc>"
sep = fc "#7c6f64"
icon = fc "#d65d0e"
config :: Config
config =
defaultConfig
{ font = "FiraCode Nerd Font",
allDesktops = True,
alpha = 255,
bgColor = "#282828",
fgColor = "#ebdbb2",
commands =
[ Run $ Xmobar.Memory ["t", "Mem: <usedratio>%"] 10,
Run $ CustomCpu,
Run $ Date (icon "\983277" ++ " %Y" ++ sep "-" ++ "%m" ++ sep "-" ++ "%d " ++ icon "\988236" ++ " %H" ++ sep ":" ++ "%M" ++ sep ":" ++ "%S ") "date" 10
],
template = "%memory% }{ %cpu% }{ %date%",
alignSep = "}{",
position = TopH 24
}
main :: IO ()
main = xmobar config -- or: configFromArgs config >>= xmobar