mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
massive merge from Nick, thanks
I had to make a few adjustments, will discuss in IRC
This commit is contained in:
commit
5eede69fe2
11 changed files with 457 additions and 71 deletions
11
debian/changelog
vendored
11
debian/changelog
vendored
|
@ -9,7 +9,16 @@ screen-profiles (1.2) UNRELEASED; urgency=low
|
||||||
[Nicolas Valcárcel]
|
[Nicolas Valcárcel]
|
||||||
* Spanish translations
|
* Spanish translations
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 06 Jan 2009 15:32:06 -0600
|
[ Nicolas Barcet ]
|
||||||
|
* 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
|
||||||
|
* screen-profile-helper allows to install screen by default
|
||||||
|
* Now uses python-newt instead of python-dialog
|
||||||
|
* Add framework for useful windows creation
|
||||||
|
|
||||||
|
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 06 Jan 2009 17:47:00 -0600
|
||||||
|
|
||||||
screen-profiles (1.1-0ubuntu1) jaunty; urgency=low
|
screen-profiles (1.1-0ubuntu1) jaunty; urgency=low
|
||||||
|
|
||||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -9,7 +9,7 @@ Vcs-Bzr: http://bazaar.launchpad.net/~kirkland/screen-profiles/main
|
||||||
|
|
||||||
Package: screen-profiles
|
Package: screen-profiles
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: debconf (>= 0.5) | debconf-2.0, screen, gettext-base, debianutils
|
Depends: debconf (>= 0.5) | debconf-2.0, screen, gettext-base, python, python-newt
|
||||||
Recommends: update-notifier-common
|
Recommends: update-notifier-common
|
||||||
Suggests: bc
|
Suggests: bc
|
||||||
Description: a set of useful profiles and a profile-switcher for GNU screen
|
Description: a set of useful profiles and a profile-switcher for GNU screen
|
||||||
|
|
4
debian/install
vendored
4
debian/install
vendored
|
@ -7,4 +7,8 @@ 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/common usr/share/screen-profiles/windows
|
||||||
select-screen-profile usr/bin
|
select-screen-profile usr/bin
|
||||||
|
screen-profiles-helper usr/bin
|
||||||
|
screen-install usr/share/screen-profiles/
|
||||||
|
screen-launcher usr/share/screen-profiles/
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
**********************************************
|
|
||||||
** Welcome to the screen powered terminal **
|
|
||||||
**********************************************
|
|
||||||
Screen is a powerful program that allows your terminal session to have
|
Screen is a powerful program that allows your terminal session to have
|
||||||
multiple windows and retain context between multiple logins. This
|
multiple windows and retain context between multiple logins. This
|
||||||
version of screen is configured with a task bar at the bottom of the
|
version of screen is configured with a task bar at the bottom of the
|
||||||
window that shows system status, pending updates, and which window you
|
window that shows system status, pending updates, and which window you
|
||||||
are currently viewing.
|
are currently viewing.
|
||||||
|
|
||||||
Common mappings* (where C- means ctrl):
|
Common mappings (where C- means ctrl):
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
C-PgUp/Shift-Tab Goto next window | F1 Basic help (this)
|
C-PgUp/Shift-Tab Goto next window | F1 Basic help (this)
|
||||||
C-PgDown Goto previous window | F2 Advanced help
|
C-PgDown Goto previous window | F2 Advanced help
|
||||||
|
@ -18,6 +15,3 @@ C-g Esc Use scrollback (Esc exits) | F6 Close current window
|
||||||
Use 'screen -r' to reattach to a detached screen. Complete help on
|
Use 'screen -r' to reattach to a detached screen. Complete help on
|
||||||
screen can be obtained using the 'man screen' command. Please note that
|
screen can be obtained using the 'man screen' command. Please note that
|
||||||
screen is configured to remap the escape prefix from ctrl-A to ctrl-G.
|
screen is configured to remap the escape prefix from ctrl-A to ctrl-G.
|
||||||
|
|
||||||
* These mappings are known to work with xterm compatible terminals (eg
|
|
||||||
gnome-terminal), but may need to be adjusted for your environment.
|
|
||||||
|
|
|
@ -37,9 +37,13 @@ bindkey -k k4 process n # F4 | Create new window
|
||||||
bindkey -k k6 kill # F6 | Close window
|
bindkey -k k6 kill # F6 | Close window
|
||||||
|
|
||||||
# Maps for help
|
# Maps for help
|
||||||
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 screen-profiles-helper # 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,8 @@ hardstatus alwayslastline
|
||||||
termcapinfo xterm ti@:te@
|
termcapinfo xterm ti@:te@
|
||||||
defscrollback 10000
|
defscrollback 10000
|
||||||
|
|
||||||
# Default windows
|
|
||||||
screen -t bash 1
|
|
||||||
screen -t welcome 0 /usr/bin/sensible-pager /usr/share/doc/screen-profiles/help.txt
|
|
||||||
|
|
||||||
# Default keybindings
|
# Default keybindings
|
||||||
source /usr/share/screen-profiles/keybindings/common
|
source /usr/share/screen-profiles/keybindings/common
|
||||||
|
|
||||||
|
# Default windows
|
||||||
|
source /usr/share/screen-profiles/windows/common
|
||||||
|
|
55
screen-install
Executable file
55
screen-install
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# GNU screen-profiles-helper
|
||||||
|
# Copyright (C) 2008 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Authors: Nick Barcet <nick.barcet@ubuntu.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; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
|
LAUNCHER="$HOME/.screen-launcher"
|
||||||
|
BASHRC="$HOME/.bashrc"
|
||||||
|
|
||||||
|
# We have to make sure screen is called last
|
||||||
|
pos=$(( $(grep -ns "source $LAUNCHER" "$BASHRC" | sed 's/:.*$//' | head -1) ))
|
||||||
|
|
||||||
|
do=0
|
||||||
|
if [ $pos -gt 0 ]; then
|
||||||
|
if [ $pos -lt $(( $(wc -l "$BASHRC" | sed "s/ .*$//") -2)) ]; then
|
||||||
|
# We have to reposition the line at the end
|
||||||
|
# First remove it
|
||||||
|
sed -ibak '/screen-launcher/d' "$BASHRC"
|
||||||
|
do=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
do=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add it at the end
|
||||||
|
if [ $do -eq 1 ]; then
|
||||||
|
echo "source $LAUNCHER" >> "$BASHRC"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure that ~/.screen-launcher is a symbolic link
|
||||||
|
if [ -e "$HOME/.screen-launcher" ]; then
|
||||||
|
if [ ! -L "$HOME/.screen-launcher" ]; then
|
||||||
|
echo `gettext 'Error:'` $HOME/.screen-launcher `gettext ' file exists, but is not a symlink'`
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ln -s /usr/share/screen-profiles/screen-launcher "$HOME/.screen-launcher"
|
||||||
|
fi
|
||||||
|
|
29
screen-launcher
Executable file
29
screen-launcher
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# GNU screen-profiles-helper
|
||||||
|
# Copyright (C) 2008 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Authors: Nick Barcet <nick.barcet@ubuntu.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; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
|
# Verify that we are correctly installed
|
||||||
|
/bin/bash /usr/share/screen-profiles/screen-install
|
||||||
|
|
||||||
|
if [ "$TERM" != "screen" ]; then
|
||||||
|
screen -xRR
|
||||||
|
logout
|
||||||
|
fi
|
198
screen-profiles-helper
Executable file
198
screen-profiles-helper
Executable file
|
@ -0,0 +1,198 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
|
#
|
||||||
|
# GNU screen-profiles-helper
|
||||||
|
# Copyright (C) 2008 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Authors: Nick Barcet <nick.barcet@ubuntu.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; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
import sys, os, os.path, time, string, commands
|
||||||
|
from snack import *
|
||||||
|
|
||||||
|
# Command presets for windows creation
|
||||||
|
cmd=( ("System activity", "top", "top"),
|
||||||
|
("System log", "log", "watch -n 10 tail -n 5 /var/log/syslog /var/log/auth.log /var/log/dmesg"),
|
||||||
|
("Disk and ram usage", "mem", 'watch -n 30 "df -h; echo ""; free -mt"'))
|
||||||
|
|
||||||
|
|
||||||
|
def ioctl_GWINSZ(fd): #### TABULATION FUNCTIONS
|
||||||
|
try: ### Discover terminal width
|
||||||
|
import fcntl, termios, struct, os
|
||||||
|
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
return cr
|
||||||
|
|
||||||
|
def terminal_size(): ### decide on *some* terminal size
|
||||||
|
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) # try open fds
|
||||||
|
if not cr: # ...then ctty
|
||||||
|
try:
|
||||||
|
fd = os.open(os.ctermid(), os.O_RDONLY)
|
||||||
|
cr = ioctl_GWINSZ(fd)
|
||||||
|
os.close(fd)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if not cr: # env vars or finally defaults
|
||||||
|
try:
|
||||||
|
cr = (env['LINES'], env['COLUMNS'])
|
||||||
|
except:
|
||||||
|
cr = (25, 80)
|
||||||
|
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.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)
|
||||||
|
bb = ButtonBar(screen, (("Ok", "ok"), ("Exit", "exit")), compact = 1)
|
||||||
|
|
||||||
|
g = GridForm(screen, "GNU Screen Profiles Menu", 1, 2)
|
||||||
|
g.add(li, 0, 0, padding=(4,2,4,2))
|
||||||
|
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||||
|
|
||||||
|
if bb.buttonPressed(g.runOnce()) == "exit":
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return li.current()
|
||||||
|
|
||||||
|
def messagebox(screen, width, height, title, text, \
|
||||||
|
scroll=0, \
|
||||||
|
buttons=(("Ok", "ok"),("Cancel", "cancel")) ):
|
||||||
|
|
||||||
|
t = Textbox(width, height, text, scroll=scroll )
|
||||||
|
bb = ButtonBar(screen, buttons, compact = 1)
|
||||||
|
g = GridForm(screen, title, 1, 2)
|
||||||
|
g.add(t, 0, 0, padding=(0,0,0,0))
|
||||||
|
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||||
|
|
||||||
|
return bb.buttonPressed(g.runOnce())
|
||||||
|
|
||||||
|
def help(screen, size):
|
||||||
|
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")) )
|
||||||
|
|
||||||
|
if button == "exit":
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return 100
|
||||||
|
|
||||||
|
def profile(screen, size):
|
||||||
|
li = Listbox(height = 6, width = 60, returnExit = 1)
|
||||||
|
|
||||||
|
for choice in commands.getoutput('select-screen-profile -l').splitlines():
|
||||||
|
if choice.startswith("ubuntu"):
|
||||||
|
li.append(choice+" <-- recommended", choice)
|
||||||
|
li.setCurrent(choice)
|
||||||
|
else:
|
||||||
|
li.append(choice, choice)
|
||||||
|
|
||||||
|
bb = ButtonBar(screen, (("Apply", "apply"), ("Cancel", "cancel")), compact = 1)
|
||||||
|
|
||||||
|
g = GridForm(screen, "Which profile would you like to use?", 1, 2)
|
||||||
|
g.add(li, 0, 0, padding=(4,2,4,2))
|
||||||
|
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||||
|
|
||||||
|
if bb.buttonPressed(g.runOnce()) != "cancel":
|
||||||
|
commands.getoutput('select-screen-profile --set %s' % li.current())
|
||||||
|
button = messagebox(screen, 60, 2, "Message", "Press F5<CR> to apply the new profile", \
|
||||||
|
buttons=(("Ok","ok"), ("Exit", "exit")) )
|
||||||
|
if button == "exit":
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return 100
|
||||||
|
|
||||||
|
def newwindow(screen, size):
|
||||||
|
title=Entry(8, text="bash", returnExit=1)
|
||||||
|
titlel=Label("Title: ")
|
||||||
|
command=Entry(20, text="/bin/bash", returnExit=1)
|
||||||
|
commandl=Label("Command: ")
|
||||||
|
|
||||||
|
rl=Label("Presets: ")
|
||||||
|
if len(cmd) > 10:
|
||||||
|
scroll=1
|
||||||
|
size=10
|
||||||
|
else:
|
||||||
|
scroll=0
|
||||||
|
size = len(cmd)
|
||||||
|
|
||||||
|
r=CheckboxTree(size, scroll=scroll)
|
||||||
|
count=0
|
||||||
|
for cur in cmd:
|
||||||
|
r.append(cur[0], count)
|
||||||
|
count=count+1
|
||||||
|
|
||||||
|
bb = ButtonBar(screen, (("Create", "create"), ("Cancel", "cancel")), compact = 1)
|
||||||
|
g = GridForm(screen, "Create new window(s):", 2, 4 )
|
||||||
|
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))
|
||||||
|
|
||||||
|
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]) )
|
||||||
|
else:
|
||||||
|
commands.getoutput('screen -t %s %s' % (title.value(), command.value()) )
|
||||||
|
|
||||||
|
return 100
|
||||||
|
|
||||||
|
def install(screen, size):
|
||||||
|
out = commands.getoutput("bash /usr/share/screen-profiles/screen-install")
|
||||||
|
if out == "":
|
||||||
|
out = "Screen will be launched automatically next time you login."
|
||||||
|
|
||||||
|
button = messagebox(screen, 60, 2, "Message", out, \
|
||||||
|
buttons=(("Ok","ok"), ("Exit", "exit")) )
|
||||||
|
if button == "exit":
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return 100
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""This is the main loop of our screen helper.
|
||||||
|
"""
|
||||||
|
size = terminal_size()
|
||||||
|
screen = SnackScreen()
|
||||||
|
screen.drawRootText(1,0,"== GNU Screen Profiles Helper ==")
|
||||||
|
screen.pushHelpLine("<Tab>/<Alt-Tab> between elements | <Return> Validates")
|
||||||
|
tag = help(screen, size)
|
||||||
|
|
||||||
|
while tag > 0 :
|
||||||
|
tag = menu(screen, size)
|
||||||
|
if tag == 1:
|
||||||
|
tag = help(screen, size)
|
||||||
|
elif tag == 2:
|
||||||
|
tag = profile(screen, size)
|
||||||
|
elif tag == 3:
|
||||||
|
tag = newwindow(screen, size)
|
||||||
|
elif tag == 4:
|
||||||
|
tag = install(screen, size)
|
||||||
|
|
||||||
|
screen.finish()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": main()
|
|
@ -1,25 +1,72 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
#
|
||||||
|
# GNU screen-profiles
|
||||||
|
# Copyright (C) 2008 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# Authors: Dustin Kirklan <dustin.kirkland@ubuntu.com>
|
||||||
|
# Nick Barcet <nick.barcet@ubuntu.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; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
# To generate localization information, run:
|
# To generate localization information, run:
|
||||||
# xgettext -o - -L Shell select-screen-profile
|
# xgettext -o - -L Shell select-screen-profile
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
cat <<EOT
|
||||||
|
usage: select-screen-profiles [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
|
||||||
|
-l,--list list avaivalable profiles
|
||||||
|
-s,--set PROFILE set profile
|
||||||
|
-h,--help this help
|
||||||
|
|
||||||
|
Without any parameters, runs interactively.
|
||||||
|
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"
|
||||||
|
profile=""
|
||||||
|
selected=-1
|
||||||
|
|
||||||
# Ensure that ~/.screenrc-profile is a symbolic link
|
assert_symlink() {
|
||||||
if [ -e "$HOME/.screenrc-profile" ]; then
|
if [ -e "$1" ]; then
|
||||||
if [ ! -L "$HOME/.screenrc-profile" ]; then
|
if [ ! -L "$HOME/.screenrc-profile" ]; then
|
||||||
echo `gettext 'Error:'` $HOME/.screenrc-profile `gettext ' file exists, but is not a symlink'`
|
echo `gettext 'Error:'` $1 `gettext ' file exists, but is not a symlink'`
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Prompt the user to choose among the available profiles
|
# If these files exist, they must be a symlink
|
||||||
echo
|
assert_symlink "$HOME/.screenrc-profile"
|
||||||
echo `gettext "Select a screen profile: "`
|
|
||||||
i=0
|
listprofiles() {
|
||||||
profiles=$(ls $PROFILE_DIR)
|
# Display list of profiles, one per line
|
||||||
for x in $profiles; do
|
for x in $(ls $PROFILE_DIR); do
|
||||||
|
echo "$x"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt() {
|
||||||
|
# Prompt the user to choose among the available profiles
|
||||||
|
echo
|
||||||
|
echo `gettext "Select a screen profile: "`
|
||||||
|
i=0
|
||||||
|
profiles=$(listprofiles)
|
||||||
|
for x in $profiles; do
|
||||||
i=$(expr $i + 1)
|
i=$(expr $i + 1)
|
||||||
desc=" "
|
desc=" "
|
||||||
if [ $x = "ubuntu.screenrc" ]; then
|
if [ $x = "ubuntu.screenrc" ]; then
|
||||||
|
@ -27,10 +74,10 @@ for x in $profiles; do
|
||||||
simple=$i
|
simple=$i
|
||||||
fi
|
fi
|
||||||
echo " $i. $x\t\t$desc"
|
echo " $i. $x\t\t$desc"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
selected=x
|
selected=x
|
||||||
while /bin/true; do
|
while /bin/true; do
|
||||||
if [ -z "$selected" -a ! -z "$simple" ]; then
|
if [ -z "$selected" -a ! -z "$simple" ]; then
|
||||||
selected="$simple"
|
selected="$simple"
|
||||||
elif ! test $selected -gt 0 2>/dev/null; then
|
elif ! test $selected -gt 0 2>/dev/null; then
|
||||||
|
@ -40,18 +87,25 @@ while /bin/true; do
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
SELECTED="$selected"
|
||||||
|
}
|
||||||
|
|
||||||
i=0
|
setprofile() {
|
||||||
for x in $profiles; do
|
# Apply a profile by name or index
|
||||||
|
selected="$SELECTED"
|
||||||
|
i=0
|
||||||
|
found=0
|
||||||
|
profiles=$(listprofiles)
|
||||||
|
for x in $profiles; do
|
||||||
i=`expr $i + 1`
|
i=`expr $i + 1`
|
||||||
if [ $i -eq $selected ]; then
|
if [ "$i" = "$selected" -o "$x" = "$selected" ]; then
|
||||||
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 $HOME/.screenrc-profile" > "$HOME/.screenrc"
|
echo "source $HOME/.screenrc-profile" > "$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
|
||||||
|
@ -63,7 +117,44 @@ for x in $profiles; do
|
||||||
fi
|
fi
|
||||||
rm -f "$HOME/.screenrc-profile"
|
rm -f "$HOME/.screenrc-profile"
|
||||||
ln -s "$PROFILE_DIR/$x" "$HOME/.screenrc-profile"
|
ln -s "$PROFILE_DIR/$x" "$HOME/.screenrc-profile"
|
||||||
|
found=1
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ $found -eq 0 ]; then
|
||||||
|
echo "Invalid profile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
prompt
|
||||||
|
setprofile
|
||||||
|
else
|
||||||
|
TEMP=`getopt -o lhs: --long list,help,set: -- "$@"`
|
||||||
|
eval set -- "$TEMP"
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
-s|--set)
|
||||||
|
profile="$2"
|
||||||
|
setprofile
|
||||||
|
shift 2
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-l|--list)
|
||||||
|
listprofiles
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage()
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
3
windows/common
Normal file
3
windows/common
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default windows
|
||||||
|
#screen -t welcome 0 screen-profiles-helper
|
||||||
|
screen -t shell 1
|
Loading…
Add table
Add a link
Reference in a new issue