mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 05:53:22 -07:00
* screen-profile-helper allows to create new windows
* screen-profile-helper allows to select profiles
This commit is contained in:
parent
e7db8eb470
commit
78d0900d2d
7 changed files with 66 additions and 24 deletions
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -6,6 +6,8 @@ screen-profiles (1.1-0ubuntu1) jaunty; urgency=low
|
||||||
* First pot and translation to french
|
* First pot and translation to french
|
||||||
* First try at screen-profile-helper
|
* First try at screen-profile-helper
|
||||||
* Allow select-screen-profile to not run interactively
|
* 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 ]
|
[ Dustin Kirkland ]
|
||||||
* created keybindings directory, moved keybindings there
|
* created keybindings directory, moved keybindings there
|
||||||
|
|
1
debian/install
vendored
1
debian/install
vendored
|
@ -7,5 +7,6 @@ profiles/common usr/share/screen-profiles/profiles
|
||||||
profiles/debian.screenrc usr/share/screen-profiles/profiles
|
profiles/debian.screenrc usr/share/screen-profiles/profiles
|
||||||
profiles/ubuntu.screenrc usr/share/screen-profiles/profiles
|
profiles/ubuntu.screenrc usr/share/screen-profiles/profiles
|
||||||
keybindings/common usr/share/screen-profiles/keybindings
|
keybindings/common usr/share/screen-profiles/keybindings
|
||||||
|
windows/default usr/share/screen-profiles/windows
|
||||||
select-screen-profile usr/bin
|
select-screen-profile usr/bin
|
||||||
screen-profiles-helper.py usr/share/screen-profiles/
|
screen-profiles-helper.py usr/share/screen-profiles/
|
||||||
|
|
|
@ -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 k1 screen -t help 0 less /usr/share/doc/screen-profiles/help.txt # F1 | Basic help (this)
|
||||||
bindkey -k k2 help # F2 | Advanced help
|
bindkey -k k2 help # F2 | Advanced help
|
||||||
|
|
||||||
|
# Reload
|
||||||
|
register r "^g:source $HOME/.screenrc-profile"
|
||||||
|
bindkey -k k5 process r
|
||||||
|
|
||||||
# power detach
|
# power detach
|
||||||
register x "^g^d D"
|
register x "^g^d D"
|
||||||
bindkey ^[[3;6~ process x # C-shift-del | Detach and logout
|
bindkey ^[[3;6~ process x # C-shift-del | Detach and logout
|
||||||
|
|
|
@ -34,9 +34,5 @@ hardstatus alwayslastline
|
||||||
termcapinfo xterm ti@:te@
|
termcapinfo xterm ti@:te@
|
||||||
defscrollback 10000
|
defscrollback 10000
|
||||||
|
|
||||||
# Default windows
|
|
||||||
screen -t bash 1
|
|
||||||
screen -t welcome 0 python /usr/share/screen-profiles/screen-profiles-helper.py
|
|
||||||
|
|
||||||
# Default keybindings
|
# Default keybindings
|
||||||
source /usr/share/screen-profiles/keybindings/common
|
source /usr/share/screen-profiles/keybindings/common
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /usr/bin/env python
|
#! /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
|
def ioctl_GWINSZ(fd): #### TABULATION FUNCTIONS
|
||||||
try: ### Discover terminal width
|
try: ### Discover terminal width
|
||||||
|
@ -52,8 +52,8 @@ def menu_demo(d, size):
|
||||||
width=size[0],
|
width=size[0],
|
||||||
choices=[("1", "Display some basic help"),
|
choices=[("1", "Display some basic help"),
|
||||||
("2", "Change screen profile"),
|
("2", "Change screen profile"),
|
||||||
("3", "Change key bindings"),
|
("3", "Create a new window"),
|
||||||
("4", "Launch screen by default")
|
("4", "Install screen by default at login")
|
||||||
])
|
])
|
||||||
if handle_exit_code(d, code):
|
if handle_exit_code(d, code):
|
||||||
break
|
break
|
||||||
|
@ -63,10 +63,23 @@ def help(d, size):
|
||||||
d.textbox("/usr/share/doc/screen-profiles/help.txt", width=size[0], height=size[1])
|
d.textbox("/usr/share/doc/screen-profiles/help.txt", width=size[0], height=size[1])
|
||||||
|
|
||||||
def profile(d):
|
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):
|
def newwindow(d):
|
||||||
d.msgbox("This has yet to be implemented")
|
(code, answer) = d.inputbox("New window name?", init="bash")
|
||||||
|
if code == d.DIALOG_OK:
|
||||||
|
commands.getoutput('screen -t %s' % answer)
|
||||||
|
|
||||||
def default(d):
|
def default(d):
|
||||||
d.msgbox("This has yet to be implemented")
|
d.msgbox("This has yet to be implemented")
|
||||||
|
@ -90,7 +103,7 @@ def main():
|
||||||
elif tag == "2":
|
elif tag == "2":
|
||||||
profile(d)
|
profile(d)
|
||||||
elif tag == "3":
|
elif tag == "3":
|
||||||
key(d)
|
newwindow(d)
|
||||||
elif tag == "4":
|
elif tag == "4":
|
||||||
default(d)
|
default(d)
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,10 @@ usage: select-screen-profiles [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Initialize variables
|
||||||
BASE_DIR="/usr/share/screen-profiles"
|
BASE_DIR="/usr/share/screen-profiles"
|
||||||
PROFILE_DIR="$BASE_DIR/profiles"
|
PROFILE_DIR="$BASE_DIR/profiles"
|
||||||
|
WINDOW_DIR="$BASE_DIR/windows"
|
||||||
profile=""
|
profile=""
|
||||||
selected=-1
|
selected=-1
|
||||||
|
|
||||||
|
@ -47,6 +49,14 @@ if [ -e "$HOME/.screenrc-profile" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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)
|
profiles=$(ls $PROFILE_DIR)
|
||||||
|
|
||||||
|
@ -81,12 +91,14 @@ prompt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
listprofiles() {
|
listprofiles() {
|
||||||
|
# Display list of profiles, one per line
|
||||||
for x in $profiles; do
|
for x in $profiles; do
|
||||||
echo "$x"
|
echo "$x"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
setprofile() {
|
setprofile() {
|
||||||
|
# Apply a profile by name ($profile) or index ($selected)
|
||||||
i=0
|
i=0
|
||||||
found=0
|
found=0
|
||||||
for x in $profiles; do
|
for x in $profiles; do
|
||||||
|
@ -95,9 +107,10 @@ setprofile() {
|
||||||
if [ ! -e "$HOME/.screenrc" ]; then
|
if [ ! -e "$HOME/.screenrc" ]; then
|
||||||
# If the user doesn't have a .screenrc, seed one
|
# If the user doesn't have a .screenrc, seed one
|
||||||
echo "source ~/.screenrc-profile" > "$HOME/.screenrc"
|
echo "source ~/.screenrc-profile" > "$HOME/.screenrc"
|
||||||
|
echo "source ~/.screenrc-window" >> "$HOME/.screenrc"
|
||||||
else
|
else
|
||||||
# If the user does have a .screenrc, see if it has the
|
# If the user does have a .screenrc, see if it has the
|
||||||
# source line
|
# sources lines
|
||||||
if ! grep -qs "source $HOME/.screenrc-profile" "$HOME/.screenrc"; then
|
if ! grep -qs "source $HOME/.screenrc-profile" "$HOME/.screenrc"; then
|
||||||
# And if it's missing the source line, add it
|
# And if it's missing the source line, add it
|
||||||
# to the top
|
# to the top
|
||||||
|
@ -106,9 +119,19 @@ setprofile() {
|
||||||
cat "$HOME/.screenrc" >> "$tmp"
|
cat "$HOME/.screenrc" >> "$tmp"
|
||||||
mv -f "$tmp" "$HOME/.screenrc"
|
mv -f "$tmp" "$HOME/.screenrc"
|
||||||
fi
|
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
|
fi
|
||||||
rm -f "$HOME/.screenrc-profile"
|
rm -f "$HOME/.screenrc-profile"
|
||||||
|
rm -f "$HOME/.screenrc-window"
|
||||||
ln -s "$PROFILE_DIR/$x" "$HOME/.screenrc-profile"
|
ln -s "$PROFILE_DIR/$x" "$HOME/.screenrc-profile"
|
||||||
|
ln -s "$WINDOW_DIR/default" "$HOME/.screenrc-window"
|
||||||
found=1
|
found=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
3
windows/default
Normal file
3
windows/default
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default windows
|
||||||
|
screen -t bash 1
|
||||||
|
screen -t welcome 0 python /usr/share/screen-profiles/screen-profiles-helper.py
|
Loading…
Add table
Add a link
Reference in a new issue