/usr/lib/byobu/include/mondrian is in byobu 5.16-1.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 | #!/bin/bash
# N.B.: Use bash for $RANDOM
#
# mondrian: randomly generate some Modrian art in tmux
#
# Copyright (C) 2011 Dustin Kirkland
#
# Authors: Dustin Kirkland <dustin.kirkland@gmail.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/>.
trap "tput reset" EXIT HUP INT QUIT TERM KILL ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM
# Special mode, argv[1]="color", paint the screen
if [ "$1" = "color" ] && [ -n "$2" ]; then
i=0
out=
count=$(stty size | awk '{print $1*$2}')
perl -e "print color 'reset'; printf \"\x1b[48;5;${2}m%${count}s\", \" \";";
head -n1
exit 0
fi
get_random_pane() {
local panes=$(tmux list-panes | wc -l)
r=$((RANDOM % 4))
while [ $r = "$LAST_PANE" ]; do
r=$((RANDOM % 4))
done
LAST_PANE="$r"
printf "%s\n" "$r"
}
get_random_numbers() {
local max="$1" R=0 B=0 Y=0
R=$((RANDOM % max + 1))
B=$((RANDOM % max + 1))
Y=$((RANDOM % max + 1))
while [ "$B" = "$R" ] || [ "$B" = "$Y" ]; do
B=$((RANDOM % max + 1))
done
while [ "$Y" = "$R" ] || [ "$Y" = "$B" ]; do
Y=$((RANDOM % max + 1))
done
_RET="$R $B $Y"
}
red_color=196
yellow_color=226
blue_color=57
white_color=231
# Get number of splits
if [ -n "$1" ]; then
# Passed in as arg1
TOTAL_SPLITS=$1
else
# Choose random number of splits between 10 and 40
TOTAL_SPLITS=$((RANDOM % 30 + 10))
fi
# Choose 1 red, 1 yellow, 1 blue
get_random_numbers "$TOTAL_SPLITS"
nums="$_RET"
red=$((RANDOM % TOTAL_SPLITS + 4))
while [ $red -ge $TOTAL_SPLITS ]; do
red=$((RANDOM % TOTAL_SPLITS + 4))
done
yellow=$((RANDOM % TOTAL_SPLITS + 4))
while [ "$yellow" = "$red" ] || [ $yellow -ge $TOTAL_SPLITS ]; do
yellow=$((RANDOM % TOTAL_SPLITS + 4))
done
blue=$((RANDOM % TOTAL_SPLITS + 4))
while [ "$blue" = "$yellow" ] || [ "$blue" = "$red" ] || [ $blue -ge $TOTAL_SPLITS ]; do
blue=$((RANDOM % TOTAL_SPLITS + 4))
done
# Create the window, set the border colors
for i in $(tmux list-windows | grep " mondrian " | awk -F: '{print $1}'); do
tmux kill-window -t $i
done
tmux new-window -n mondrian "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color"
tmux set-option -g pane-active-border-bg black
tmux set-option -g pane-active-border-fg black
tmux set-option -g pane-border-bg black
tmux set-option -g pane-border-fg black
# Create and paint the splits
for i in $(seq 0 $((TOTAL_SPLITS-1))); do
case $i in
$red) color=$red_color ;;
$yellow) color=$yellow_color ;;
$blue) color=$blue_color ;;
*) color=$white_color ;;
esac
CMD="$BYOBU_PREFIX/lib/byobu/include/mondrian color $color"
[ "$((RANDOM % 2))" = "0" ] && SPLIT="-v" || SPLIT="-h"
if ! tmux split-window $SPLIT -t $(get_random_pane) "$CMD" ; then
case "$i" in
$red) red=$((red+1)) ;;
$yellow) yellow=$((yellow+1)) ;;
$blue) blue=$((blue+1)) ;;
esac
fi
done
exit 0
|