mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 05:53:22 -07:00
parent
f78936a278
commit
015f0840cc
3 changed files with 88 additions and 28 deletions
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -6,6 +6,9 @@ screen-profiles (1.6) UNRELEASED; urgency=low
|
|||
* profiles/ubuntu: zero-fill the hour component of the timestamp
|
||||
* bin/updates-available: add some rudimentary caching mechanism for updates,
|
||||
will make screen launch *much* faster on <= Ubuntu 8.10
|
||||
[ Nicolas Barcet ]
|
||||
* Add toggles to fix bugs LP: #315884 and LP: #315885 for help screen and
|
||||
install of screen by defaults
|
||||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Sat, 10 Jan 2009 12:56:02 -0600
|
||||
|
||||
|
|
|
@ -53,13 +53,19 @@ def terminal_size(): ### decide on *some* terminal size
|
|||
cr = (25, 80)
|
||||
return int(cr[1]-5), int(cr[0]-5) # reverse rows, cols
|
||||
|
||||
def menu(screen, size):
|
||||
def menu(screen, size, isInstalled):
|
||||
if isInstalled:
|
||||
installtext="Remove screen by default at login"
|
||||
else:
|
||||
installtext="Install screen by default at login"
|
||||
|
||||
|
||||
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("Manage default windows", 4)
|
||||
li.append("Install screen by default at login", 5)
|
||||
li.append(installtext, 5)
|
||||
bb = ButtonBar(screen, (("Ok", "ok"), ("Exit", "exit")), compact = 1)
|
||||
|
||||
g = GridForm(screen, "GNU Screen Profiles Menu", 1, 2)
|
||||
|
@ -83,7 +89,7 @@ def messagebox(screen, width, height, title, text, \
|
|||
|
||||
return bb.buttonPressed(g.runOnce())
|
||||
|
||||
def help(screen, size, intro=0, config=None):
|
||||
def help(screen, size, config):
|
||||
f=file('/usr/share/doc/screen-profiles/help.txt')
|
||||
text=f.read()
|
||||
f.close()
|
||||
|
@ -91,27 +97,31 @@ def help(screen, size, intro=0, config=None):
|
|||
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)
|
||||
if (config.get('Defaults', 'help') == "on"):
|
||||
cbOn = 1
|
||||
else:
|
||||
formlen=2
|
||||
cbOn = 0
|
||||
|
||||
cb=Checkbox("Display this help on startup", isOn=cbOn)
|
||||
|
||||
g = GridForm(screen, "GNU Screen Profiles Help", 1, formlen)
|
||||
g = GridForm(screen, "GNU Screen Profiles Help", 1, 3)
|
||||
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))
|
||||
g.add(cb, 0, 1, padding=(1,0,0,0))
|
||||
g.add(bb, 0, 2, padding=(1,1,0,0))
|
||||
|
||||
button = bb.buttonPressed(g.runOnce())
|
||||
|
||||
if intro == 1 and not cb.value():
|
||||
if cb.value() != cbOn:
|
||||
#Check box value has change, write config file
|
||||
if not config.has_section('Defaults'):
|
||||
config.add_section('Defaults')
|
||||
config.set('Defaults','help','off')
|
||||
|
||||
if cb.value() == 1:
|
||||
value = "on"
|
||||
else:
|
||||
value = "off"
|
||||
|
||||
config.set('Defaults','help',value)
|
||||
configfile=open(os.getenv("HOME")+'/.screen-profiles-helper', 'wb')
|
||||
try:
|
||||
config.write(configfile)
|
||||
|
@ -277,17 +287,30 @@ def defaultwindows(screen, size):
|
|||
|
||||
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."
|
||||
def install(screen, size, isInstalled):
|
||||
if not isInstalled:
|
||||
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, \
|
||||
button = messagebox(screen, 60, 2, "Message", out, \
|
||||
buttons=(("Ok","ok"), ("Exit", "exit")) )
|
||||
if button == "exit":
|
||||
return 0
|
||||
if button == "exit":
|
||||
return 0
|
||||
|
||||
return 100
|
||||
else:
|
||||
out = commands.getoutput("bash /usr/share/screen-profiles/screen-remove")
|
||||
if out == "":
|
||||
out = "Screen will not be used next time you login."
|
||||
|
||||
button = messagebox(screen, 60, 2, "Message", out, \
|
||||
buttons=(("Ok","ok"), ("Exit", "exit")) )
|
||||
if button == "exit":
|
||||
return 0
|
||||
|
||||
return 101
|
||||
|
||||
return 100
|
||||
|
||||
def main():
|
||||
"""This is the main loop of our screen helper.
|
||||
|
@ -304,15 +327,17 @@ def main():
|
|||
else:
|
||||
showhelp="on"
|
||||
|
||||
if showhelp == "on":
|
||||
tag = help(screen, size, intro=1, config=config)
|
||||
isInstalled = (commands.getoutput('grep screen-launcher '+(os.getenv("HOME")+'/.bashrc')) != "")
|
||||
|
||||
if showhelp == "on" :
|
||||
tag = help(screen, size, config)
|
||||
else:
|
||||
tag = 100
|
||||
|
||||
while tag > 0 :
|
||||
tag = menu(screen, size)
|
||||
tag = menu(screen, size, isInstalled)
|
||||
if tag == 1:
|
||||
tag = help(screen, size)
|
||||
tag = help(screen, size, config)
|
||||
elif tag == 2:
|
||||
tag = profile(screen, size)
|
||||
elif tag == 3:
|
||||
|
@ -320,7 +345,8 @@ def main():
|
|||
elif tag == 4:
|
||||
tag = defaultwindows(screen, size)
|
||||
elif tag == 5:
|
||||
tag = install(screen, size)
|
||||
tag = install(screen, size, isInstalled)
|
||||
isInstalled=(tag == 100)
|
||||
|
||||
screen.finish()
|
||||
sys.exit(0)
|
||||
|
|
31
screen-remove
Executable file
31
screen-remove
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# GNU screen-profiles-helper
|
||||
# Copyright (C) 2008 Canonical Ltd.
|
||||
#
|
||||
# Authors: Nick Barcet <nick.barcet@ubuntu.com>
|
||||
# Dustin Kirkland <kirkland@canonical.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.
|
||||
|
||||
|
||||
remove_screen_launcher() {
|
||||
dest=$1
|
||||
sed -ibak '/screen-launcher/d' "$dest"
|
||||
}
|
||||
|
||||
remove_screen_launcher "$HOME/.bashrc"
|
||||
remove_screen_launcher "$HOME/.bash_profile"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue