diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6ff2a0976..f7deb577f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -194,6 +194,9 @@ /modules/programs/waybar.nix @berbiche /tests/modules/programs/waybar @berbiche +/modules/programs/xmobar.nix @t4ccer +/tests/modules/programs/xmobar @t4ccer + /modules/programs/z-lua.nix @marsam /modules/programs/zathura.nix @rprospero diff --git a/modules/modules.nix b/modules/modules.nix index 30e7fecdd..6d6cff5db 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -146,6 +146,7 @@ let (loadModule ./programs/vscode.nix { }) (loadModule ./programs/vscode/haskell.nix { }) (loadModule ./programs/waybar.nix { condition = hostPlatform.isLinux; }) + (loadModule ./programs/xmobar.nix { }) (loadModule ./programs/z-lua.nix { }) (loadModule ./programs/zathura.nix { }) (loadModule ./programs/zoxide.nix { }) diff --git a/modules/programs/xmobar.nix b/modules/programs/xmobar.nix new file mode 100644 index 000000000..0ad5d7c19 --- /dev/null +++ b/modules/programs/xmobar.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.programs.xmobar; +in { + options.programs.xmobar = { + enable = mkEnableOption "Xmobar, a minimalistic status bar"; + + package = mkOption { + default = pkgs.haskellPackages.xmobar; + defaultText = literalExample "pkgs.haskellPackages.xmobar"; + type = types.package; + description = '' + Package providing the xmobar binary. + ''; + }; + + extraConfig = mkOption { + default = ""; + example = literalExample '' + Config + { font = "Fira Code" + , borderColor = "#d0d0d0" + , border = FullB + , borderWidth = 3 + , bgColor = "#222" + , fgColor = "grey" + , position = TopSize C 99 30 + , commands = + [ Run Cpu ["-t", "cpu: %"] 10 + , Run Network "enp3s0" ["-S", "True", "-t", "eth: /"] 10 + , Run Memory ["-t","mem: %"] 10 + , Run Date "date: %a %d %b %Y %H:%M:%S " "date" 10 + , Run StdinReader + ] + , sepChar = "%" + , alignSep = "}{" + , template = " %StdinReader% | %cpu% | %memory% | %enp3s0% }{%date% " + } + ''; + type = types.lines; + description = '' + Extra configuration lines to add to + $XDG_CONFIG_HOME/xmobar/.xmobarrc. + See + + for options. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + xdg.configFile."xmobar/.xmobarrc".text = cfg.extraConfig; + }; + + meta.maintainers = with maintainers; [ t4ccer ]; +} diff --git a/tests/default.nix b/tests/default.nix index ef49cc397..130eab4c0 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -112,6 +112,7 @@ import nmt { ./modules/programs/rofi-pass ./modules/programs/terminator ./modules/programs/waybar + ./modules/programs/xmobar ./modules/services/barrier ./modules/services/dropbox ./modules/services/emacs diff --git a/tests/modules/programs/xmobar/basic-configuration.expected b/tests/modules/programs/xmobar/basic-configuration.expected new file mode 100644 index 000000000..51b06a7ef --- /dev/null +++ b/tests/modules/programs/xmobar/basic-configuration.expected @@ -0,0 +1,19 @@ +Config + { font = "Fira Code" + , borderColor = "#d0d0d0" + , border = FullB + , borderWidth = 3 + , bgColor = "#222" + , fgColor = "grey" + , position = TopSize C 99 30 + , commands = + [ Run Cpu ["-t", "cpu: %"] 10 + , Run Network "enp3s0" ["-S", "True", "-t", "eth: /"] 10 + , Run Memory ["-t","mem: %"] 10 + , Run Date "date: %a %d %b %Y %H:%M:%S " "date" 10 + , Run StdinReader + ] + , sepChar = "%" + , alignSep = "}{" + , template = " %StdinReader% | %cpu% | %memory% | %enp3s0% }{%date% " + } diff --git a/tests/modules/programs/xmobar/basic-configuration.nix b/tests/modules/programs/xmobar/basic-configuration.nix new file mode 100644 index 000000000..360cc4c3d --- /dev/null +++ b/tests/modules/programs/xmobar/basic-configuration.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.xmobar = { + enable = true; + extraConfig = '' + Config + { font = "Fira Code" + , borderColor = "#d0d0d0" + , border = FullB + , borderWidth = 3 + , bgColor = "#222" + , fgColor = "grey" + , position = TopSize C 99 30 + , commands = + [ Run Cpu ["-t", "cpu: %"] 10 + , Run Network "enp3s0" ["-S", "True", "-t", "eth: /"] 10 + , Run Memory ["-t","mem: %"] 10 + , Run Date "date: %a %d %b %Y %H:%M:%S " "date" 10 + , Run StdinReader + ] + , sepChar = "%" + , alignSep = "}{" + , template = " %StdinReader% | %cpu% | %memory% | %enp3s0% }{%date% " + } + ''; + }; + + nmt.script = '' + assertFileExists home-files/.config/xmobar/.xmobarrc + assertFileContent \ + home-files/.config/xmobar/.xmobarrc \ + ${./basic-configuration.expected} + ''; + }; +} diff --git a/tests/modules/programs/xmobar/default.nix b/tests/modules/programs/xmobar/default.nix new file mode 100644 index 000000000..f1a314890 --- /dev/null +++ b/tests/modules/programs/xmobar/default.nix @@ -0,0 +1 @@ +{ xmobar-basic-configuration = ./basic-configuration.nix; }