Set up opener. Support multiple hosts.
Enable with `systemctl --user enable --now opener@myhost`
This commit is contained in:
parent
fe11201cdb
commit
e176c27955
3 changed files with 22 additions and 0 deletions
10
.config/systemd/user/opener@.service
Normal file
10
.config/systemd/user/opener@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Open URL in your local web browser from the SSH-connected remote environment.
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
Environment=OPENER_CONF=%t/opener.%i.conf
|
||||
ExecStart=/bin/sh -c 'echo "address: %t/opener.%i.sock" > $OPENER_CONF && exec %h/bin/opener --config $OPENER_CONF'
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
|
@ -21,6 +21,7 @@ LocalForward 127.0.0.1:3000 127.0.0.1:3000
|
|||
LocalForward 127.0.0.1:8000 127.0.0.1:8000
|
||||
LocalForward 127.0.0.1:8080 127.0.0.1:8080
|
||||
LocalForward 127.0.0.1:9090 127.0.0.1:9090
|
||||
RemoteForward ${XDG_RUNTIME_DIR}/opener.sock ${XDG_RUNTIME_DIR}/opener.dln-dev.sock
|
||||
|
||||
Host *
|
||||
ForwardAgent no
|
||||
|
|
11
bin/xdg-open
Executable file
11
bin/xdg-open
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
# Use local xdg-open if not in an ssh session
|
||||
[ -n "$SSH_TTY" ] || exec /usr/bin/xdg-open "$@"
|
||||
|
||||
if [ -p /dev/stdin ]; then
|
||||
exec nc -U "$XDG_RUNTIME_DIR/opener.sock" </dev/stdin
|
||||
else
|
||||
echo "$@" | nc -U "$XDG_RUNTIME_DIR/opener.sock"
|
||||
fi
|
Loading…
Reference in a new issue