From e978fb30b6dfcdd709f13771e52d8fc65b95019d Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 10 Jul 2011 19:15:43 +0100 Subject: [PATCH] * usr/lib/byobu/battery, usr/lib/byobu/color, usr/lib/byobu/date, usr/lib/byobu/.shutil, usr/lib/byobu/time, usr/share/byobu/profiles/Makefile.am, usr/share/byobu/profiles/tmux: - create tmux color mappings and functions - get date/time working in tmux (need to figure out how to get tmux to interpret the time format sequence) - install the tmux profile - get the tmux profile using the new status print methodology --- debian/changelog | 8 ++++ usr/lib/byobu/.shutil | 61 ++++++++++++++++++++++++++-- usr/lib/byobu/battery | 12 +++--- usr/lib/byobu/color | 13 ++++-- usr/lib/byobu/date | 13 ++++-- usr/lib/byobu/time | 9 +++- usr/share/byobu/profiles/Makefile.am | 2 +- usr/share/byobu/profiles/tmux | 14 +++++-- 8 files changed, 111 insertions(+), 21 deletions(-) diff --git a/debian/changelog b/debian/changelog index 49e17ef7..7650b8bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -61,6 +61,14 @@ byobu (4.18) unreleased; urgency=low - significantly reduce the number of mkdir -p commands * usr/bin/byobu-status-print: - save a few forks + * usr/lib/byobu/battery, usr/lib/byobu/color, usr/lib/byobu/date, + usr/lib/byobu/.shutil, usr/lib/byobu/time, + usr/share/byobu/profiles/Makefile.am, usr/share/byobu/profiles/tmux: + - create tmux color mappings and functions + - get date/time working in tmux (need to figure out how to get + tmux to interpret the time format sequence) + - install the tmux profile + - get the tmux profile using the new status print methodology [ James Spencer ] * usr/lib/byobu/.constants: diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index a82b010f..e0db59f2 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -41,8 +41,63 @@ color_screen() { esac } +color_map() { + case "$1" in + k) _RET=black ;; + r) _RET=red ;; + g) _RET=green ;; + y) _RET=yellow ;; + b) _RET=blue ;; + m) _RET=magenta ;; + c) _RET=cyan ;; + w) _RET=white ;; + d) _RET=color0 ;; + K) _RET=black,bold ;; + R) _RET=red,bold ;; + G) _RET=green,bold ;; + Y) _RET=yellow,bold ;; + B) _RET=blue,bold ;; + M) _RET=magenta,bold ;; + C) _RET=cyan,bold ;; + W) _RET=white,bold ;; + *) _RET= ;; + esac +} + +attr_map() { + case "$1" in + d) _RET=,dim ;; + u) _RET=,underline ;; + b) _RET=,bold ;; + r) _RET=,reverse ;; + s) _RET=,standout ;; + B) _RET=,blinking ;; + *) _RET= ;; + esac +} + color_tmux() { - true + ESC="\005" + case "$1" in + "") return 0 ;; + -) printf "#[default]" ;; + --) printf "#[default] " ;; + esc) printf "" ;; + bold*) printf "#[fg=bold]" ;; + none) printf "#[default]" ;; + invert) printf "#[reverse]" ;; + *) + if [ "$#" = "2" ]; then + color_map "$1"; back="$_RET" + color_map "$2"; fore="$_RET" + else + attr_map "$1"; attr="$_RET" + color_map "$2"; back="$_RET" + color_map "$3"; fore="$_RET" + fi + [ "$MONOCHROME" = "1" ] && printf "#[default]" || printf "#[fg=$fore$attr,bg=$back]" + ;; + esac } color() { @@ -167,7 +222,7 @@ status_freq() { cpu_freq) _RET=2 ;; cpu_temp) _RET=19 ;; custom) _RET=5 ;; - date) _RET=28793 ;; + date) [ "$BYOBU_BACKEND" = "tmux" ] && _RET=1 || _RET=28793 ;; disk) _RET=13 ;; disk_io) _RET=3 ;; ec2_cost) _RET=601 ;; @@ -189,7 +244,7 @@ status_freq() { release) _RET=599 ;; services) _RET=53 ;; swap) _RET=19 ;; - time) _RET=9999999 ;; + time) [ "$BYOBU_BACKEND" = "tmux" ] && _RET=1 || _RET=9999999 ;; time_binary) _RET=23 ;; time_utc) _RET=11 ;; trash) _RET=9999999 ;; diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index e266446e..f475c3eb 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -54,14 +54,14 @@ __battery() { done < "$bat/state" percent=$(((100*$rem)/$full)) if [ "$percent" -lt 33 ]; then - color="R k" - bcolor="b R k" + color="R w" + bcolor="b R w" elif [ "$percent" -lt 67 ]; then - color="Y k" - bcolor="b Y k" + color="Y w" + bcolor="b Y w" else - color="G k" - bcolor="b G k" + color="G w" + bcolor="b G w" fi percent="$percent%" case $state in diff --git a/usr/lib/byobu/color b/usr/lib/byobu/color index 64b2720c..6325739d 100755 --- a/usr/lib/byobu/color +++ b/usr/lib/byobu/color @@ -23,9 +23,16 @@ __color_detail() { } __color() { - [ -z "$FOREGROUND" ] && FOREGROUND="w" - [ -z "$BACKGROUND" ] && BACKGROUND="k" - printf "\005{= $BACKGROUND$FOREGROUND}" + case "$BYOBU_BACKEND" in + tmux) + true + ;; + *) + [ -z "$FOREGROUND" ] && FOREGROUND="w" + [ -z "$BACKGROUND" ] && BACKGROUND="k" + printf "\005{= $BACKGROUND$FOREGROUND}" + ;; + esac } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/date b/usr/lib/byobu/date index 75125db1..0f26d5b8 100755 --- a/usr/lib/byobu/date +++ b/usr/lib/byobu/date @@ -24,9 +24,16 @@ __date_detail() { } __date() { - bd=$(date "+%m%d") - [ "$bd" = "0320" ] && msg="$(echo SGFwcHkgQmlydGhkYXkgU2NyZWVuIC0tIGh0dHA6Ly9iaXQubHkvc2NyZWVuLWJkYXkK | base64 -di)" && $BYOBU_BACKEND -X -S "byobu" at "*" echo "[$msg]" - color none; printf "\005Y-\005m-\005d"; color -- + case "$BYOBU_BACKEND" in + tmux) + date +"%Y-%m-%d" + ;; + *) + bd=$(date "+%m%d") + [ "$bd" = "0320" ] && msg="$(echo SGFwcHkgQmlydGhkYXkgU2NyZWVuIC0tIGh0dHA6Ly9iaXQubHkvc2NyZWVuLWJkYXkK | base64 -di)" && $BYOBU_BACKEND -X -S "byobu" at "*" echo "[$msg]" + color none; printf "\005Y-\005m-\005d"; color -- + ;; + esac } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/time b/usr/lib/byobu/time index 99d5d074..46dfba64 100755 --- a/usr/lib/byobu/time +++ b/usr/lib/byobu/time @@ -24,7 +24,14 @@ __time_detail() { } __time() { - printf "\0050c:\005s" + case "$BYOBU_BACKEND" in + tmux) + date +"%H:%M:%S" + ;; + *) + printf "\0050c:\005s" + ;; + esac } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/share/byobu/profiles/Makefile.am b/usr/share/byobu/profiles/Makefile.am index dc1b9816..dc27453c 100644 --- a/usr/share/byobu/profiles/Makefile.am +++ b/usr/share/byobu/profiles/Makefile.am @@ -1,2 +1,2 @@ profilesdir = $(datadir)/@PACKAGE@/profiles -profiles_DATA = byoburc screenrc common NONE +profiles_DATA = byoburc screenrc common tmux NONE diff --git a/usr/share/byobu/profiles/tmux b/usr/share/byobu/profiles/tmux index 67549327..313293dd 100644 --- a/usr/share/byobu/profiles/tmux +++ b/usr/share/byobu/profiles/tmux @@ -47,9 +47,11 @@ bind-key -n S-F4 select-pane -R bind-key -n C-F6 kill-pane set-option -g set-titles on -set-option -g set-titles-string '#(whoami)@#H - #S' +set-option -g set-titles-string '#(whoami)@#H - byobu (#S)' -set-window-option -g window-status-current-bg red +set-window-option -g window-status-attr bold +set-window-option -g window-status-current-bg white +set-window-option -g window-status-current-fg black set-window-option -g automatic-rename on set-window-option -g aggressive-resize on #set-window-option -g xterm-keys on @@ -61,5 +63,9 @@ set -g default-command /bin/bash set -g status-bg black set -g status-fg white set -g status-interval 1 -set -g status-left '#[fg=white,bold,bg=magenta] U ' -set -g status-right '%Y-%m-%d %H:%M:%S' +set -g status-left-length 256 +set -g status-right-length 256 +set -g status-left '#(byobu-status-print 3)[' +set -g status-right ']#(byobu-status-print 4)' +set -g message-bg magenta +set -g message-fg white