big merge from Nick, fair number of changes (see changelog for details)

renamed profiles to drop .screenrc
install screen-launcher to /usr/bin
rework screen-launcher and screen-install
screen-profiles-helper support for disabling itself on startup
This commit is contained in:
Dustin Kirkland 2009-01-09 17:41:31 -06:00
commit 66526bc41d
12 changed files with 201 additions and 42 deletions

14
debian/changelog vendored
View file

@ -6,8 +6,20 @@ screen-profiles (1.5) UNRELEASED; urgency=low
* debian/install, profiles/common, profiles/ubuntu.screenrc:
updated with mem and load status scripts
* profiles/common: fix scrollback, LP: #309393
* profiles/*.screenrc: renamed to drop the ".screenrc" bit as this was
unnecessary; this will break early users, they will need to re-run
select-screen-profile to fix
* screen-launcher, screen-install, debian/install: install screen-launcher
to /usr/bin, drop the symlinking to ~/.screen-launcher, just install by
adding /usr/bin/screen-launcher to ~/.bashrc; install screen-launcher
to both bashrc and bash_profile
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 09 Jan 2009 15:05:11 -0600
[Nicolas Barcet]
* Allow selecting which windows are opened by default in
screen-profiles-helper
* Allow help message not to be displayed when starting
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 09 Jan 2009 17:40:00 -0600
screen-profiles (1.4-0ubuntu1) jaunty; urgency=low

6
debian/install vendored
View file

@ -6,11 +6,11 @@ bin/reboot-required usr/share/screen-profiles/bin
bin/release usr/share/screen-profiles/bin
bin/updates-available usr/share/screen-profiles/bin
profiles/common usr/share/screen-profiles/profiles
profiles/debian.screenrc usr/share/screen-profiles/profiles
profiles/ubuntu.screenrc usr/share/screen-profiles/profiles
profiles/debian usr/share/screen-profiles/profiles
profiles/ubuntu usr/share/screen-profiles/profiles
keybindings/common usr/share/screen-profiles/keybindings
windows/common usr/share/screen-profiles/windows
select-screen-profile usr/bin
screen-profiles-helper usr/bin
screen-install usr/share/screen-profiles/
screen-launcher usr/share/screen-profiles/
screen-launcher usr/bin/

2
debian/rules vendored
View file

@ -42,7 +42,7 @@ binary-indep: build install
dh_installdebconf
dh_compress
dh_fixperms
dh_link /etc/screenrc usr/share/${PACKAGE}/profiles/default.screenrc
dh_link /etc/screenrc usr/share/${PACKAGE}/profiles/plain
dh_installdeb
dh_gencontrol
dh_builddeb

View file

@ -44,4 +44,6 @@ defscrollback 10000
source /usr/share/screen-profiles/keybindings/common
# Default windows
source /usr/share/screen-profiles/windows/common
# Windows list should be placed in each user's ~/.screenrc-windows,
# to be configurable
source ~/.screenrc-windows

View file

@ -21,25 +21,29 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
LAUNCHER="/usr/bin/screen-launcher"
BASHRC="$HOME/.bashrc"
install_screen_launcher() {
dest=$1
launcher="/usr/bin/screen-launcher"
# We have to make sure screen is called last
pos=$(( $(grep -ns "$LAUNCHER" "$BASHRC" | sed 's/:.*$//' | head -1) ))
pos=$(( $(grep -ns "$launcher" "$dest" | sed 's/:.*$//' | head -1) ))
do=0
if [ $pos -gt 0 ]; then
if [ $pos -lt $(( $(wc -l "$BASHRC" | sed "s/ .*$//") -2)) ]; then
if [ $pos -lt $(( $(wc -l "$dest" | sed "s/ .*$//") -2)) ]; then
# We have to reposition the line at the end
# First remove it
sed -ibak '/screen-launcher/d' "$BASHRC"
sed -ibak '/screen-launcher/d' "$dest"
do=1
fi
else
do=1
fi
# Add it at the end
if [ $do -eq 1 ]; then
echo "$LAUNCHER" >> "$BASHRC"
echo "$launcher" >> "$dest"
fi
}
install_screen_launcher "$HOME/.bashrc"
install_screen_launcher "$HOME/.bash_profile"

View file

@ -20,6 +20,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import sys, os, os.path, time, string, commands
from ConfigParser import SafeConfigParser
from snack import *
# Command presets for windows creation
@ -53,11 +54,12 @@ def terminal_size(): ### decide on *some* terminal size
return int(cr[1]-5), int(cr[0]-5) # reverse rows, cols
def menu(screen, size):
li = Listbox(height = 4, width = 60, returnExit = 1)
li = Listbox(height = 5, width = 60, returnExit = 1)
li.append("Help", 1)
li.append("Change screen profile", 2)
li.append("Create new window(s)", 3)
li.append("Install screen by default at login", 4)
li.append("Manage default windows", 4)
li.append("Install screen by default at login", 5)
bb = ButtonBar(screen, (("Ok", "ok"), ("Exit", "exit")), compact = 1)
g = GridForm(screen, "GNU Screen Profiles Menu", 1, 2)
@ -81,13 +83,40 @@ def messagebox(screen, width, height, title, text, \
return bb.buttonPressed(g.runOnce())
def help(screen, size):
def help(screen, size, intro=0, config=None):
f=file('/usr/share/doc/screen-profiles/help.txt')
text=f.read()
f.close()
button = messagebox(screen, 76, 19, "GNU Screen Profiles Help", text, \
scroll=1, buttons=(("Menu", "menu"), ("Exit", "exit")) )
t = Textbox(74, 19, text, scroll=1)
bb = ButtonBar(screen, (("Menu", "menu"), ("Exit", "exit")), compact = 1)
if intro == 1:
formlen=3
cb=Checkbox("Display this help on startup", isOn=1)
else:
formlen=2
g = GridForm(screen, "GNU Screen Profiles Help", 1, formlen)
g.add(t, 0, 0, padding=(0,0,0,0))
if intro == 1:
g.add(cb, 0, 1, padding=(1,0,0,0))
g.add(bb, 0, 2, padding=(1,1,0,0))
else:
g.add(bb, 0, 1, padding=(1,1,0,0))
button = bb.buttonPressed(g.runOnce())
if intro == 1 and not cb.value():
#Check box value has change, write config file
if not config.has_section('Defaults'):
config.add_section('Defaults')
config.set('Defaults','help','off')
configfile=open(os.getenv("HOME")+'/.screen-profiles-helper', 'wb')
try:
config.write(configfile)
finally:
configfile.close()
if button == "exit":
return 0
@ -139,23 +168,112 @@ def newwindow(screen, size):
r.append(cur[0], count)
count=count+1
cb=Checkbox("Add to default windows")
bb = ButtonBar(screen, (("Create", "create"), ("Cancel", "cancel")), compact = 1)
g = GridForm(screen, "Create new window(s):", 2, 4 )
g = GridForm(screen, "Create new window(s):", 2, 5 )
g.add(titlel, 0, 0, anchorLeft=1,padding=(4,1,0,1))
g.add(title, 1, 0, anchorLeft=1)
g.add(commandl, 0, 1, anchorLeft=1, anchorTop=1,padding=(4,0,0,1))
g.add(command, 1, 1, anchorLeft=1)
g.add(rl, 0, 2, anchorLeft=1,padding=(4,0,0,1))
g.add(r, 1, 2)
g.add(bb, 1, 3, padding=(4,1,0,0))
g.add(cb, 1, 3, padding=(4,1,0,1))
g.add(bb, 1, 4, padding=(4,1,0,0))
if bb.buttonPressed(g.runOnce()) != "cancel":
sel=r.getSelection()
if sel:
for s in sel:
commands.getoutput('screen -t %s %s' % (cmd[s][1], cmd[s][2]) )
win='screen -t %s %s' % (cmd[s][1], cmd[s][2])
commands.getoutput(win)
if cb.value():
appendwindow(win)
else:
commands.getoutput('screen -t %s %s' % (title.value(), command.value()) )
win='screen -t %s %s' % (title.value(), command.value())
commands.getoutput(win)
if cb.value():
appendwindow(win)
return 100
def appendwindow(win):
f=open(os.getenv("HOME")+'/.screenrc-windows', 'a')
try:
f.write(win+"\n")
except IOError:
return None
finally:
f.close()
def readwindows():
f=open(os.getenv("HOME")+'/.screenrc-windows', 'r')
try:
li=[]
for line in f.readlines():
if line.startswith("# "):
# this is a comment
window=[-1, line]
elif line.startswith("#"):
# this is an inactive window
window=[0, line.lstrip("#")]
else:
window=[1, line]
li.append(window)
return li
except IOError:
return None
finally:
f.close()
def writewindows(winlist):
f=open(os.getenv("HOME")+'/.screenrc-windows', 'w')
try:
for win in winlist:
if win[0] == -1:
f.write(win[1])
elif win[0] == 0:
f.write("#"+win[1])
else:
f.write(win[1])
except IOError:
return None
finally:
f.close()
def defaultwindows(screen, size):
winlist=readwindows()
rl=Label("Windows:")
r=CheckboxTree(10, scroll=1)
count=0
for win in winlist:
if win[0] != -1:
r.append(win[1],count,selected=win[0])
count=count+1
bb = ButtonBar(screen, (("Save", "save"), ("Cancel", "cancel")), compact = 1)
g = GridForm(screen, "Select window(s) to create by default:", 2, 4 )
g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4,0,0,1))
g.add(r, 1, 0)
g.add(bb, 1, 1, padding=(4,1,0,0))
if bb.buttonPressed(g.runOnce()) != "cancel":
count=0
for win in winlist:
if win[0] != -1:
win[0] = r.getEntryValue(count)[1]
count=count+1
writewindows(winlist)
return 100
@ -176,9 +294,20 @@ def main():
"""
size = terminal_size()
screen = SnackScreen()
screen.drawRootText(1,0,"== GNU Screen Profiles Helper ==")
screen.drawRootText(1,0,"GNU Screen Profiles Helper")
screen.pushHelpLine("<Tab>/<Alt-Tab> between elements | <Return> Validates")
tag = help(screen, size)
config = SafeConfigParser()
config.read(os.getenv("HOME")+'/.screen-profiles-helper')
if config.has_option('Defaults', 'help'):
showhelp=config.get('Defaults', 'help')
else:
showhelp="on"
if showhelp == "on":
tag = help(screen, size, intro=1, config=config)
else:
tag = 100
while tag > 0 :
tag = menu(screen, size)
@ -189,6 +318,8 @@ def main():
elif tag == 3:
tag = newwindow(screen, size)
elif tag == 4:
tag = defaultwindows(screen, size)
elif tag == 5:
tag = install(screen, size)
screen.finish()

View file

@ -27,7 +27,7 @@
usage () {
cat <<EOT
usage: select-screen-profiles [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
-l,--list list avaivalable profiles
-l,--list list available profiles
-s,--set PROFILE set profile
-h,--help this help
@ -56,6 +56,10 @@ assert_symlink "$HOME/.screenrc-profile"
listprofiles() {
# Display list of profiles, one per line
for x in $(ls $PROFILE_DIR); do
if [ $x = "common" ]; then
# Skip the common profile, no value there
continue
fi
echo "$x"
done
}
@ -69,7 +73,7 @@ prompt() {
for x in $profiles; do
i=$(expr $i + 1)
desc=" "
if [ $x = "ubuntu.screenrc" ]; then
if [ $x = "ubuntu" ]; then
desc="<---- ` gettext 'recommended'`"
simple=$i
fi
@ -93,7 +97,11 @@ prompt() {
setprofile() {
# Apply a profile by name or index
if [ -n "$1" ]; then
selected="$1"
else
selected="$SELECTED"
fi
i=0
found=0
profiles=$(listprofiles)
@ -124,6 +132,9 @@ setprofile() {
if [ $found -eq 0 ]; then
echo "Invalid profile"
fi
if [ ! -e "$HOME/.screenrc-windows" ]; then
cp "$BASE_DIR/windows/common" "$HOME/.screenrc-windows"
fi
}
if [ $# -eq 0 ]; then
@ -135,8 +146,7 @@ else
while true; do
case "$1" in
-s|--set)
profile="$2"
setprofile
setprofile "$2"
shift 2
break
;;

View file

@ -1,3 +1,3 @@
# Default windows
#screen -t welcome 0 screen-profiles-helper
screen -t shell 1
screen -t welcome 0 screen-profiles-helper