How to show in GNU Screen hardstatus tabs that have an activity? - zsh

Each time I have more than 4 tabs, I really like to know in which one there's activity.
Until now, I used to benefit from rxvt tabbing system. It displays a * next to tabs which are not shown, but have an activity. It's really usefull when you're on a IRC channel for example.
How can I do it with zsh/screen ?
Here's my .zshrc :
function precmd {
echo -ne "\033]83;title zsh\007"
}
function preexec {
local foo="$2 "
local bar=${${=foo}[1]}
echo -ne "\033]83;title $bar\007"
}
and my .screenrc
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W} %c %{g}]'
[...]
shell "/usr/bin/zsh"
aclchg :window: -rwx #?
aclchg :window: +x title

This is documented in the manual:
monitor [on|off]
Toggles activity monitoring of windows. When monitoring is
turned on and an affected window is switched into the background,
you will receive the activity notification message in the status
line at the first sign of output and the window will also be
marked with an `#' in the window-status display. Monitoring is
initially off for all windows.
You can manually toggle monitoring for the current window via C-a M, or if you want monitoring on for all windows by default, add defmonitor on to your screenrc. Once on, any windows to the left or right of the current one in your hardstatus line (as expanded by %-Lw and %+Lw respectively in your hardstatus string line) will show an # symbol after the hyphen which follows the window number. You'll also get an alert message which can be configured via the activity command.
On my system, the # doesn't appear until something else in the window changes. This can be fixed by removing hardstatus off from your config file.
Finally, I strongly recommend that you try tmux. Development on GNU screen has mostly stalled, and tmux is an actively maintained and developed replacement which has pretty much a large superset of screen's functionality.

Related

Kernel cancelling a `input_request` at the end of the execution of a cell

I'm implementing a new Go kernel, using directly the ZMQ messages. But as an extra I want it to execute any bash command when a line is prefixed with !, similar to the usual ipython kernel.
One of the tricky parts seems to be bash scripts that take input -- there is no way (that I know of) to predict when I need to request input. So I took the following approach:
Whenever I execute a bash script, if it hasn't ended after 500ms (configurable), it issues an input_request.
If the kernel receives any input back (input_reply message), it writes the contents to the bash program's piped stdin (concurrently, not to block), and immediately issues another input_request.
Now at the end of the execution of the bash program, there is always the last input_request pending, and the corresponding widget expecting input from the user.
Jupyter doesn't drop the input_request after the execution of the cell ended, and requires the user to type enter and send an input_reply before another cell can be executed. It complains with "Cell not executed due to pending input"
Is there a way to cancel the input_request (the pending input) if the execution of the last cell already finished ?
Maybe there is some undocumented message that can be send once the bash program ends ?
Any other suggested approach ?
I know something similar works in colab.research.google.com, if I do:
!while read ii; do if [[ "${ii}" == "done" ]] ; then exit 0; fi ; echo "Input: $ii"; done
It correctly asks for inputs, and closes the last one.
But I'm not sure how that is achieved.
Jupyter's ipython notebook doesn't seem to have that smarts though, at least here the line above just locks. I suppose it never sends a input_request message.
many thanks in advance!

How to use one key-binding to spawn tag-specific program in awesome-wm?

Introduction:
In my wrokflow, I am using tags for specific purposes (WEB, IDE, EMAIL, File Manager,>Terminal/Taskwarrior-tui/Timewarrior) and I want to stick to this. So whenever I go to tag 1 I want to have a browser there.
Problem: I would like to minimize the number of key bindings for the most important programs.
Question: How can I use one keybinding for launching a "default program for the tag"??
Example: Let's say that I am currently on tag 1 (called WEB) which default application would be qutebrowser (at least in my case) so I would like to hit MOD+D to spawn qutebrowser. But when I hit the same keybinding (MOD+D) on tag 2 i want awesome-wm to spawn Rstudio.
Note that I am not asking how to make a rule of spawning a certain program on specific tag (with a keybinding assigned to spawning this program) as there are a lot of answers to that around the web. I want to have conditional rule, based on which tag is active, to spawn a predefined app in this tag with one keybinding.
awful.keyboard.append_global_keybindings({
awful.key({ modkey }, "d", function()
local t = awful.screen.focused().selected_tag
if t.name == "WEB" then
-- launch qutebrowser
elseif t.name == "tag 2 name" then
-- launch Rstudio
end
end,
{description = "description", group = "group"})
})

Why does Progress go back to the initial screen after a session crash?

Hello all and thanks for viewing this question,
I have a program that users get access to via a login screen. Once the user's credentials have been validated on the login screen, the main program is called (from the login screen) and the login screen disappears. All good. However, if the session crashes (or I press CTRL-PAUSE), the main program is terminated and I end up at the initial login screen. I'd have assumed that after a session crash, Progress (11.4) should take me back to the OS (Windows Server 2012), but not back to the initial screen. I have tried placing QUIT in different areas of the program, but Progress still takes me back to the initial screen, while I need it to quit completely. Any thoughts would be greatly appreciated. Thanks!
It's the AVM's default behavior to rerun the startup procedure after a STOP condition has occurred that was not handled.
You can add an
ON STOP UNDO, RETURN "stopped" .
option to a DO, FOR or REPEAT block close where your "crash" happens. Then the calling procedure could check for the RETURN-VALUE of "stopped".
Assuming you are on a recent version (OpenEdge 12.x), you can also use CATCH Blocks for Progress.Lang.Stop:
CATCH stopcon AS Progress.Lang.Stop:
QUIT.
END CATCH.
I think that your use of the word "crashed" is very, very confusing. If your session actually "crashes" in the usual sense that _progres (or prowin if this is Windows) terminates, then you would not have any locked records remaining. You would also have a protrace file that would help you to identify where the issue occurs.
Incidentally, you could add error logging to the client startup to determine where the errors that QXtend cannot find are occurring:
_progres dbname -p startup.p -clientlog logname.log
You have not shared any code so I can only guess but, presumably, you are running your login program via the -p startup parameter.
Correct me if I am wrong but something along these lines:
_progres dbname -p startup.p
The startup program then runs whatever it runs to get you logged in and run the application. Maybe something like this:
/* startup.p
*/
message "(re)starting!".
pause.
run value( "login.p" ).
run value( "stuff.p" ).
message "all done".
pause.
quit.
And:
/* login.p
*/
message "hello, logging in!".
pause.
return.
Along with:
/* stuff.p
*/
message "hello, doing stuff!".
pause.
run value( "notthere.p" ).
message "hello, doing more stuff!".
pause.
return.
At some point an error occurs (you seem to want to call this a "crash"). I have arranged for a serious error to occur when stuff.p tries to "run notthere.p". So if you run my example you will see the behavior that you have described - your session "crashes", the startup procedure re-runs, and you get to the login screen again.
To change that and trap the error simply wrap a "DO ON STOP" around the RUN statements. Like this:
/* startup.p
*/
message "(re)starting!".
pause.
do on error undo, leave
on endkey undo, leave
on stop undo, leave
on quit undo, leave: /* "leave", exits this block when one of the named conditions arises */
run value( "login.p" ).
run value( "stuff.p" ).
/* we just leave because we finished normally */
end.
message "all done".
pause.
quit.
You mention QXtend so I am guessing that MFG/Pro is involved. If you cannot directly modify the MFG/Pro startup procedure (as I recall that would be "-p mfg.p") just adapt the code above to be a "shim" that runs mfg.p from within the "DO ON STOP..." block.
I believe I have found a way to quit the initial login screen when this appears as the result of a session crash, by using the the ETIME function. Thanks again, Mike for your response.

Example use case of tmux's "refresh-client"?

From the man page (http://manpages.ubuntu.com/manpages/precise/en/man1/tmux.1.html):
refresh-client [-S] [-t target-client]
(alias: refresh)
Refresh the current client if bound to a key, or a single client
if one is given with -t. If -S is specified, only update the
client's status bar.
What does it mean for a client to be bound to a key? I'm trying to think of when I may actually use this.
This is by default bound to "r" in tmux, and I'm thinking of overriding it. Could someone explain an example use case for wanting to refresh the client? Thanks.
tmux only updates the screen when there is some new content to display. If you put something like date into your status line, the date will only update when the content of the pane changes, when you change between panes, or when run refresh-client. So in that case, you could use Ctrl-b r to refresh the screen.
Alternatively, you can also set set status-interval 1 to redraw every second, but that will cause CPU usage and drain your battery.
If you don't have anything dynamic in your status line, you can safely remap the key. And if you ever need to execute refresh-client, you can still run it with tmux refresh-client.

Asterisk: Record application is generating empty files

User making the call is asked to dial an extension. This is done by 1#playing a prompt with Background and then 2#wait_for_digit. Based on the extension that has been dialed, the destination number is determined and the call is forwarded to that number.
If the called person doesn't not answer, then Playback is used to play a prompt that asks the user to record the voice message; recording the voice message is done with the Record application.
This Record application is always generating empty wav files, size 44 bytes. If I remove the 1#playing a prompt with Background the Record application is generating proper files. If the Background is included, all recordings are empty.
I am using Perl Asterisk::AGI module.
$agi->exec('Answer');
....
.....
$agi->exec('Background', 'en/extra/please-enter-the-extension,n'); # this is the troubling part
my $my_extension = $agi->wait_for_digit(5000);
....
.....
$agi->exec('Playback', 'en/extra/the-party-you-are-calling&en/extra/is-curntly-busy,noanswer');
$agi->exec('Playback', 'en/vm-intro,noanswer');
my $file = 'xyz.wav';
$agi->exec('Record', "$file,0,10,k");
...
...
What should I do to make it work as I want it to?
Thank you.
UPDATE 1:
The same script is working without glitches now. Not sure if something unrelated to the script has changed.
Most likly you have check your codecs. IF you use g729 or g723 and no transcoder,it just can't write in wav format.

Resources