From f47c274764692858292a5b1a5a0517ea5998f17f Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Mon, 27 Feb 2023 11:11:14 +0100 Subject: [PATCH] Configure status bar with home-manager --- modules/graphical/sway/default.nix | 106 +++++++++++++++++- .../graphical/sway/status-configuration.nix | 102 ----------------- 2 files changed, 104 insertions(+), 104 deletions(-) delete mode 100644 modules/graphical/sway/status-configuration.nix diff --git a/modules/graphical/sway/default.nix b/modules/graphical/sway/default.nix index 148c13a6..32b67728 100644 --- a/modules/graphical/sway/default.nix +++ b/modules/graphical/sway/default.nix @@ -4,7 +4,23 @@ let launcher = import ./launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; }; color-picker = import ./color-picker.nix { inherit pkgs; }; screenshot = import ./screenshot.nix { inherit pkgs; }; - status-configuration = import ./status-configuration.nix { inherit pkgs config; }; + mic-status = pkgs.writeShellScript "mic-status" '' + if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ] + then + echo -e '\uf131' + else + echo -e '\uf130' + fi + ''; + mail-status = pkgs.writeShellScript "mail-status" '' + mails=$(${pkgs.mblaze}/bin/mlist -N ~/mail/*/INBOX | wc -l) + if [ "$mails" -gt 0 ] + then + echo "{ \"state\": \"Info\", \"text\": \"📬 $mails\" }" + else + echo "{ \"state\": \"Idle\", \"text\": \"📭\" }" + fi + ''; in { options.chvp.graphical.sway.enable = lib.mkOption { @@ -36,6 +52,92 @@ in exec sway fi ''; + i3status-rust = { + enable = true; + bars.default = { + icons = "awesome6"; + settings.theme = { + name = "gruvbox-light"; + overrides = { + idle_bg="#ffffff"; + idle_fg="#000000"; + info_bg="#6aaeff"; + info_fg="#000000"; + good_bg="#5ada88"; + good_fg="#000000"; + warning_bg="#f5df23"; + warning_fg="#000000"; + critical_bg="#ff8892"; + critical_fg="#000000"; + separator=""; + }; + }; + blocks = [ + { + block = "net"; + device = "wlp2s0"; + format = "{ssid}"; + hide_missing = true; + hide_inactive = true; + } + { + block = "net"; + device = "wlp0s20f3"; + format = "{ssid}"; + hide_missing = true; + hide_inactive = true; + } + { + block = "net"; + device = "enp0s31f6"; + format = "{ip}"; + hide_missing = true; + hide_inactive = true; + } + { + block = "net"; + device = "enp0s13f0u2u2"; + format = "{ip}"; + hide_missing = true; + hide_inactive = true; + } + { + block = "battery"; + } + { + block = "backlight"; + } + { + block = "music"; + player = "firefox"; + marquee = false; + max_width = 40; + hide_when_empty = true; + } + { + block = "sound"; + } + { + block = "custom"; + command = "${mic-status}"; + interval = 1; + on_click = "${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + } + { + block = "custom"; + json = true; + command = "${mail-status}"; + interval = 1; + on_click = "mbsync -a && emacsclient --eval \"(mu4e-update-index)\""; + } + { + block = "time"; + interval = 1; + format = "%a %d/%m %H:%M"; + } + ]; + }; + }; }; services.kanshi = { enable = true; @@ -87,7 +189,7 @@ in }; fonts = { names = [ "Hack" ]; size = 9.0; style = "Regular"; }; position = "top"; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ${status-configuration}"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs $XDG_CONFIG_HOME/i3status-rust/config-default.toml"; extraConfig = '' status_padding 0 icon_theme Arc diff --git a/modules/graphical/sway/status-configuration.nix b/modules/graphical/sway/status-configuration.nix deleted file mode 100644 index b8fc133c..00000000 --- a/modules/graphical/sway/status-configuration.nix +++ /dev/null @@ -1,102 +0,0 @@ -{ config, pkgs, ... }: -let - mic-status = pkgs.writeShellScript "mic-status" '' - if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ] - then - echo -e '\uf131' - else - echo -e '\uf130' - fi - ''; - mail-status = pkgs.writeShellScript "mail-status" '' - mails=$(${pkgs.mblaze}/bin/mlist -N ~/mail/*/INBOX | wc -l) - if [ "$mails" -gt 0 ] - then - echo "{ \"state\": \"Info\", \"text\": \"📬 $mails\" }" - else - echo "{ \"state\": \"Idle\", \"text\": \"📭\" }" - fi - ''; -in -pkgs.writeText "configuration.toml" '' - [theme] - name = "gruvbox-light" - [theme.overrides] - idle_bg="#ffffff" - idle_fg="#000000" - info_bg="#6aaeff" - info_fg="#000000" - good_bg="#5ada88" - good_fg="#000000" - warning_bg="#f5df23" - warning_fg="#000000" - critical_bg="#ff8892" - critical_fg="#000000" - separator="" - - [icons] - name = "awesome5" - - [[block]] - block = "net" - device = "wlp2s0" - format = "{ssid}" - hide_missing = true - hide_inactive = true - - [[block]] - block = "net" - device = "wlp0s20f3" - format = "{ssid}" - hide_missing = true - hide_inactive = true - - [[block]] - block = "net" - device = "enp0s31f6" - format = "{ip}" - hide_missing = true - hide_inactive = true - - [[block]] - block = "net" - device = "enp0s13f0u2u2" - format = "{ip}" - hide_missing = true - hide_inactive = true - - [[block]] - block = "battery" - - [[block]] - block = "backlight" - - [[block]] - block = "music" - player = "firefox" - buttons = ["prev", "play", "next"] - marquee = false - max_width = 40 - hide_when_empty = true - - [[block]] - block = "sound" - - [[block]] - block = "custom" - command = "${mic-status}" - interval = 1 - on_click = "${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle" - - [[block]] - block = "custom" - json = true - command = "${mail-status}" - interval = 1 - on_click = "mbsync -a && emacsclient --eval \"(mu4e-update-index)\"" - - [[block]] - block = "time" - interval = 1 - format = "%a %d/%m %H:%M" -''