How to iconify signal-desktop in the notification area - notifications

I try to minimize signal-desktop on linux and have an icon put in the notification area. Notifications are enabled in Preferences and I have set the line
Exec=/opt/Signal/signal-desktop --use-tray-icon --no-sandbox %U
But the icon does not turn up in the notification area and the messenger exits when I close the window.

I use:
kdocker -m -q -d 15 -i/home/dl3no/Bilder/Icons/Signal.png /opt/Signal/signal-desktop --no-sandbox %U
in Autostart..

Related

Copy to client clipboard after mouse selection with tmux in a remote session

This is my .tmux.conf
setw -g mouse on
set-option -s set-clipboard off
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
Works well on a linux machine locally. Mouse selection is copied to system clipboard automatically.
However, in a remote session (iTerm + Mac), it doesn't work. Text isn't copied to the client's system clipboard. Apparently I have to use OSC 52. Here is a helper script.
You can use the script like so:
echo "whatever text" | osc52.sh
Now "whatever text" is copied to the client's system clipboard.
However I can't get the script to work with tmux mouse selection:
setw -g mouse on
set-option -s set-clipboard off
osc52="~/osc52.sh"
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "$osc52"
Any help is appreciated. Thanks!
This is not the way to use OSC 52. You can't send it from a script - all output from commands run from copy-pipe is ignored.
Instead, you need to configure tmux itself to do it. Try the following:
1) Remove the bind-key command and just leave MouseDragEnd1Pane as the default which is copy-selection.
2) Change set-clipboard off to set-clipboard on. Remember to restart tmux entirely after changing .tmux.conf.
3) Make sure TERM outside tmux is xterm or xterm-256color so that tmux adds the Ms capability from the default terminal-overrides. This should be the default in iTerm2. Make sure you are not removing it from terminal-overrides in .tmux.conf.
4) In iTerm2, I think you need to turn on this option, "Applications in terminal may access clipboard":

Turning off / Hiding the Touch Bar - MacBook Pro 2016

I have extensively searched internet for how to programatically turn off the Touch Bar, but have had no luck so far in finding a solution.
I know this is possible due to Apple's "QuickTime" app turning off the Touch Bar when a video is playing after the on screen controls fade away.
Would there be an official way to do this, or even a "hacky" way? Any help would be much appreciated.
I have found a way to turn off the touch bar using the script below:
#!/bin/bash
function enableTouchBar() {
local presentationModeProperties="<dict><key>app</key><string>fullControlStrip</string><key>appWithControlStrip</key><string>fullControlStrip</string><key>fullControlStrip</key><string>app</string></dict>"
defaults delete com.apple.touchbar.agent PresentationModeGlobal
defaults write com.apple.touchbar.agent PresentationModeFnModes $presentationModeProperties
launchctl load /System/Library/LaunchAgents/com.apple.controlstrip.plist
launchctl load /System/Library/LaunchAgents/com.apple.touchbar.agent.plist
launchctl load /System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist
pkill "ControlStrip"
pkill "Touch Bar agent"
pkill Dock
}
function disableTouchBar() {
defaults write com.apple.touchbar.agent PresentationModeGlobal -string fullControlStrip
launchctl unload /System/Library/LaunchAgents/com.apple.controlstrip.plist
launchctl unload /System/Library/LaunchAgents/com.apple.touchbar.agent.plist
launchctl unload /System/Library/LaunchDaemons/com.apple.touchbar.user-device.plist
pkill "ControlStrip"
pkill "Touch Bar agent"
pkill Dock
}
{
if [ "$1" == "enable" ]; then
enableTouchBar
elif [ "$1" == "disable" ]; then
disableTouchBar
else
printf "\\nUsage:\\n\\tTouchBar enable\\n\\tTouchBar disable\\n\\n"
fi
}
Please note, System Integrity Protection must be disabled $ csrutil disable in recovery mode
References:
https://github.com/HiKay/TouchBarDisabler
https://gist.github.com/JamesMarino/1c628e9ad57e21684cd5e8ec139b7e98

GNU Screen terminal line settings

