Tmux : Add statusbar uber-mode.
This commit is contained in:
parent
e71875c927
commit
2c7f09dfe4
|
@ -28,7 +28,7 @@ function _tmux_battery() {
|
||||||
|
|
||||||
echo -n "${icon}"
|
echo -n "${icon}"
|
||||||
${is_charging} && echo -n ""
|
${is_charging} && echo -n ""
|
||||||
[[ "${level}" -lt 40 ]] && echo -n "\n${level}%"
|
echo -n "\n${level}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _tmux_volume() {
|
function _tmux_volume() {
|
||||||
|
@ -56,12 +56,12 @@ function _tmux_volume() {
|
||||||
icon=""
|
icon=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "${icon}"
|
echo "${icon}"
|
||||||
[[ "${level}" -gt 100 ]] && echo -n "\n${level}%"
|
echo -n "${level}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _tmux_statusbar() {
|
function _tmux_statusbar() {
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
|
|
||||||
# Get data.
|
# Get data.
|
||||||
battery=($(_tmux_battery))
|
battery=($(_tmux_battery))
|
||||||
|
@ -80,8 +80,21 @@ function _tmux_statusbar() {
|
||||||
# Print.
|
# Print.
|
||||||
echo -n " "
|
echo -n " "
|
||||||
|
|
||||||
[[ "${volume[0]}" != "" ]] && echo -n "${volume[0]}${sep_batvol}"
|
# Assemble.
|
||||||
[[ "${battery[0]}" != "" ]] && echo -n "${battery[0]}"
|
if $(cat "/tmp/.tmux_uber" || echo false); then
|
||||||
|
[[ "${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}" -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 " "
|
echo -n " "
|
||||||
}
|
}
|
||||||
|
@ -94,6 +107,17 @@ function _tmux_client_count() {
|
||||||
[ ${count} -gt 1 ] && echo -n "(${count}) "
|
[ ${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'
|
IFS=$'\n'
|
||||||
action=${1}
|
action=${1}
|
||||||
session=${2}
|
session=${2}
|
||||||
|
@ -101,4 +125,5 @@ session=${2}
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
"statusbar") _tmux_statusbar ;;
|
"statusbar") _tmux_statusbar ;;
|
||||||
"client_count") _tmux_client_count ${session} ;;
|
"client_count") _tmux_client_count ${session} ;;
|
||||||
|
"togglestatusbar") _tmux_toggle_statusbar ;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -63,6 +63,8 @@ bind -n M-g choose-session
|
||||||
set -g window-size smallest
|
set -g window-size smallest
|
||||||
|
|
||||||
# Statusbar.
|
# Statusbar.
|
||||||
|
bind-key -n M-F set-option -g status;
|
||||||
|
bind-key -n M-f run-shell 'tmux_script togglestatusbar'
|
||||||
set -g status-interval 2
|
set -g status-interval 2
|
||||||
set -g status-position bottom
|
set -g status-position bottom
|
||||||
set -g status-justify left
|
set -g status-justify left
|
||||||
|
|
Loading…
Reference in a new issue