{ options, config, lib, pkgs, namespace, ... }: with lib; with lib.${namespace}; let cfg = config.${namespace}.desktop.components.polybar; desktop = config.${namespace}.desktop; in { options.${namespace}.desktop.components.polybar = with types; { enable = mkEnableOption "polybar"; }; config = mkIf cfg.enable { services.polybar = { enable = true; script = ""; package = pkgs.polybar.override { i3Support = true; pulseSupport = true; }; settings = let c = desktop.theme.colors; in { "bar/main" = { width = "100%"; height = "24pt"; radius = 0; background = "#${c.bg}"; foreground = "#${c.fg}"; font = [ "Symbols Nerd Font:size=16;2" "monospace:size=11;2" "Sauce Code Pro Nerd Font:size=11;2" "Noto Sans CJK JP:size=11;1" "sans-serif:size=11;1" ]; border = { top = "8px"; left = "8px"; right = "8px"; color = "#00000000"; }; padding = { left = 2; right = 2; }; cursor = { click = "pointer"; scroll = "ns-resize"; }; enable-ipc = true; line.size = "3pt"; separator = { text = "|"; foreground = "#${c.bg3}"; }; module.margin = 1; modules = { left = "stat music anki"; center = "i3"; right = "wlan eth filesystem keyboard xkeyboard pulseaudio date"; }; }; "module/keyboard" = { type = "custom/script"; exec = "if [[ $(fcitx5-remote -n) == 'mozc' ]]; then printf 'jp'; else printf 'en'; fi"; interval = 1; click.left = "${pkgs.fcitx5}/bin/fcitx5-remote -t"; format = { prefix = { text = "󰌌 "; foreground = "#${c.accent}"; }; }; }; "module/music" = { type = "custom/script"; exec = "playerctl --player=playerctld,cmus,firefox,%any -F metadata --format='{{title}} - {{artist}}'"; tail = true; format = { prefix = { text = "󰎄 "; foreground = "#${c.accent}"; }; }; }; "module/stat" = { type = "custom/script"; exec = "vmstat -n 2 | awk '{printf \"%.0f%% %.2f GiB\\\\n\", 100-$15, (31998756-($4+$5+$6))/1024/1024};fflush()'"; tail = true; format = { prefix = { text = "󱕍 "; foreground = "#${c.accent}"; }; }; }; "module/anki" = { type = "custom/script"; interval = 600; interval-fail = 10; exec = pkgs.writeShellScript "get-anki-status" '' count="$(${pkgs.sqlite}/bin/sqlite3 --readonly ~/.local/share/Anki2/$(whoami)/collection.anki2 <