* screen-profile-helper allows to create new windows

* screen-profile-helper allows to select profiles
This commit is contained in:
Nick Barcet 2008-12-19 18:46:17 +01:00
commit 78d0900d2d
7 changed files with 66 additions and 24 deletions

2
debian/changelog vendored
View file

@ -6,6 +6,8 @@ screen-profiles (1.1-0ubuntu1) jaunty; urgency=low
* First pot and translation to french
* First try at screen-profile-helper
* Allow select-screen-profile to not run interactively
* screen-profile-helper allows to create new windows
* screen-profile-helper allows to select profiles
[ Dustin Kirkland ]
* created keybindings directory, moved keybindings there

1
debian/install vendored
View file

@ -7,5 +7,6 @@ profiles/common usr/share/screen-profiles/profiles
profiles/debian.screenrc usr/share/screen-profiles/profiles
profiles/ubuntu.screenrc usr/share/screen-profiles/profiles
keybindings/common usr/share/screen-profiles/keybindings
windows/default usr/share/screen-profiles/windows
select-screen-profile usr/bin
screen-profiles-helper.py usr/share/screen-profiles/

View file

@ -40,6 +40,10 @@ bindkey -k k6 kill # F6 | Close window
bindkey -k k1 screen -t help 0 less /usr/share/doc/screen-profiles/help.txt # F1 | Basic help (this)
bindkey -k k2 help # F2 | Advanced help
# Reload
register r "^g:source $HOME/.screenrc-profile"
bindkey -k k5 process r
# power detach
register x "^g^d D"
bindkey ^[[3;6~ process x # C-shift-del | Detach and logout

View file

@ -34,9 +34,5 @@ hardstatus alwayslastline
termcapinfo xterm ti@:te@
defscrollback 10000
# Default windows
screen -t bash 1
screen -t welcome 0 python /usr/share/screen-profiles/screen-profiles-helper.py
# Default keybindings
source /usr/share/screen-profiles/keybindings/common

View file

@ -1,6 +1,6 @@
#! /usr/bin/env python
import sys, os, os.path, time, string, dialog
import sys, os, os.path, time, string, dialog, commands
def ioctl_GWINSZ(fd): #### TABULATION FUNCTIONS
try: ### Discover terminal width
@ -52,8 +52,8 @@ def menu_demo(d, size):
width=size[0],
choices=[("1", "Display some basic help"),
("2", "Change screen profile"),
("3", "Change key bindings"),
("4", "Launch screen by default")
("3", "Create a new window"),
("4", "Install screen by default at login")
])
if handle_exit_code(d, code):
break
@ -63,10 +63,23 @@ def help(d, size):
d.textbox("/usr/share/doc/screen-profiles/help.txt", width=size[0], height=size[1])
def profile(d):
d.msgbox("This has yet to be implemented")
list = []
for choice in commands.getoutput('select-screen-profile -l').splitlines():
if choice.startswith("ubuntu"):
el = (choice, "<-- recommended", 1)
list.append(el)
else:
el = (choice, "", 0)
list.append(el)
(code, tag) = d.radiolist("Which profile would you like to use?", width=65, choices=list)
if code == d.DIALOG_OK:
commands.getoutput('select-screen-profile --set %s' % tag)
d.msgbox("Please press F5 to apply profile")
def key(d):
d.msgbox("This has yet to be implemented")
def newwindow(d):
(code, answer) = d.inputbox("New window name?", init="bash")
if code == d.DIALOG_OK:
commands.getoutput('screen -t %s' % answer)
def default(d):
d.msgbox("This has yet to be implemented")
@ -90,7 +103,7 @@ def main():
elif tag == "2":
profile(d)
elif tag == "3":
key(d)
newwindow(d)
elif tag == "4":
default(d)

View file

@ -35,18 +35,28 @@ usage: select-screen-profiles [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
EOT
}
# Initialize variables
BASE_DIR="/usr/share/screen-profiles"
PROFILE_DIR="$BASE_DIR/profiles"
WINDOW_DIR="$BASE_DIR/windows"
profile=""
selected=-1
# Ensure that ~/.screenrc-profile is a symbolic link
if [ -e "$HOME/.screenrc-profile" ]; then
if [ ! -L "$HOME/.screenrc-profile" ]; then
echo `gettext 'Error:'` $HOME/.screenrc-profile `gettext ' file exists, but is not a symlink'`
exit 1
fi
if [ ! -L "$HOME/.screenrc-profile" ]; then
echo `gettext 'Error:'` $HOME/.screenrc-profile `gettext ' file exists, but is not a symlink'`
exit 1
fi
fi
# Ensure that ~/.screenrc-window is a symbolic link
if [ -e "$HOME/.screenrc-window" ]; then
if [ ! -L "$HOME/.screenrc-window" ]; then
echo `gettext 'Error:'` $HOME/.screenrc-window `gettext ' file exists, but is not a symlink'`
exit 1
fi
fi
profiles=$(ls $PROFILE_DIR)
@ -81,12 +91,14 @@ prompt() {
}
listprofiles() {
# Display list of profiles, one per line
for x in $profiles; do
echo "$x"
done
}
setprofile() {
# Apply a profile by name ($profile) or index ($selected)
i=0
found=0
for x in $profiles; do
@ -95,20 +107,31 @@ setprofile() {
if [ ! -e "$HOME/.screenrc" ]; then
# If the user doesn't have a .screenrc, seed one
echo "source ~/.screenrc-profile" > "$HOME/.screenrc"
echo "source ~/.screenrc-window" >> "$HOME/.screenrc"
else
# If the user does have a .screenrc, see if it has the
# source line
if ! grep -qs "source $HOME/.screenrc-profile" "$HOME/.screenrc"; then
# And if it's missing the source line, add it
# to the top
tmp=`mktemp "$HOME/.screenrc.XXXXXX"`
echo "source $HOME/.screenrc-profile" > "$tmp"
cat "$HOME/.screenrc" >> "$tmp"
mv -f "$tmp" "$HOME/.screenrc"
fi
# sources lines
if ! grep -qs "source $HOME/.screenrc-profile" "$HOME/.screenrc"; then
# And if it's missing the source line, add it
# to the top
tmp=`mktemp "$HOME/.screenrc.XXXXXX"`
echo "source $HOME/.screenrc-profile" > "$tmp"
cat "$HOME/.screenrc" >> "$tmp"
mv -f "$tmp" "$HOME/.screenrc"
fi
if ! grep -qs "source $HOME/.screenrc-window" "$HOME/.screenrc"; then
# And if it's missing the source line, add it
# to the top
tmp=`mktemp "$HOME/.screenrc.XXXXXX"`
echo "source $HOME/.screenrc-window" > "$tmp"
cat "$HOME/.screenrc" >> "$tmp"
mv -f "$tmp" "$HOME/.screenrc"
fi
fi
rm -f "$HOME/.screenrc-profile"
rm -f "$HOME/.screenrc-window"
ln -s "$PROFILE_DIR/$x" "$HOME/.screenrc-profile"
ln -s "$WINDOW_DIR/default" "$HOME/.screenrc-window"
found=1
fi
done

3
windows/default Normal file
View file

@ -0,0 +1,3 @@
# Default windows
screen -t bash 1
screen -t welcome 0 python /usr/share/screen-profiles/screen-profiles-helper.py