* usr/bin/byobu-modrian:

- add a new, fun script
This commit is contained in:
Dustin Kirkland 2011-11-16 14:33:05 -06:00
commit 6d3b563936
2 changed files with 71 additions and 1 deletions

3
debian/changelog vendored
View file

@ -1,6 +1,7 @@
byobu (4.49) unreleased; urgency=low
* UNRELEASED
* usr/bin/byobu-modrian:
- add a new, fun script
-- Dustin Kirkland <kirkland@ubuntu.com> Mon, 14 Nov 2011 17:43:02 -0600

69
usr/bin/byobu-modrian Executable file
View file

@ -0,0 +1,69 @@
#!/bin/bash
#
# byobu-modrian: 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/>.
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"
echo "$r"
}
red_color=196
yellow_color=226
blue_color=57
white_color=231
# Get number of splits
[ -n "$1" ] && TOTAL_SPLITS=$1 || TOTAL_SPLITS=10
# Choose 1 red, 1 yellow, 1 blue
nums=$(rand -N 3 -M $TOTAL_SPLITS -u)
red=$(echo "$nums" | awk '{print $1}')
yellow=$(echo "$nums" | awk '{print $2}')
blue=$(echo "$nums" | awk '{print $3}')
directions=$(rand -N TOTAL_SPLITS -M 2)
# Create some splits
tmux new-window -n modrian "solid_color $white_color"
tmux set-option -g pane-active-border-bg default
tmux set-option -g pane-active-border-fg default
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="solid_color $color"
case "$(head -c 10 /dev/urandom | md5sum | head -c1)" in
0|1|2|3|4|5|6|7) SPLIT="-v" ;;
8|9|a|b|c|d|e|f) SPLIT="-h" ;;
esac
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
#sleep 0.1
done