Tmux : Add separate modules.
This commit is contained in:
parent
cee243f86f
commit
3d431d739d
|
@ -1,6 +1,9 @@
|
||||||
{ pkgs, ... }: {
|
{ pkgs, ... }: let
|
||||||
|
tmux_script = pkgs.writeShellScriptBin "tmux_script" (builtins.readFile ./tmux/tmux_script.sh);
|
||||||
|
in {
|
||||||
programs.tmux = {
|
programs.tmux = {
|
||||||
enable = true;
|
enable = true;
|
||||||
extraConfig = builtins.readFile ./tmux/tmux.conf;
|
extraConfig = builtins.readFile ./tmux/tmux.conf;
|
||||||
};
|
};
|
||||||
|
environment.systemPackages = [ tmux_script ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 "#[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-left-length 50
|
||||||
set -g status-right-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 ""
|
set-window-option -g window-status-separator ""
|
||||||
|
|
||||||
|
|
43
module/common/tmux/tmux_script.sh
Executable file
43
module/common/tmux/tmux_script.sh
Executable 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
|
Loading…
Reference in a new issue