use XDG_RUNTIME_DIR for the socket file

cc #722 #726
This commit is contained in:
Gokcehan 2022-02-06 23:45:40 +03:00
parent 1703dcc11f
commit 86e84c9151
4 changed files with 9 additions and 4 deletions

2
doc.go
View File

@ -1026,7 +1026,7 @@ To use this feature, you need to use a client which supports communicating with
OpenBSD implementation of netcat (nc) is one such example. OpenBSD implementation of netcat (nc) is one such example.
You can use it to send a command to the socket file: You can use it to send a command to the socket file:
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such.
When using lf, you do not need to specify the address of the socket file. When using lf, you do not need to specify the address of the socket file.

View File

@ -1128,7 +1128,7 @@ To use this feature, you need to use a client which supports communicating
with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such
example. You can use it to send a command to the socket file: example. You can use it to send a command to the socket file:
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
Since such a client may not be available everywhere, lf comes bundled with a Since such a client may not be available everywhere, lf comes bundled with a
command line flag to be used as such. When using lf, you do not need to command line flag to be used as such. When using lf, you do not need to

2
lf.1
View File

@ -1213,7 +1213,7 @@ One of the more advanced features in lf is remote commands. All clients connect
To use this feature, you need to use a client which supports communicating with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such example. You can use it to send a command to the socket file: To use this feature, you need to use a client which supports communicating with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such example. You can use it to send a command to the socket file:
.PP .PP
.EX .EX
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
.EE .EE
.PP .PP
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. When using lf, you do not need to specify the address of the socket file. This is the recommended way of using remote commands since it is shorter and immune to socket file address changes: Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. When using lf, you do not need to specify the address of the socket file. This is the recommended way of using remote commands since it is shorter and immune to socket file address changes:

7
os.go
View File

@ -88,7 +88,12 @@ func init() {
gMarksPath = filepath.Join(data, "lf", "marks") gMarksPath = filepath.Join(data, "lf", "marks")
gHistoryPath = filepath.Join(data, "lf", "history") gHistoryPath = filepath.Join(data, "lf", "history")
gDefaultSocketPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.sock", gUser.Username)) runtime := os.Getenv("XDG_RUNTIME_DIR")
if runtime == "" {
runtime = os.TempDir()
}
gDefaultSocketPath = filepath.Join(runtime, fmt.Sprintf("lf.%s.sock", gUser.Username))
} }
func detachedCommand(name string, arg ...string) *exec.Cmd { func detachedCommand(name string, arg ...string) *exec.Cmd {