I want to use GNU screen to monitor to a serial USB port like this:
$ screen /dev/ttyUSB0 115200
But I need to tweak a few terminal line settings. I have made several attempts but none seem to work. For example, to send NL+CR for a newline character, not just NL, the terminal line setting is onlcr.
Attempt 1 - without any special settings:
$ screen /dev/ttyUSB0 115200
# only sends NL
Attempt 2 - via screen:
$ screen /dev/ttyUSB0 115200,onlcr
# still only sends NL
Attempt 3 - via ssty:
$ stty -F /dev/ttyUSB0 onlcr
$ screen /dev/ttyUSB0 115200
# still only sends NL
Attempt 4 - via both:
$ stty -F /dev/ttyUSB0 onlcr
$ screen /dev/ttyUSB0 115200,onlcr
# still only sends NL
Attempt 5 - in the other order:
$ screen /dev/ttyUSB0 115200,onlcr
# then ctrl+a, ctrl+z to pause the screen session
$ stty -F /dev/ttyUSB0 onlcr
stty: /dev/ttyUSB0: Device or resource busy
In all cases, if I run stty to check the terminal line settings I get this:
Before running screen - note the -onlcr is present:
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo
Changing the stty setting - note the -onlcr has gone:
$ stty -F /dev/ttyUSB0 onlcr
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost
-isig -icanon -echo
After running screen - note the -onlcr is back again:
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo
It's as if screen ignores any stty settings and resets them to it's own defaults. And this the same on both machines I tested it on; Debain 8.7 and macOS Sierra 10.12.4
I have seen posts with other people facing similar problems but none give a definitive answer. Many people end up recommending an alternative to screen like minicom but now I'm interested.
Can stty settings, like onlcr, be used with screen?
I just went through much the same process, only to find out the screen clobbers the stty settings no matter what. One comment here suggests changing the screen source code:
How to toggle CR/LF in gnu screen?
In the end, I was very happy to find a more minimal dumb-terminal program that allows passing stty-style arguments on the command line:
https://github.com/npat-efault/picocom
It also pretty-prints the serial port settings when it starts so you can easily check them.
Packages exist in Debian-derived distros (sudo apt-get install picocom), and for others it seems that compilation is straightforward. One dependency is the linenoise library, which can be disabled.
The way I handled this is to start screen running without any special terminal options using in your case: screen /dev/ttyUSB0 115200, and then leave it running, and switch over to another terminal window and do the stty commands from there.
If you stop screen, I think it locks the device somehow (or else its because you aren't using sudo). Once in the other window you can type the sudo stty -F /dev/ttyUSB0 onlcr and that will change the behavior of the screen session from then on. The problem is that screen is ignoring the setting passed to it and just configuring the tty its own way. You can type sudo stty -F /dev/ttyUSB0 -a to list the settings from another window while screen is running and then alter them as needed. (Note that on the Mac, the -F should be lower case.)
If you only have the one terminal window then it is problematic because putting screen in the background and leaving it running just mixes input and output streams between the shell and screen process.
Another thing you can do if you have two terminal windows open is a low-level fallback hack when nothing is working: In one terminal type cat /dev/ttyUSB0. Then in the other set up the terminal options you want with sudo stty. Then from this same terminal you can send commands via echo "Some text" > /dev/ttyUSB0. You can translate the output of the cat command by piping it through sed or tr. For example cat /dev/ttyUSB0 | tr '\r' '\n' will translate any received carriage returns to line feeds.

Pexpect ssh login opens password prompt window

I have a simple pexpect script to ssh into a system:
p = pexpect.spawn ("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null admin#%s" % (system))
p.logfile_read = fout
p.setecho(True)
time.sleep (5)
i = p.expect ([VM_PAT_TM_PROMPT_USER, STANDBY_PROMPT, 'password:', pexpect.EOF, pexpect.TIMEOUT, 'Error'], timeout=60)
It works on some of the systems. However, now it started popping up this small window with password prompt. While that window is waiting for the password the p.expect call times out.
Is there any way to prevent this extra popup window?
Found the problem.
This is the same issue as described in this question. The popup comes from the SSH settings, SSH_ASKPASS in particular. You can find more details at the SSH man page.

Automatically (or more easily) reconnect to a screen session after network interruption

ADDED: This question is now, I believe, subsumed by this one:
Using GNU Screen completely transparently and automatically
See also this related question:
https://superuser.com/questions/147873/ssh-sessions-in-xterms-freeze-for-many-minutes-whenever-they-disconnect
Original question:
It would be nice if there were a way to ssh to a machine and immediately reconnect to a specific screen session. You can do this:
laptop> ssh server.com screen -ls
and it will show a list of screens available on server.com like so [1]:
123.pts-1
456.pts-2
And then you might try to do this:
laptop> ssh server.com screen -dr pts-2
but that fails, saying "Must be connected to a terminal."
You have to ssh in first and then do the "screen -dr pts-2" on server.com which is no good if you have a flaky connection and get disconnected a lot. You want to be able to resume with a simple "up-arrow enter" on the laptop. (Or perhaps make it even more automatic.)
I have a rihackulous solution to this problem which I'll post as an answer and hope it gets downvoted to oblivion in favor of the Right Way to deal with this.
Footnotes:
[1] Or, better, if you created the screen sessions with names like "screen -S foo" and "screen -S bar" then you'll get a friendlier list like:
123.foo
456.bar
and can reconnect with, eg, "screen -dr foo".
Mini screen tutorial, incorporating the answer to this question:
Login in to server.com and do
screen -S foo
and then never log out of that session again.
To reconnect to it from elsewhere, do
ssh -t server.com screen -dr foo
To list available screens to reconect to:
screen -ls
or, of course,
ssh server.com screen -ls
to check on server.com's available screens remotely.
I now use the following alias (tcsh), based on Jason's answer below, to connect to a named screen if it exists or create and connect otherwise:
alias ssc 'ssh -t \!:1 "screen -S \!:2 -dr || screen -S \!:2"'
Does the -t option do what you want?
-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g. when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
So:
laptop> ssh -t server.com screen -dr pts-2
This seems to work in my installation.
This is now subsumed by this: Using GNU Screen completely transparently and automatically
Here's a script, ssc, that works just like ssh but takes a third argument to specify the screen to reconnect to, or the name of a new screen.
I believe this script subsumes everything in the original question.
#!/usr/bin/env perl
# Use 'ssc' (this script) instead of 'ssh' to log into a remote machine.
# Without a 3rd argument it will list available screens.
# Give it a 3rd argument to attach to an existing screen or specify a new
# screen. Eg, ssc remote.com foo
# The numbers in front of the screen tag can usually be ignored.
# Screen is a little too clever though in that if there's an existing screen "bar"
# and you say "ssc remote.com b" it will reconnect you to "bar" instead of making
# a new screen "b". It's like invisible and silent tab-completion.
if(scalar(#ARGV)==0 || scalar(#ARGV) > 2) {
print "USAGE: ssc remote.com [screen name]\n";
} elsif (scalar(#ARGV) == 1) {
$machine = shift;
#screens = split("\n", `ssh $machine screen -ls`);
for(#screens) {
if(/^\s*(\d+)\.(\S+)\s+\(([^\)]*)\)/) {
($num, $tag, $status) = ($1, $2, $3);
if($status =~ /attached/i) { $att{"$num.$tag"} = 1; }
elsif($status =~ /detached/i) { $att{"$num.$tag"} = 0; }
else { print "Couldn't parse this: $_\n"; }
}
}
print "ATTACHED screens:\n";
for(keys(%att)) { print " $_\n" if $att{$_}; }
print "DETACHED screens:\n";
for(keys(%att)) { print " $_\n" unless $att{$_}; }
} else {
$machine = shift;
$tag = shift;
system("ssh -t $machine \"screen -S $tag -dr || screen -S $tag\"");
}
Use the -t option to ssh to allocate a terminal while directly running a command.
laptop> ssh -t server.com screen -dr pts-2
I've been working on something similar but not quite got there, your solutions have solved my problem so here's my suggestion:
ssh -t server.com "screen -S foo -rd || screen -S foo"
This just tries to open the existing screen named foo and if it doesnt exist, creates it.
I'll put this in a launcher on my laptop, so when the wireless network goes I can just open where I left off.
Just noticed that the default screen shell is a bit weak, so an improvement which sets up your home environment a little better is:
ssh -t server.com "screen -S foo -rd || screen -S foo bash -l"
I converted this to work on OS X .bash_profile with one addition: If no 2nd parameter is given, it will start a session "default".
function ssc() {
if [[ -z $2 ]]; then
screen="default"
else
screen=$2
fi
ssh -t $1 "screen -S $screen -dr || screen -S $screen"
}
If you like to connect to the same session always even it is active, detached or not exists yet:
ssh -t user#server screen -xR screenName
The same but create a new session if it is already active on some other pty:
ssh -t user#server screen -rR screenName