4
# Copyright (C) 2008 Canonical Ltd.
6
# Authors: Dustin Kirkland <kirkland@canonical.com>
7
# Nick Barcet <nick.barcet@ubuntu.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, version 3 of the License.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
# If you change any strings, please generate localization information with:
23
# ./debian/rules get-po
31
usage: byobu-select-profile [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
32
-l,--list list available profiles
33
-s,--set PROFILE set profile
36
Without any parameters, runs interactively.
40
# Initialize variables
41
BASE_DIR="/usr/share/$PKG"
42
PROFILE_DIR="$BASE_DIR/profiles"
48
if [ ! -L "$1" ]; then
49
echo `gettext 'Error:'` $1 `gettext ' file exists, but is not a symlink'`
55
mkdir -p "$HOME/.$PKG"
56
# If these files exist, they must be a symlink
57
assert_symlink "$HOME/.$PKG/profile"
60
# Display list of profiles, one per line
61
# Start with basic profiles
62
basename $(ls $PROFILE_DIR/NONE 2>/dev/null) 2>/dev/null
63
basename $(ls $PROFILE_DIR/light 2>/dev/null) 2>/dev/null
64
basename $(ls $PROFILE_DIR/dark 2>/dev/null) 2>/dev/null
65
basename $(ls $PROFILE_DIR/black 2>/dev/null) 2>/dev/null
66
# Now, list advanced profiles
67
for x in $(ls $PROFILE_DIR/*_* 2>/dev/null); do
69
if [ $x = "common" -o $x = "misc" ]; then
70
# Skip the common profile, no value there
78
# Prompt the user to choose among the available profiles
80
echo `gettext "Select a screen profile: "`
82
profiles=$(listprofiles)
83
for x in $profiles; do
86
if [ "$x" = "light" ]; then
89
[ $i -lt 10 ] && i=" $i"
96
if [ $count -gt 5 ]; then
97
echo `gettext "ERROR: Invalid selection"`
100
count=`expr $count + 1`
101
if [ -z "$selected" -a ! -z "$simple" ]; then
103
elif ! test $selected -gt 0 2>/dev/null; then
104
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
106
elif ! test $selected -le $i 2>/dev/null; then
107
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
117
# Apply a profile by name or index
125
profiles=$(listprofiles)
126
for x in $profiles; do
128
if [ "$i" = "$selected" -o "$x" = "$selected" ]; then
129
rm -f "$HOME/.$PKG/profile"
130
ln -s "$PROFILE_DIR/$x" "$HOME/.$PKG/profile"
133
if [ -n "$STY" ]; then
134
echo `gettext 'If you are using the default set of keybindings, press\n<F5> to activate these changes.\n\nOtherwise, exit this screen session and start a new one.'`
136
echo `gettext 'Run "byobu" to activate'`
142
if [ $found -eq 0 ]; then
143
echo "Invalid profile"
147
if [ $# -eq 0 ]; then
151
TEMP=`getopt -o lhs: --long list,help,set: -- "$@"`