diff --git a/client/client.yml b/client/client.yml index 3cd5736c..d3ba2722 100644 --- a/client/client.yml +++ b/client/client.yml @@ -5,10 +5,14 @@ # # default-host: https://ntfy.sh -# Defaults below will be used when a topic does not have its own settings +# Default username and password will be used with "ntfy publish" if no credentials are provided on command line +# Default username and password will be used with "ntfy subscribe" if no credentials are provided in subscription below +# For an empty password, use empty double-quotes ("") # # default-user: # default-password: + +# Default command will execute after "ntfy subscribe" receives a message if no command is provided in subscription below # default-command: # Subscriptions to topics and their actions. This option is primarily used by the systemd service, diff --git a/cmd/publish.go b/cmd/publish.go index 0b995258..efa875bf 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -160,6 +160,8 @@ func execPublish(c *cli.Context) error { fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20)) } options = append(options, client.WithBasicAuth(user, pass)) + } else if conf.DefaultUser != "" && conf.DefaultPassword != nil { + options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword)) } if pid > 0 { newMessage, err := waitForProcess(pid)