Merge lp:~u78qir8a9-deactivatedaccount/do-plugins/screen into lp:do-plugins
- screen
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Alex Launi |
Proposed branch: | lp:~u78qir8a9-deactivatedaccount/do-plugins/screen |
Merge into: | lp:do-plugins |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~u78qir8a9-deactivatedaccount/do-plugins/screen |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Launi (community) | ball-buster style | Needs Fixing | |
Review via email: mp+5680@code.launchpad.net |
This proposal supersedes a proposal from 2009-02-08.
Commit message
Description of the change
X (u78qir8a9-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
Alex Launi (alexlauni) wrote : Posted in a previous version of this proposal | # |
When I enabled this plugin it blocked my console and made me pick 1, 2, or 3. I had never launched screen on my laptop before and I guess this is why, but that's a case that needs considered.
Alex Launi (alexlauni) wrote : Posted in a previous version of this proposal | # |
You know what would make this one of the best Do plugins ever written? The ability to find ssh sessions, and index screen sessions running on remote hosts. How beautiful would that be?
X (u78qir8a9-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
"When I enabled this plugin it blocked my console and made me pick 1, 2, or 3. I had never launched screen on my laptop before and I guess this is why, but that's a case that needs considered."
Whoa ok that sounds bad. What does "pick 1,2, or 3" mean?
I know a plugin as this has many open issues, like
1. default location of the binary (now "screen")
2. configurable permanent arguments(?)
3. how to find the user's terminal app of choice (this hardcoded to "gnome-terminal", I was just looking at other plugins). Perhaps that's one that is simple to sove using Unix.Process..
Alex Launi (alexlauni) wrote : Posted in a previous version of this proposal | # |
On Mon, Feb 9, 2009 at 5:02 AM, Ulrik Sverdrup <email address hidden>wrote:
> Whoa ok that sounds bad. What does "pick 1,2, or 3" mean?
>
I have no idea what it meant! I just chose 1 to get it to unblock...
--
--Alex Launi
Matthew Frizelle (gleebtorin) wrote : Posted in a previous version of this proposal | # |
"You know what would make this one of the best Do plugins ever written? The ability to find ssh sessions, and index screen sessions running on remote hosts. How beautiful would that be?"
That would actually be a pretty awesome idea. As a heavy user of screen, that would be very useful to me :)
X (u78qir8a9-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
2009/2/17 Matthew Frizelle <email address hidden>:
> "You know what would make this one of the best Do plugins ever written? The ability to find ssh sessions, and index screen sessions running on remote hosts. How beautiful would that be?"
>
> That would actually be a pretty awesome idea. As a heavy user of screen, that would be very useful to me :)
> --
> https:/
> You are subscribed to branch lp:~ulrik-sverdrup/do-plugins/screen.
>
Something to hack on when I have time! That would require finding out
which ssh hosts have key authentication, and then "simply" send "ssh
host 'screen -list'" over the network.. I wouldn't do it without the
user's explicit consent (plugin preferences) though. Anyway, that's
for a later time.
So, this thing that happened first time you used the plugin, do we
have to resolve that to merge this? I don't understand at all what
could have happened, but I can try reproducing it somehow.
ulrik
Alex Launi (alexlauni) wrote : | # |
Organize using statements by length, or lexicographically, and separate them logically, all of the System namespaces together, etc.
Make sure you're following mono guidelines for method calls, I see a lot of MethodName(params) when I should be seeing only MethodName (params)
whitespace issues. separate your methods by newlines. Description and LastUpdateTime in NewScreenAction.cs are touching.
There are some weird tabbing issues too, I'm going to blame monodevelop, but it still needs fixed. Make sure oyu're using all tabs, not spaces.
In SupportsModifie
return file == null ? false : Directory.Exists (fitem.Path);
I see you're hardcoding GNOME terminal, there is a GConf key for the users' preferred terminal. This should be respected, and you should launch that.
perform could use breaking up, if not into methods than just use whitespace. Perform is pretty dense, hard to read. One suggestion I've got for this is to declare your variables at the beginning, then assign them later, vs. having declarations littered throughout the method. Obviously this isn't true for small scoped variables.
These comments pretty much hold for the rest of the merge.
Alex Launi (alexlauni) wrote : | # |
ping? This is a cool plugin, if you just fix these couple of issues we can merge!
Alex Launi (alexlauni) wrote : | # |
Rejecting due to abandonment
Unmerged revisions
- 523. By X
-
New Plugin: GNU Screen
This is a plugin for Gnome Do to work with GNU Screen sessions. GNU Screen
(command 'screen') is a command line application for managing multi-windowed
shell sessions that can be detached and reattached for persistency, and offers
much configurability.This adds the Plugin directory ./GNUScreen, and adds the plugin to monodevelop
as well as to the autotools setup.This is the Plugin code as provided in gitorious revision 2fd1c03b at
screen-plugin- gnome-do/ mainline
Preview Diff
1 | === modified file 'DoPlugins.mds' |
2 | --- DoPlugins.mds 2009-02-01 04:00:44 +0000 |
3 | +++ DoPlugins.mds 2009-02-08 17:28:11 +0000 |
4 | @@ -68,6 +68,7 @@ |
5 | <Entry build="True" name="xmms2" configuration="Debug" /> |
6 | <Entry build="True" name="TinyUrl" configuration="Debug" /> |
7 | <Entry build="True" name="Tracker" configuration="Debug" /> |
8 | + <Entry build="True" name="GNUScreen" configuration="Debug" /> |
9 | </Configuration> |
10 | <Configuration name="Release" ctype="CombineConfiguration"> |
11 | <Entry build="True" name="Rhythmbox" configuration="Release" /> |
12 | @@ -137,6 +138,7 @@ |
13 | <Entry build="True" name="xmms2" configuration="Release" /> |
14 | <Entry build="True" name="TinyUrl" configuration="Release" /> |
15 | <Entry build="True" name="Tracker" configuration="Release" /> |
16 | + <Entry build="True" name="GNUScreen" configuration="Release" /> |
17 | </Configuration> |
18 | </Configurations> |
19 | <StartMode startupentry="Rhythmbox" single="True"> |
20 | @@ -207,6 +209,7 @@ |
21 | <Execute type="None" entry="xmms2" /> |
22 | <Execute type="None" entry="TinyUrl" /> |
23 | <Execute type="None" entry="Tracker" /> |
24 | + <Execute type="None" entry="GNUScreen" /> |
25 | </StartMode> |
26 | <MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" /> |
27 | <Entries> |
28 | @@ -277,5 +280,6 @@ |
29 | <Entry filename="Xmms2/xmms2.mdp" /> |
30 | <Entry filename="TinyUrl/TinyUrl.mdp" /> |
31 | <Entry filename="Tracker/Tracker.mdp" /> |
32 | + <Entry filename="GNUScreen/GNUScreen.mdp" /> |
33 | </Entries> |
34 | </Combine> |
35 | \ No newline at end of file |
36 | |
37 | === added directory 'GNUScreen' |
38 | === added file 'GNUScreen/GNUScreen.mdp' |
39 | --- GNUScreen/GNUScreen.mdp 1970-01-01 00:00:00 +0000 |
40 | +++ GNUScreen/GNUScreen.mdp 2009-02-08 17:28:11 +0000 |
41 | @@ -0,0 +1,30 @@ |
42 | +<Project name="GNUScreen" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> |
43 | + <Configurations active="Debug"> |
44 | + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> |
45 | + <Output directory="bin/Debug" assembly="GNUScreen" /> |
46 | + <Build debugmode="True" target="Library" /> |
47 | + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> |
48 | + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> |
49 | + </Configuration> |
50 | + <Configuration name="Release" ctype="DotNetProjectConfiguration"> |
51 | + <Output directory="bin/Release" assembly="GNUScreen" /> |
52 | + <Build debugmode="False" target="Library" /> |
53 | + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> |
54 | + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> |
55 | + </Configuration> |
56 | + </Configurations> |
57 | + <Contents> |
58 | + <File name="." subtype="Directory" buildaction="Compile" /> |
59 | + <File name="Resources/GNUScreen.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> |
60 | + <File name="src/NewScreenAction.cs" subtype="Code" buildaction="Compile" /> |
61 | + <File name="src/ScreenAction.cs" subtype="Code" buildaction="Compile" /> |
62 | + <File name="src/ScreenSessions.cs" subtype="Code" buildaction="Compile" /> |
63 | + </Contents> |
64 | + <References> |
65 | + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
66 | + <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" /> |
67 | + <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.8.0.0, Culture=neutral, PublicKeyToken=null" /> |
68 | + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> |
69 | + <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
70 | + </References> |
71 | +</Project> |
72 | \ No newline at end of file |
73 | |
74 | === added file 'GNUScreen/Makefile.am' |
75 | --- GNUScreen/Makefile.am 1970-01-01 00:00:00 +0000 |
76 | +++ GNUScreen/Makefile.am 2009-02-08 17:28:11 +0000 |
77 | @@ -0,0 +1,18 @@ |
78 | +include $(top_srcdir)/build.rules.mk |
79 | + |
80 | +ASSEMBLY=GNUScreen |
81 | + |
82 | +FILES = \ |
83 | + src/NewScreenAction.cs \ |
84 | + src/ScreenAction.cs \ |
85 | + src/ScreenSessions.cs |
86 | + |
87 | +RESOURCES = \ |
88 | + Resources/GNUScreen.addin.xml |
89 | + |
90 | +REFERENCES = \ |
91 | + Mono.Posix \ |
92 | + System \ |
93 | + System.Core \ |
94 | + $(DO_PLATFORM_LIBS) \ |
95 | + $(DO_UNIVERSE_LIBS) |
96 | |
97 | === added directory 'GNUScreen/Resources' |
98 | === added file 'GNUScreen/Resources/GNUScreen.addin.xml' |
99 | --- GNUScreen/Resources/GNUScreen.addin.xml 1970-01-01 00:00:00 +0000 |
100 | +++ GNUScreen/Resources/GNUScreen.addin.xml 2009-02-08 17:28:11 +0000 |
101 | @@ -0,0 +1,27 @@ |
102 | +<Addin |
103 | + id="GNUScreen" |
104 | + namespace="Do" |
105 | + version="1.0" |
106 | + name="GNU Screen" |
107 | + description="Work with GNU Screen sessions" |
108 | + author="Ulrik Sverdrup" |
109 | + category="Community" |
110 | + > |
111 | + |
112 | + <Runtime> |
113 | + <Import assembly="GNUScreen.dll"/> |
114 | + </Runtime> |
115 | + |
116 | + <Dependencies> |
117 | + <Addin id="Universe" version="1.0" /> |
118 | + </Dependencies> |
119 | + |
120 | + <Extension path = "/Do/ItemSource"> |
121 | + <ItemSource type="GnomeDoScreen.ScreenSessionItemSource" /> |
122 | + </Extension> |
123 | + <Extension path = "/Do/Action"> |
124 | + <Action type="GnomeDoScreen.AttachScreenAction" /> |
125 | + <Action type="GnomeDoScreen.NewScreenAction" /> |
126 | + <Action type="GnomeDoScreen.ScreenCommandAction" /> |
127 | + </Extension> |
128 | +</Addin> |
129 | |
130 | === added directory 'GNUScreen/src' |
131 | === added file 'GNUScreen/src/NewScreenAction.cs' |
132 | --- GNUScreen/src/NewScreenAction.cs 1970-01-01 00:00:00 +0000 |
133 | +++ GNUScreen/src/NewScreenAction.cs 2009-02-08 17:28:11 +0000 |
134 | @@ -0,0 +1,110 @@ |
135 | +/* NewScreenAction.cs |
136 | + * |
137 | + * GNOME Do is the legal property of its developers. Please refer to the |
138 | + * COPYRIGHT file distributed with this |
139 | + * source distribution. |
140 | + * |
141 | + * This program is free software: you can redistribute it and/or modify |
142 | + * it under the terms of the GNU General Public License as published by |
143 | + * the Free Software Foundation, either version 3 of the License, or |
144 | + * (at your option) any later version. |
145 | + * |
146 | + * This program is distributed in the hope that it will be useful, |
147 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
148 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
149 | + * GNU General Public License for more details. |
150 | + * |
151 | + * You should have received a copy of the GNU General Public License |
152 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
153 | + */ |
154 | + |
155 | +using System; |
156 | +using System.Collections.Generic; |
157 | +using System.Linq; |
158 | +using System.IO; |
159 | +using Do.Universe; |
160 | +using Do.Platform; |
161 | +using System.Diagnostics; |
162 | + |
163 | +using Mono.Unix; |
164 | + |
165 | +namespace GnomeDoScreen { |
166 | + public class NewScreenAction : Act { |
167 | + |
168 | + public override string Name { |
169 | + get { |
170 | + return Catalog.GetString("New Screen session"); |
171 | + } |
172 | + } |
173 | + |
174 | + public override string Description { |
175 | + get { |
176 | + return Catalog.GetString("Create a new GNU Screen session"); |
177 | + } |
178 | + } |
179 | + public DateTime LastUpdateTime { get; private set;} |
180 | + |
181 | + public override string Icon { |
182 | + get { |
183 | + return "terminal"; |
184 | + } |
185 | + } |
186 | + |
187 | + public override IEnumerable<Type> SupportedItemTypes { |
188 | + get { |
189 | + yield return typeof(ITextItem); |
190 | + } |
191 | + } |
192 | + |
193 | + public override bool SupportsItem (Item item) { |
194 | + return true; |
195 | + } |
196 | + |
197 | + /* Support directory as optional |
198 | + */ |
199 | + public override IEnumerable<Type> SupportedModifierItemTypes { |
200 | + get { yield return typeof(IFileItem); } |
201 | + } |
202 | + |
203 | + public override bool ModifierItemsOptional { |
204 | + get { return true; } |
205 | + } |
206 | + public override bool SupportsModifierItemForItems (IEnumerable<Item> items, Item modItem) |
207 | + { |
208 | + IFileItem fitem = modItem as IFileItem; |
209 | + bool exists = Directory.Exists(fitem.Path); |
210 | + return exists; |
211 | + } |
212 | + |
213 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) { |
214 | + string exec = "gnome-terminal"; |
215 | + |
216 | + string sessionname = ""; |
217 | + if (items.First () is ITextItem) { |
218 | + ITextItem textitem = items.First () as ITextItem; |
219 | + sessionname = textitem.Text.Trim(); |
220 | + } |
221 | + string workdir = null; |
222 | + if (modItems.Count() > 0 && modItems.First() is IFileItem) { |
223 | + string path = (modItems.First() as IFileItem).Path; |
224 | + /* Check if it is an existing directory |
225 | + */ |
226 | + if (Directory.Exists(path)) |
227 | + workdir = path; |
228 | + } |
229 | + Process term = new Process (); |
230 | + term.StartInfo.FileName = exec; |
231 | + string sessionarg = "", titlearg = ""; |
232 | + if (sessionname != "") |
233 | + sessionarg = "-S '" + sessionname + "'"; |
234 | + if (sessionname != "") |
235 | + titlearg = String.Format("--title='{0}'", sessionname); |
236 | + term.StartInfo.Arguments = String.Format("{0} -x screen {1}", titlearg, sessionarg); |
237 | + if (workdir != null) |
238 | + term.StartInfo.WorkingDirectory = workdir; |
239 | + Log<NewScreenAction>.Debug(term.StartInfo.Arguments); |
240 | + term.Start (); |
241 | + return null; |
242 | + } |
243 | + } |
244 | +} |
245 | |
246 | === added file 'GNUScreen/src/ScreenAction.cs' |
247 | --- GNUScreen/src/ScreenAction.cs 1970-01-01 00:00:00 +0000 |
248 | +++ GNUScreen/src/ScreenAction.cs 2009-02-08 17:28:11 +0000 |
249 | @@ -0,0 +1,209 @@ |
250 | +/* ScreenAction.cs |
251 | + * |
252 | + * GNOME Do is the legal property of its developers. Please refer to the |
253 | + * COPYRIGHT file distributed with this |
254 | + * source distribution. |
255 | + * |
256 | + * This program is free software: you can redistribute it and/or modify |
257 | + * it under the terms of the GNU General Public License as published by |
258 | + * the Free Software Foundation, either version 3 of the License, or |
259 | + * (at your option) any later version. |
260 | + * |
261 | + * This program is distributed in the hope that it will be useful, |
262 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
263 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
264 | + * GNU General Public License for more details. |
265 | + * |
266 | + * You should have received a copy of the GNU General Public License |
267 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
268 | + */ |
269 | + |
270 | +using System; |
271 | +using System.Collections.Generic; |
272 | +using System.Linq; |
273 | +using Do.Universe; |
274 | +using Do.Platform; |
275 | +using System.Diagnostics; |
276 | + |
277 | +using Mono.Unix; |
278 | + |
279 | +namespace GnomeDoScreen { |
280 | + public class AbstractScreenAction : Act { |
281 | + static ScreenSessionItemSource source_cache = null; |
282 | + public override string Name { |
283 | + get { return "AbstractScreenAction"; } |
284 | + } |
285 | + |
286 | + public override string Description { |
287 | + get { return "Base class"; } |
288 | + } |
289 | + |
290 | + public override string Icon { |
291 | + get { |
292 | + return "terminal"; |
293 | + } |
294 | + } |
295 | + |
296 | + public override IEnumerable<Type> SupportedItemTypes { |
297 | + get { |
298 | + return new Type[] { |
299 | + typeof(ITextItem), |
300 | + typeof(ScreenSessionItem), |
301 | + }; |
302 | + } |
303 | + } |
304 | + |
305 | + public static DateTime LastUpdateTime { get; private set;} |
306 | + |
307 | + private static void UpdateCacheIfOld(int wait) { |
308 | + /* Wait before update */ |
309 | + TimeSpan update_interval = new TimeSpan(0,0,wait); |
310 | + if ((DateTime.UtcNow - LastUpdateTime) > update_interval ) { |
311 | + source_cache.UpdateItems(); |
312 | + LastUpdateTime = DateTime.UtcNow; |
313 | + } |
314 | + } |
315 | + |
316 | + private static bool TextMatchesItem(string text, ScreenSessionItem item) { |
317 | + if (item == null) |
318 | + return false; |
319 | + string pid = item.Pid; |
320 | + string name = item.SessionName; |
321 | + if (name.StartsWith(text) || pid.StartsWith(text)) |
322 | + return true; |
323 | + return false;; |
324 | + } |
325 | + |
326 | + public override bool SupportsItem (Item item) { |
327 | + if (item is ScreenSessionItem) { |
328 | + /* If it's a SSI, it should be updated from |
329 | + * the source side |
330 | + */ |
331 | + return true; |
332 | + } else if (item is ITextItem) { |
333 | + ITextItem titem = item as ITextItem; |
334 | + /* Check if the given text |
335 | + * matches the beginning of the |
336 | + * _pid_ or _tty name_ of any running |
337 | + * session |
338 | + */ |
339 | + /* Wait shorter time for text items */ |
340 | + if (source_cache == null) |
341 | + source_cache = new ScreenSessionItemSource(); |
342 | + UpdateCacheIfOld(15); |
343 | + foreach (Item it in source_cache.Items) { |
344 | + ScreenSessionItem ssitem = it as ScreenSessionItem; |
345 | + if (this.TextMatchesItem(titem.Text, ssitem)) { |
346 | + return true; |
347 | + } |
348 | + } |
349 | + } |
350 | + return false; |
351 | + } |
352 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) { |
353 | + return null; |
354 | + } |
355 | + |
356 | + public static void SpawnScreenSession(string name, string arguments) { |
357 | + string term = "gnome-terminal"; |
358 | + ProcessStartInfo ps = new ProcessStartInfo (term); |
359 | + string term_arguments = ""; |
360 | + if (name != "") |
361 | + term_arguments += "--title='" + name + "' "; |
362 | + term_arguments += "-x screen "; |
363 | + if (arguments != "") |
364 | + term_arguments += arguments; |
365 | + ps.Arguments = term_arguments; |
366 | + using (Process p = Process.Start (ps)) { |
367 | + Log<AbstractScreenAction>.Debug(ps.Arguments); |
368 | + } |
369 | + } |
370 | + |
371 | + public static void RunScreen(string arguments) { |
372 | + string term = "screen"; |
373 | + ProcessStartInfo ps = new ProcessStartInfo (term); |
374 | + ps.UseShellExecute = false; |
375 | + ps.Arguments = arguments; |
376 | + using (Process p = Process.Start (ps)) { |
377 | + Log<ScreenCommandAction>.Debug(ps.Arguments); |
378 | + } |
379 | + } |
380 | + } |
381 | + |
382 | + public class AttachScreenAction : AbstractScreenAction { |
383 | + |
384 | + public override string Name { |
385 | + get { |
386 | + return Catalog.GetString("Attach"); |
387 | + } |
388 | + } |
389 | + |
390 | + public override string Description { |
391 | + get { |
392 | + return Catalog.GetString("Attach or reattach a running GNU Screen session"); |
393 | + } |
394 | + } |
395 | + |
396 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) { |
397 | + string screenname = null; |
398 | + string termname = ""; |
399 | + if (items.First () is ITextItem) { |
400 | + ITextItem textitem = items.First () as ITextItem; |
401 | + screenname = textitem.Text; |
402 | + } else if (items.First () is ScreenSessionItem) { |
403 | + ScreenSessionItem sitem = items.First () as ScreenSessionItem; |
404 | + /* Attach with Pid, because it is always correct, |
405 | + * the session name can change! */ |
406 | + screenname = sitem.Pid; |
407 | + termname = sitem.Name; |
408 | + } |
409 | + if (screenname != null) { |
410 | + SpawnScreenSession(termname, "-x -R " + screenname); |
411 | + } |
412 | + return null; |
413 | + } |
414 | + |
415 | + } |
416 | + |
417 | + public class ScreenCommandAction : AbstractScreenAction { |
418 | + public override string Name { |
419 | + get { |
420 | + return Catalog.GetString("Send command"); |
421 | + } |
422 | + } |
423 | + |
424 | + public override string Description { |
425 | + get { |
426 | + return Catalog.GetString("Send a command to a running GNU Screen session"); |
427 | + } |
428 | + } |
429 | + public override string Icon { |
430 | + get { return "gtk-execute"; } |
431 | + } |
432 | + |
433 | + public override IEnumerable<Type> SupportedModifierItemTypes { |
434 | + get { yield return typeof(ITextItem); } |
435 | + } |
436 | + |
437 | + public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) { |
438 | + string screenname = null; |
439 | + string command = null; |
440 | + if (items.First () is ITextItem) { |
441 | + ITextItem textitem = items.First () as ITextItem; |
442 | + screenname = textitem.Text.Trim(); |
443 | + } else if (items.First () is ScreenSessionItem) { |
444 | + ScreenSessionItem sitem = items.First () as ScreenSessionItem; |
445 | + /* Use with Pid, because it is always correct, |
446 | + * the session name can change! */ |
447 | + screenname = sitem.Pid; |
448 | + } |
449 | + if (modItems.First() is ITextItem) { |
450 | + command = (modItems.First() as ITextItem).Text; |
451 | + } |
452 | + if (screenname != null && command != null) { |
453 | + RunScreen("-S " + screenname + " -X " + command); |
454 | + } |
455 | + return null; |
456 | + } |
457 | + } |
458 | +} |
459 | |
460 | === added file 'GNUScreen/src/ScreenSessions.cs' |
461 | --- GNUScreen/src/ScreenSessions.cs 1970-01-01 00:00:00 +0000 |
462 | +++ GNUScreen/src/ScreenSessions.cs 2009-02-08 17:28:11 +0000 |
463 | @@ -0,0 +1,152 @@ |
464 | +/* ScreenSessions.cs |
465 | + * |
466 | + * GNOME Do is the legal property of its developers. Please refer to the |
467 | + * COPYRIGHT file distributed with this |
468 | + * source distribution. |
469 | + * |
470 | + * This program is free software: you can redistribute it and/or modify |
471 | + * it under the terms of the GNU General Public License as published by |
472 | + * the Free Software Foundation, either version 3 of the License, or |
473 | + * (at your option) any later version. |
474 | + * |
475 | + * This program is distributed in the hope that it will be useful, |
476 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
477 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
478 | + * GNU General Public License for more details. |
479 | + * |
480 | + * You should have received a copy of the GNU General Public License |
481 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
482 | + */ |
483 | + |
484 | +using System; |
485 | +using System.IO; |
486 | +using System.Collections.Generic; |
487 | +using System.Text.RegularExpressions; |
488 | +using System.Diagnostics; |
489 | + |
490 | +using Do.Platform; |
491 | +using Do.Universe; |
492 | + |
493 | +using Mono.Unix; |
494 | + |
495 | + |
496 | +namespace GnomeDoScreen { |
497 | + |
498 | + public class ScreenSessionItem : Item { |
499 | + string pid, sessionname, name, status, date; |
500 | + |
501 | + public ScreenSessionItem (string ipid, string iname, string istatus, string idate) |
502 | + { |
503 | + sessionname = iname; |
504 | + status = istatus; |
505 | + date = idate; |
506 | + |
507 | + /* Pid used to identify the session */ |
508 | + pid = ipid; |
509 | + /* Display name */ |
510 | + name = String.Format("{0} ({1})", sessionname, pid); |
511 | + } |
512 | + |
513 | + public override string Name { get { return name; } } |
514 | + public override string Description { |
515 | + get { |
516 | + return status + " GNU Screen session, created " + date; |
517 | + } |
518 | + } |
519 | + public override string Icon { get { return "gnome-window-manager"; } } |
520 | + |
521 | + public string Pid { get { return pid; } } |
522 | + public string SessionName { get { return sessionname; } } |
523 | + } |
524 | + |
525 | + public class ScreenSessionItemSource : ItemSource { |
526 | + List<Item> items; |
527 | + |
528 | + public ScreenSessionItemSource () |
529 | + { |
530 | + items = new List<Item> (); |
531 | + UpdateItems (); |
532 | + } |
533 | + |
534 | + public override string Name { get { return Catalog.GetString("Screen sessions"); } } |
535 | + public override string Description { get { return Catalog.GetString("Lists running GNU Screen sessions"); } } |
536 | + public override string Icon { get { return "terminal"; } } |
537 | + |
538 | + public override IEnumerable<Type> SupportedItemTypes { |
539 | + get { |
540 | + yield return typeof (ScreenSessionItem); |
541 | + } |
542 | + } |
543 | + |
544 | + public override IEnumerable<Item> Items { |
545 | + get { |
546 | + return items; |
547 | + } |
548 | + } |
549 | + |
550 | + public override IEnumerable<Item> ChildrenOfItem (Item parent) |
551 | + { |
552 | + yield break; |
553 | + } |
554 | + |
555 | + public override void UpdateItems () |
556 | + { |
557 | + items.Clear (); |
558 | + Log<ScreenSessionItemSource>.Debug(" updating items.."); |
559 | + |
560 | + try { |
561 | + // sets up our process, the first argument is the command |
562 | + // and the second holds the arguments passed to the command |
563 | + ProcessStartInfo ps = new ProcessStartInfo ("screen", "-list"); |
564 | + ps.UseShellExecute = false; |
565 | + // we need to redirect the standard output so we read it |
566 | + // internally in out program |
567 | + ps.RedirectStandardOutput = true; |
568 | + |
569 | + // starts the process |
570 | + string output = null; |
571 | + using (Process p = Process.Start (ps)) { |
572 | + // we read the output to a string |
573 | + output = p.StandardOutput.ReadToEnd (); |
574 | + // waits for the process to exit |
575 | + p.WaitForExit (); |
576 | + } |
577 | + if (output == null) |
578 | + return; |
579 | + |
580 | + StringReader reader = new StringReader (output); |
581 | + |
582 | + Regex r = new Regex ("^\\t([^\\t]+)\\t\\((.*)\\)\\t\\((.*)\\)$"); |
583 | + Regex pidtty= new Regex ("^([0-9]+)\\.(.*)"); |
584 | + |
585 | + string s; |
586 | + /* Group matches: |
587 | + * Groups[0] is the whole string that matched |
588 | + * and [1] and so on are the () groups one by one |
589 | + */ |
590 | + while ((s = reader.ReadLine ()) != null) { |
591 | + Match m = r.Match (s); |
592 | + if (m.Groups.Count == 4) { |
593 | + string fullname, status, date; |
594 | + fullname = m.Groups[1].ToString(); |
595 | + date = m.Groups[2].ToString(); |
596 | + status = m.Groups[3].ToString(); |
597 | + /* Part the pid.tty.host into pid and tty |
598 | + */ |
599 | + Match ptm = pidtty.Match(fullname); |
600 | + string pid, name; |
601 | + if (ptm.Groups.Count == 3) { |
602 | + pid = ptm.Groups[1].ToString(); |
603 | + name = ptm.Groups[2].ToString(); |
604 | + items.Add (new ScreenSessionItem (pid, name, status, date)); |
605 | + } else { |
606 | + /* Best to report matching error */ |
607 | + Log<ScreenSessionItemSource>.Debug("Unable to parse " + s); |
608 | + } |
609 | + } |
610 | + } |
611 | + } catch { } |
612 | + } |
613 | + } |
614 | +} |
615 | + |
616 | |
617 | === modified file 'Makefile.am' |
618 | --- Makefile.am 2009-01-30 00:17:43 +0000 |
619 | +++ Makefile.am 2009-02-08 17:28:11 +0000 |
620 | @@ -30,6 +30,7 @@ |
621 | GoogleDocs \ |
622 | GoogleMaps \ |
623 | GoogleSearch \ |
624 | + GNUScreen \ |
625 | ImageShack \ |
626 | JIRA \ |
627 | Launchpad \ |
628 | |
629 | === modified file 'configure.ac' |
630 | --- configure.ac 2009-01-29 20:26:24 +0000 |
631 | +++ configure.ac 2009-02-08 17:28:11 +0000 |
632 | @@ -135,6 +135,7 @@ |
633 | GoogleDocs/Makefile |
634 | GoogleMaps/Makefile |
635 | GoogleSearch/Makefile |
636 | +GNUScreen/Makefile |
637 | ImageShack/Makefile |
638 | JIRA/Makefile |
639 | Launchpad/Makefile |
New Plugin: GNU Screen
This is a plugin for Gnome Do to work with GNU Screen sessions. GNU Screen
(command 'screen') is a command line application for managing multi-windowed
shell sessions that can be detached and reattached for persistency, and offers
much configurability.
This adds the Plugin directory ./GNUScreen, and adds the plugin to monodevelop
as well as to the autotools setup.
This is the Plugin code as provided in gitorious revision 2fd1c03b at plugin- gnome-do/ mainline
screen-
http:// gitorious. org/projects/ screen- plugin- gnome-do