This file is indexed.

/usr/bin/byobu-select-profile is in byobu 5.112-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/sh -e
#
#    byobu-select-profile
#    Copyright (C) 2008 Canonical Ltd.
#
#    Authors: Dustin Kirkland <kirkland@byobu.org>
#             Nick Barcet <nick.barcet@ubuntu.com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, version 3 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.


# If you change any strings, please generate localization information with:
#	./debian/rules get-po

PKG="byobu"
[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc"
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
. "${BYOBU_PREFIX}/lib/${PKG}/include/common"

TEXTDOMAIN="$PKG"

COLORS="default_light \
	default_dark \
	white \
	black \
	grey \
	dark_grey \
	light_grey \
	blue \
	light_blue \
	cyan \
	light_cyan \
	green \
	light_green \
	purple \
	light_purple \
	red \
	light_red \
	yellow \
	brown"

# Find a hash utility
for i in md5sum md5 sha512sum sha256sum sha1sum shasum shasum5.12 shasum5.10; do
	if eval $BYOBU_TEST $i >/dev/null 2>&1; then
		HASH="$i"
		break
	fi
done

usage () {
    cat <<EOT
Usage: $0 [(-l|--list)][(-h|--help)]
    -l,--list           list available profiles
    -b,--background	set the background color
    -f,--foreground     set the foreground color
    -h,--help           this help

    Without any parameters, runs interactively.
EOT
}

# Initialize variables
FILE="$BYOBU_CONFIG_DIR/color"
PROFILE="$BYOBU_CONFIG_DIR/profile"
[ -r "$PROFILE" ] || ln -sf $BYOBU_PREFIX/share/$PKG/profiles/common "$PROFILE"
selected=-1
color=

listprofiles() {
	# Display list of profiles, one per line
	for x in $COLORS; do
		echo "$x"
	done
}

prompt() {
	which="$1"
	count=1
	selected=-1
	while /bin/true; do
		if [ $count -gt 5 ]; then
			echo `gettext "ERROR: Invalid selection"`
			exit 1
		fi
		count=$(expr $count + 1)
		echo
		if [ "$which" = "foreground" ]; then
			echo `gettext 'Select the foreground color: '`
			simple="white"
		else
			echo `gettext 'Select the background color: '`
			simple="black"
		fi
		i=1
		for x in $COLORS; do
			test $i -lt 10 2>/dev/null && printf "  " || printf " "
			echo "$i. $x"
			i=$(expr $i + 1)
			[ "$simple" = "$x" ] && simple=$i
		done
		echo
		if [ -z "$selected" -a -n "$simple" ]; then
			selected="$simple"
		elif ! test $selected -gt 0 2>/dev/null; then
			printf "`gettext 'Choose'` 1-$i [$simple]: "
			selected=`head -n1`
		elif ! test $selected -le $i 2>/dev/null; then
			printf "`gettext 'Choose'` 1-$i [$simple]: "
			selected=`head -n1`
		else
			i=1
			for color in $COLORS; do
				[ "$i" = "$selected" ] && break
				i=$(expr $i + 1)
			done
			echo `gettext "Selected"` "$which [$color]"
			case "$BYOBU_BACKEND" in
				screen)
					setcolor_screen "$which" "$color"
				;;
				tmux|*)
					setcolor_tmux "$color"
				;;
			esac
			return 0
		fi
	done
}

getletter() {
	count=$(echo "$1" | wc -c)
	if [ "$count" = "2" ]; then
		echo "$1"
		return
	fi
	color="$1"
	case $color in
		default_light) letter="d";;
		default_dark)  letter="D";;
		black)         letter="k";;
		dark_grey)     letter="K";;
		blue)          letter="b";;
		light_blue)    letter="B";;
		cyan)          letter="c";;
		light_cyan)    letter="C";;
		green)         letter="g";;
		light_green)   letter="G";;
		purple)        letter="m";;
		light_purple)  letter="M";;
		red)           letter="r";;
		light_red)     letter="R";;
		grey)          letter="w";;
		light_grey)    letter="W";;
		white)         letter="w";;
		yellow)        letter="Y";;
		brown)         letter="y";;
		*)             letter="d";;
	esac
	echo "$letter"
}

setcolor_screen() {
	which="$1"
	color="$2"
	[ -r $FILE ] && . $FILE
	if [ "$which" = "foreground" ]; then
		FOREGROUND=$(getletter "$color")
	else
		BACKGROUND=$(getletter "$color")
	fi
	[ "$MONOCHROME" = "1" ] || MONOCHROME=0
	printf "FOREGROUND=$FOREGROUND\nBACKGROUND=$BACKGROUND\nMONOCHROME=$MONOCHROME" > $FILE
	touch "$BYOBU_RUN_DIR/reload-required"
	$BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile"
}

get_contrast() {
	# See section 2.2: http://www.w3.org/TR/AERT#color-contrast
	local awk="awk"
	if eval $BYOBU_TEST gawk >/dev/null 2>&1; then
		awk="gawk"
	fi
	local hex="$(echo "$1" | sed -e "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() {
	if [ "$BYOBU_BACKEND" != "tmux" ]; then
		echo "WARNING: This functionality is only supported in Byobu with the tmux backend" 1>&2
	fi
	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"
	case "$BYOBU_BACKEND" in
		screen)
			prompt "foreground"
		;;
	esac
else
	while true; do
		case "$1" in
			-b|--background)
				setcolor_screen "background" "$2"
				shift 2
			;;
			-f|--foreground)
				setcolor_screen "foreground" "$2"
				shift 2
			;;
			-l|--list)
				listprofiles
				shift
				break
			;;
			-h|--hostname)
				color=$(hostname | $HASH | 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| $HASH | head -c 6)
				setcolor_tmux "$color"
				shift
				break
			;;
			-r|--random)
				color=$(head -c 10 /dev/urandom | $HASH | head -c 6)
				setcolor_tmux "\#$color"
				shift
				break
			;;
			*)
				usage
				exit 1
			;;
			--)
				shift
				break
			;;
		esac
		[ $# -eq 0 ] && break
	done
fi

exit 0

# vi: syntax=sh ts=4 noexpandtab