mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 05:53:22 -07:00
Add framework for usefull windows creation
This commit is contained in:
parent
f8ad0a7888
commit
4a0769261d
2 changed files with 36 additions and 7 deletions
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -10,6 +10,7 @@ screen-profiles (1.1-0ubuntu1) jaunty; urgency=low
|
|||
* 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 usefull windows creation
|
||||
|
||||
[ Dustin Kirkland ]
|
||||
* created keybindings directory, moved keybindings there
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
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
|
||||
|
@ -50,7 +56,7 @@ 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", 3)
|
||||
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)
|
||||
|
||||
|
@ -106,7 +112,7 @@ def profile(screen, size):
|
|||
|
||||
if bb.buttonPressed(g.runOnce()) != "cancel":
|
||||
commands.getoutput('select-screen-profile --set %s' % li.current())
|
||||
button = messagebox(screen, 60, 2, "Message", "Press F5 to apply the new profile", \
|
||||
button = messagebox(screen, 60, 2, "Message", "Press F5<CR> to apply the new profile", \
|
||||
buttons=(("Ok","ok"), ("Exit", "exit")) )
|
||||
if button == "exit":
|
||||
return 0
|
||||
|
@ -118,15 +124,37 @@ def newwindow(screen, size):
|
|||
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:", 2, 3, )
|
||||
g.add(titlel, 0, 0, anchorLeft=1,padding=(0,1,0,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,padding=(0,0,0,1))
|
||||
g.add(commandl, 0, 1, anchorLeft=1, anchorTop=1,padding=(4,0,0,1))
|
||||
g.add(command, 1, 1, anchorLeft=1)
|
||||
g.add(bb, 0, 2, padding=(1,1,0,0))
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue