Tmux : Remove script preping for swaybar.
This commit is contained in:
parent
b286793e0b
commit
185989ee7b
|
@ -1,10 +1,9 @@
|
|||
{ pkgs, inputs, const, style, util, key, setting, secret, ... } @args: let
|
||||
homePath = "/data/data/com.termux.nix/files/home";
|
||||
tmux = import ./common/tmux args;
|
||||
tmuxScript = pkgs.writeShellScriptBin "tmux_script" tmux.script;
|
||||
bash = import ./common/bash args;
|
||||
nvim = import ./common/nvim args;
|
||||
ssh = import ./common/ssh args;
|
||||
homePath = "/data/data/com.termux.nix/files/home";
|
||||
tmux = import ./common/tmux args;
|
||||
bash = import ./common/bash args;
|
||||
nvim = import ./common/nvim args;
|
||||
ssh = import ./common/ssh args;
|
||||
font = pkgs.runCommandNoCC "font" {} ''
|
||||
cp ${pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out
|
||||
'';
|
||||
|
@ -111,7 +110,7 @@ in {
|
|||
ripgrep
|
||||
rsync
|
||||
sqlite
|
||||
pkgs.tmux tmuxScript
|
||||
pkgs.tmux
|
||||
tree
|
||||
utillinux
|
||||
wget
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{ pkgs, style, key, util, ... } @args: let
|
||||
tmux = import ./tmux args;
|
||||
script = pkgs.writeShellScriptBin "tmux_script" tmux.script;
|
||||
tmux = import ./tmux args;
|
||||
in {
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
extraConfig = tmux.config;
|
||||
};
|
||||
environment.systemPackages = [ script ];
|
||||
}
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
{ setting, util, ... }: {
|
||||
text = util.trimTabs ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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>=${toString(setting.tmux.status.battery.threshold.high)}))
|
||||
then
|
||||
icon=""
|
||||
elif ((level>=${toString(setting.tmux.status.battery.threshold.medium)}))
|
||||
then
|
||||
icon=""
|
||||
elif ((level>=${toString(setting.tmux.status.battery.threshold.low)}))
|
||||
then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
echo -n "''${icon}"
|
||||
''${is_charging} && echo -n ""
|
||||
echo
|
||||
echo -n "''${level}"
|
||||
}
|
||||
|
||||
function _tmux_volume() {
|
||||
local IFS=$'\n'
|
||||
local level=$(wpctl get-volume @DEFAULT_SINK@ | cut -d\ -f2 | sed -e "s/^0//" -e "s/\.//")
|
||||
[[ "''${level}" = "" ]] && return 1
|
||||
[[ "''${level}" = "00" ]] && level="0"
|
||||
|
||||
local icon
|
||||
if ((level>=${toString(setting.tmux.status.volume.threshold.high)}))
|
||||
then
|
||||
icon=""
|
||||
elif ((level>=${toString(setting.tmux.status.volume.threshold.medium)}))
|
||||
then
|
||||
icon=""
|
||||
elif ((level>=${toString(setting.tmux.status.volume.threshold.low)}))
|
||||
then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
local muted=$(wpctl get-volume @DEFAULT_SINK@ | grep '[MUTED]')
|
||||
if [[ "''${muted}" != "" ]]; then
|
||||
icon=""
|
||||
fi
|
||||
|
||||
echo "''${icon}"
|
||||
echo -n "''${level}"
|
||||
}
|
||||
|
||||
function _tmux_statusbar() {
|
||||
local IFS=$'\n'
|
||||
local sep=""
|
||||
local thr_volume=${toString(setting.tmux.status.volume.threshold.show)}
|
||||
local thr_battery=${toString(setting.tmux.status.battery.threshold.show)}
|
||||
local is_uber=$(cat "/tmp/.tmux_uber" || echo -n false)
|
||||
|
||||
# Get data.
|
||||
battery=($(_tmux_battery))
|
||||
volume=($(_tmux_volume))
|
||||
|
||||
# Prepare separators.
|
||||
sep_batvol=" "
|
||||
|
||||
if ''${is_uber} || [[ "''${battery[1]}" -lt "''${thr_battery}" ]] || [[ "''${volume[1]}" -gt "''${thr_volume}" ]]; then
|
||||
sep_batvol=" ''${sep} "
|
||||
fi
|
||||
if [[ "''${battery[0]}" = "" ]]; then
|
||||
sep_batvol=""
|
||||
fi
|
||||
|
||||
# Print.
|
||||
echo -n " "
|
||||
|
||||
# Assemble.
|
||||
if ''${is_uber}; then
|
||||
local lang=($(_tmux_language))
|
||||
[[ "''${lang[0]}" != "" ]] && {
|
||||
echo -n "''${lang[0]} ''${sep} "
|
||||
};
|
||||
|
||||
[[ "''${volume[0]}" != "" ]] && echo -n "''${volume[0]} ''${volume[1]}%''${sep_batvol}"
|
||||
[[ "''${battery[0]}" != "" ]] && echo -n "''${battery[0]} ''${battery[1]}%"
|
||||
else
|
||||
[[ "''${volume[0]}" != "" ]] && {
|
||||
echo -n "''${volume[0]}"
|
||||
[[ "''${volume[1]}" -gt 100 ]] && echo -n " ''${volume[1]}%"
|
||||
echo -n "''${sep_batvol}"
|
||||
};
|
||||
[[ "''${battery[0]}" != "" ]] && {
|
||||
echo -n "''${battery[0]}"
|
||||
[[ "''${battery[1]}" -lt 40 ]] && echo -n " ''${battery[1]}%"
|
||||
};
|
||||
fi
|
||||
|
||||
echo -n " "
|
||||
}
|
||||
|
||||
function _tmux_language() {
|
||||
local IFS=$'\n'
|
||||
local lang=$(swaymsg -t get_inputs | jq 'map(select(has("xkb_active_layout_name")))[0].xkb_active_layout_name')
|
||||
|
||||
echo -n ''${lang:1:2}
|
||||
}
|
||||
|
||||
function _tmux_client_count() {
|
||||
local IFS=$'\n'
|
||||
local session=''${1}
|
||||
local count=$(tmux list-clients -t ''${session} | wc -l)
|
||||
|
||||
[ ''${count} -gt 1 ] && echo -n "+''${count} "
|
||||
}
|
||||
|
||||
function _tmux_toggle_statusbar() {
|
||||
local file="/tmp/.tmux_uber"
|
||||
if [[ ! -f ''${file} ]]; then
|
||||
echo "true" > ''${file}
|
||||
elif $(cat ''${file}); then
|
||||
echo "false" > ''${file}
|
||||
else
|
||||
echo "true" > ''${file}
|
||||
fi
|
||||
}
|
||||
|
||||
IFS=$'\n'
|
||||
action=''${1}
|
||||
session=''${2}
|
||||
|
||||
case "''${action}" in
|
||||
"statusbar") _tmux_statusbar ;;
|
||||
"client_count") _tmux_client_count ''${session} ;;
|
||||
"togglestatusbar") _tmux_toggle_statusbar ;;
|
||||
esac
|
||||
'';
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
{ style, key, util, setting, ... } @args: {
|
||||
config = util.catAllText ./module args;
|
||||
script = (import ./Script.nix args).text;
|
||||
}
|
||||
|
|
|
@ -7,16 +7,15 @@
|
|||
in {
|
||||
text = ''
|
||||
bind-key -n ${mod}-${key.tmux.status.toggle} set-option -g status;
|
||||
bind-key -n ${mod}-${key.tmux.status.uber} run-shell 'tmux_script togglestatusbar'
|
||||
set -g status-interval ${toString(setting.tmux.status.interval)}
|
||||
set -g status-position bottom
|
||||
set -g status-justify left
|
||||
set -g status-style "fg=#${fg}"
|
||||
|
||||
set -g status-left "#[bold] #H-#S #(tmux_script client_count #S)"
|
||||
set -g status-left "#[bold] #H-#S "
|
||||
set -g status-left-length ${toString(setting.tmux.status.length)}
|
||||
set -g status-right-length ${toString(setting.tmux.status.length)}
|
||||
set -g status-right "#(tmux_script statusbar) %d %a #[bold] %H:%M "
|
||||
set -g status-right " %d %a #[bold] %H:%M "
|
||||
|
||||
set-window-option -g window-status-separator ""
|
||||
|
||||
|
|
|
@ -93,8 +93,7 @@
|
|||
prev = "9";
|
||||
};
|
||||
status = {
|
||||
toggle = "F";
|
||||
uber = "f";
|
||||
toggle = "f";
|
||||
};
|
||||
window = {
|
||||
new = "Escape";
|
||||
|
|
Loading…
Reference in a new issue