Tmux : Add separate modules.

This commit is contained in:
Dmitry Voronin 2024-04-02 06:50:22 +03:00
parent cee243f86f
commit 3d431d739d
4 changed files with 49 additions and 3 deletions

View file

@ -37,5 +37,5 @@
];
# Special packages.
programs.adb.enable = true;
programs.adb.enable = true;
}

View file

@ -1,6 +1,9 @@
{ pkgs, ... }: {
{ pkgs, ... }: let
tmux_script = pkgs.writeShellScriptBin "tmux_script" (builtins.readFile ./tmux/tmux_script.sh);
in {
programs.tmux = {
enable = true;
extraConfig = builtins.readFile ./tmux/tmux.conf;
};
environment.systemPackages = [ tmux_script ];
}

View file

@ -71,7 +71,7 @@ set -g status-style "bg=#3c3836 fg=#a89984"
set -g status-left "#[bold,bg=#a89984,fg=#282828] #H-#S #(count=$(tmux list-clients -t #S | wc -l); [ ${count} -gt 1 ] && echo (${count}) )#[bg=#3c3836,fg=#a89984]"
set -g status-left-length 50
set -g status-right-length 50
set -g status-right " #(head -c -1 /sys/class/power_supply/BAT*/capacity 2> /dev/null && echo -n '% ') %Y-%m-%d #[fg=#a89984]#[bold,bg=#a89984,fg=#282828] %H:%M "
set -g status-right " #(tmux_script battery) %Y-%m-%d #[fg=#a89984]#[bold,bg=#a89984,fg=#282828] %H:%M "
set-window-option -g window-status-separator ""

View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
action="${1}"
function _tmux_battery() {
local IFS=$'\n'
local batteries=($(ls /sys/class/power_supply/ | grep ^BAT[0-9]$))
[[ "${batteries}" = "" ]] && return 1
local battery="/sys/class/power_supply/${batteries[0]}"
local level=$(cat ${battery}/capacity)
local status=$(cat ${battery}/status)
local is_charging=false
[[ "${status}" = "Charging" ]] && is_charging=true
local icon
if ((level>=60))
then
icon="󱊣"
elif ((level>=40))
then
icon="󱊢"
elif ((level>=20))
then
icon="󱊡"
else
icon="󰂎"
fi
echo -n " ${level} ${icon}"
${is_charging} && echo -n "󱐋"
echo -n " "
}
case ${action} in
"battery")
_tmux_battery
;;
"*")
;;
esac