diff --git a/cli/sh.nix b/cli/sh.nix index 779b5ef..5b318f3 100644 --- a/cli/sh.nix +++ b/cli/sh.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, pkgs, lib, ... }: let shellAliases = { btw = "echo I use NixOS, btw"; @@ -12,6 +12,15 @@ let ''; in { + xdg.configFile."scripts" = { + recursive = true; + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dotfiles/scripts"; + }; + home.packages = with pkgs; [ + lm_sensors + gnugrep + ]; + programs = { fzf.enable = true; starship.enable = true; diff --git a/hot-configs/tmux.conf b/hot-configs/tmux.conf index 2b5962e..90d87f0 100644 --- a/hot-configs/tmux.conf +++ b/hot-configs/tmux.conf @@ -11,7 +11,7 @@ set -g status-keys emacs set -s escape-time 0 set -g display-time 4000 set -g focus-events -set -g status-interval 2 +set -g status-interval 5 setw -g aggressive-resize on set -g default-terminal "screen-256color" set -g terminal-overrides ',xterm-256color:RGB,screen-256color:RGB,tmux-256color:RGB' @@ -43,7 +43,12 @@ set -g window-status-current-format "\ #[fg=brightblack,bg=default]\ " -set -g status-left-length 100 +set -g status-right-length 100 +set -g status-right "\ +#[fg=red]#(~/.config/scripts/battery.sh) #[fg=default]| \ +#[fg=blue]#(~/.config/scripts/cpu.sh) #[fg=default]| \ +#[fg=blue]#(~/.config/scripts/memory.sh)\ +" bind ':' command-prompt diff --git a/scripts/battery.sh b/scripts/battery.sh new file mode 100755 index 0000000..c4712f4 --- /dev/null +++ b/scripts/battery.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -euo pipefail + +HEALTHY_LIMIT=80 +BATTERY="/sys/class/power_supply/BAT0" + +capacity="$(cat "$BATTERY/capacity" 2>&1)" +case "$(cat "$BATTERY/status" 2>&1)" in + "Not charging") + if [ "$capacity" -gt "$HEALTHY_LIMIT" ]; then + printf "󰂄" + else + printf "󱈑" + fi + ;; + Discharging) + if [ "$capacity" -gt "$HEALTHY_LIMIT" ]; then + printf "󱟞" + elif [ "$capacity" -gt 70 ]; then + printf "󰂂" + elif [ "$capacity" -gt 60 ]; then + printf "󰂀" + elif [ "$capacity" -gt 50 ]; then + printf "󰁿" + elif [ "$capacity" -gt 40 ]; then + printf "󰁽" + elif [ "$capacity" -gt 30 ]; then + printf "󰁼" + elif [ "$capacity" -gt 20 ]; then + printf "󰁻" + else + printf "󰂎!" + fi + ;; + Charging) + if [ "$capacity" -gt "$HEALTHY_LIMIT" ]; then + printf "󰂃󱐋" # Battery shouldn't be charging beyond the healthy limit + elif [ "$capacity" -gt 70 ]; then + printf "󰂂󱐋" + elif [ "$capacity" -gt 60 ]; then + printf "󰂀󱐋" + elif [ "$capacity" -gt 50 ]; then + printf "󰁿󱐋" + elif [ "$capacity" -gt 40 ]; then + printf "󰁽󱐋" + elif [ "$capacity" -gt 30 ]; then + printf "󰁼󱐋" + elif [ "$capacity" -gt 20 ]; then + printf "󰁻󱐋" + else + printf "󰂎󱐋" + fi + ;; + Unknown) + printf "󰂑" + ;; +esac + +printf "$capacity%%" diff --git a/scripts/cpu.sh b/scripts/cpu.sh new file mode 100755 index 0000000..1884c53 --- /dev/null +++ b/scripts/cpu.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +temp_avg="$(sensors | grep 'Package id 0' | awk '{print $4}' | cut -b2-)" +load_avg="$(cut -d' ' -f1 /proc/loadavg)" +freq_avg="$(cat /proc/cpuinfo | grep 'cpu MHz' | awk '{ total += $4; count++ } END { print total/count }')" +freq_avg="$(printf %0.f $freq_avg)" + +if [ $freq_avg -gt 2000 ]; then + printf "󰓅" +elif [ $freq_avg -gt 1000 ]; then + printf "󰾅" +else + printf "󰾆" +fi + +printf " %s %s@%sMHz" $temp_avg $load_avg $freq_avg diff --git a/scripts/memory.sh b/scripts/memory.sh new file mode 100755 index 0000000..492bff8 --- /dev/null +++ b/scripts/memory.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +printf " " +printf "$(free -h | awk '/Mem/{print $3}')"