* usr/bin/byobu-select-profile, usr/share/byobu/keybindings/f-

keys.tmux, usr/share/byobu/keybindings/f-keys.tmux.disable,
  usr/share/doc/byobu/help.tmux.txt: LP: #817686
  - add a couple of (tmux-only) modes to byobu-select-profile, which can
    automatically change the background color of the status bar, based
    on the systems hostname, ip address, or just at random
  - map this to Ctrl-F8
This commit is contained in:
Dustin Kirkland 2011-11-14 17:31:32 -06:00
commit f50e5bb5bf
5 changed files with 53 additions and 1 deletions

7
debian/changelog vendored
View file

@ -22,6 +22,13 @@ byobu (4.48) unreleased; urgency=low
* usr/share/byobu/status/statusrc:
- fix reference to non-existent variable, MONITORED_INTERFACE; should be
MONITORED_NETWORK
* usr/bin/byobu-select-profile, usr/share/byobu/keybindings/f-
keys.tmux, usr/share/byobu/keybindings/f-keys.tmux.disable,
usr/share/doc/byobu/help.tmux.txt: LP: #817686
- add a couple of (tmux-only) modes to byobu-select-profile, which can
automatically change the background color of the status bar, based
on the systems hostname, ip address, or just at random
- map this to Ctrl-F8
-- Dustin Kirkland <kirkland@ubuntu.com> Wed, 09 Nov 2011 17:54:11 -0600

View file

@ -167,6 +167,28 @@ setcolor() {
touch "$BYOBU_RUN_DIR/reload-required"
}
get_contrast() {
# See section 2.2: http://www.w3.org/TR/AERT
local hex="$(echo "$1" | sed "s/\(..\)\(..\)\(..\)/\1 \2 \3/")"
local bright=$(echo $hex | awk --non-decimal-data '{printf "%0.0f",(("0x"$1)*299+("0x"$2)*587+("0x"$3)*114)/1000}')
if [ $bright -ge 130 ]; then
_RET="black"
else
_RET="white"
fi
}
setcolor_tmux() {
dark="$1"
get_contrast "$dark"
light="$_RET"
accent="magenta"
highlight="red"
monochrome="0"
printf "BYOBU_DARK=\"#$dark\"\nBYOBU_LIGHT=$light\nBYOBU_ACCENT=$accent\nBYOBU_HIGHLIGHT=$highlight\nMONOCHROME=$MONOCHROME" > "$FILE".tmux
tmux source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc"
}
if [ $# -eq 0 ]; then
prompt "background"
prompt "foreground"
@ -187,6 +209,26 @@ else
shift
break
;;
-h|--hostname)
color=$(hostname | md5sum | head -c 6)
setcolor_tmux "$color"
shift
break
;;
-i|--ip)
[ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc"
. $BYOBU_PREFIX/lib/$PKG/ip_address
color=$(__ip_address t| md5sum | head -c 6)
setcolor_tmux "$color"
shift
break
;;
-r|--random)
color=$(head -c 10 /dev/urandom | md5sum | head -c 6)
setcolor_tmux "$color"
shift
break
;;
*)
usage
exit 1

View file

@ -59,6 +59,7 @@ bind-key -n F7 copy-mode
bind-key -n M-NPage copy-mode \; send-keys NPage
bind-key -n M-PPage copy-mode \; send-keys PPage
bind-key -n F8 command-prompt -p "(rename-window)" "rename-window %%"
bind-key -n C-F8 new-window -d "byobu-select-profile -r"
bind-key -n F9 new-window -k -n config byobu-config
bind-key -n M-F11 break-pane
bind-key -n C-F11 join-pane -h -s :. -t :-1

View file

@ -55,6 +55,7 @@ unbind-key -n F7
unbind-key -n M-NPage
unbind-key -n M-PPage
unbind-key -n F8
unbind-key -n C-F8
unbind-key -n F9
unbind-key -n M-F11
unbind-key -n C-F11

View file

@ -24,7 +24,8 @@ and some convenient keybindings:
Ctrl-F6 Kill split in focus
F7 Enter scrollback history
Alt-PageUp/PageDown Enter and move through scrollback
F8 Rename the current window
F8 Change the current window's name
Ctrl-F8 Change status bar's color randomly
F9 Launch byobu-config window
F10 * Used by X11 *
F11 * Used by X11 *