From 63e5afe8ec7844b2ee222cd05baadf27e9107504 Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Tue, 9 Apr 2024 16:59:34 -0500 Subject: [PATCH] added i3status-rust. --- hosts/archlaptop-vm/default.nix | 1 + hosts/workstation-vm/default.nix | 1 + modules/both/i3/default.nix | 11 +++++ modules/both/i3/i3status-rust.nix | 77 +++++++++++++++++++++++++++++++ modules/commonopts.nix | 8 ++++ 5 files changed, 98 insertions(+) create mode 100644 modules/both/i3/i3status-rust.nix diff --git a/hosts/archlaptop-vm/default.nix b/hosts/archlaptop-vm/default.nix index a93aa67..c5bf8a4 100644 --- a/hosts/archlaptop-vm/default.nix +++ b/hosts/archlaptop-vm/default.nix @@ -27,6 +27,7 @@ inputs.nixpkgs.lib.nixosSystem { host = { user = "gabe"; gui.enable = true; + isVm=true; }; networking.hostName = "archlaptop-vm"; # Define your hostname. # Set your time zone. diff --git a/hosts/workstation-vm/default.nix b/hosts/workstation-vm/default.nix index e5ab33f..05d1243 100644 --- a/hosts/workstation-vm/default.nix +++ b/hosts/workstation-vm/default.nix @@ -27,6 +27,7 @@ inputs.nixpkgs.lib.nixosSystem { host = { user = "gabe"; gui.enable = true; + isVm=true; }; networking.hostName = "workstation-vm"; # Define your hostname. # Set your time zone. diff --git a/modules/both/i3/default.nix b/modules/both/i3/default.nix index 56cca1f..d4db486 100644 --- a/modules/both/i3/default.nix +++ b/modules/both/i3/default.nix @@ -202,6 +202,16 @@ notification = false; } ]; + bars = [ + { + fonts = { + names = ["Fira Code"]; + size = 8.0; + }; + position = "bottom"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; + } + ]; }; }; imports = [ @@ -214,5 +224,6 @@ }; imports = [ ../sound.nix + ./i3status-rust.nix ]; } diff --git a/modules/both/i3/i3status-rust.nix b/modules/both/i3/i3status-rust.nix new file mode 100644 index 0000000..49e1bdb --- /dev/null +++ b/modules/both/i3/i3status-rust.nix @@ -0,0 +1,77 @@ +{ + config, + pkgs, + lib, + ... +}: { + home-manager.users.${config.host.user} = { + config, + osConfig, + lib, + ... + }: { + programs.i3status-rust = { + enable = true; + bars = { + default = { + blocks = [ + { + block = "music"; + format = " $icon {$combo.str(max_w:25,rot_interval:0.5) $play $next $prev $player.str(max_w:5,rot_interval:0.5) [$cur/$avail] |} "; + } + { + block = "memory"; + format = " $icon $mem_used_percents "; + format_alt = " $icon $swap_used_percents (swap)"; + } + { + block = "cpu"; + interval = 1; + } + { + block = "load"; + format = " $icon $1m "; + interval = 1; + } + ( + lib.mkIf + (!osConfig.host.isVm) + {block = "backlight";} + ) + ( + lib.mkIf (osConfig.host.isLaptop) + { + block = "battery"; + driver = "upower"; + format = "$icon $percentage {$time |}"; + } + ) + { + block = "net"; + format = "$icon {$signal_strength $ssid.str(max_w:5,rot_interval:0.5)|}"; + format_alt = " $icon {$signal_strength $ssid.str(max_w:5,rot_interval:0.5) $frequency|} $ip | $ipv6 via $device"; + } + { + block = "sound"; + format = "$icon {$volume.bar(v:true) $volume.eng(w:2) |}"; + headphones_indicator = true; + click = [ + { + button = "left"; + cmd = "pwvucontrol"; + } + ]; + } + { + block = "time"; + format = " $timestamp.datetime(f:'%F %R') "; + interval = 60; + } + ]; + theme = "gruvbox-dark"; + icons = "material-nf"; + }; + }; + }; + }; +} diff --git a/modules/commonopts.nix b/modules/commonopts.nix index f17382b..5600193 100644 --- a/modules/commonopts.nix +++ b/modules/commonopts.nix @@ -18,6 +18,14 @@ description = "enable GUI"; default = false; }; + isLaptop=lib.mkEnableOption { + description="machine is a laptop"; + default=false; + }; + isVm=lib.mkEnableOption { + description="machine is a virtual machine"; + default=false; + }; }; }; }