Skip to content

Commit

Permalink
Remove desktop notifications
Browse files Browse the repository at this point in the history
As a command-line utility, most operations won't be running in the
background even if they might take some time, so a desktop notification
shouldn't be necessary.  If commands are being scripted then it should
be up to the script to determine if notifications are needed.  The only
built-in desktop notification that really made any sense was for the
delayed clearing of the clipboard, but it doesn't seem worth the trouble
just for that one case.
  • Loading branch information
kpitt committed Sep 27, 2022
1 parent 5417ca0 commit 466a57d
Show file tree
Hide file tree
Showing 33 changed files with 125 additions and 1,228 deletions.
1 change: 0 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ ratings:

exclude_patterns:
- "vendor/"
- "utils/notify/icon.go"
- "**/*_test.go"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Please see [docs/features.md](https://github.com/kpitt/gopass/blob/master/docs/f
| JSON API | *integration* | Allow gopass to be used as a native extension for browser plugins |
| Automatic fuzzy search | *stable* | Automatically search for matching store entries if a literal entry was not found |
| gopass sync | *stable* | Easy to use syncing of remote repos and GPG keys |
| Desktop Notifications | *stable* | Display desktop notifications and completing long running operations |
| REPL | *beta* | Integrated Read-Eval-Print-Loop shell with autocompletion by running `gopass`. |
| OTP support | *stable* | Generate TOTP/(HOTP) tokens based on the stored secret |
| Extensions | | Extend gopass with custom commands using our API |
Expand Down
2 changes: 0 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Some configuration options are only available through setting environment variab
| `GOPASS_CHARACTER_SET` | `bool` | Set to any non-empty value to restrict the characters used in generated passwords |
| `GOPASS_CONFIG` | `string` | Set this to the absolute path to the configuration file |
| `GOPASS_HOMEDIR` | `string` | Set this to the absolute path of the directory containing the `.config/` tree |
| `GOPASS_NO_NOTIFY` | `bool` | Set to any non-empty value to prevent notifications |
| `GOPASS_NO_REMINDER` | `bool` | Set to any non-empty value to prevent reminders |
| `GOPASS_CLIPBOARD_COPY_CMD` | `string` | Use an external command to copy a password to the clipboard. See [GPaste](usecases/gpaste.md) for an example |
| `GOPASS_CLIPBOARD_CLEAR_CMD` | `string` | Use an external command to remove a password from the clipboard. See [GPaste](usecases/gpaste.md) for an example |
Expand Down Expand Up @@ -65,7 +64,6 @@ This is a list of available options:
| `usesymbols` | `bool` | If enabled - it will use symbols when generating passwords. DEPRECATED in v1.9.3 |
| `nocolor` | `bool` | Do not use color. |
| `nopager` | `bool` | Do not invoke a pager to display long lists. |
| `notifications` | `bool` | Enable desktop notifications. |
| `parsing` | `bool` | Enable parsing of output to have key-value and yaml secrets. |
| `path` | `string` | Path to the root store. |
| `safecontent` | `bool` | Only output _safe content_ (i.e. everything but the first line of a secret) to the terminal. Use _copy_ (`-c`) to retrieve the password in the clipboard, or _force_ (`-f`) to still print it. |
5 changes: 0 additions & 5 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ GPG keys.
$ gopass sync
```

### Desktop Notifications

Certain long running operations, like `gopass sync` or `copy to clipboard` will
try to show desktop notifications [Linux only].

### git auto-push and sync

gopass always pushes changes to your default git remote server (origin).
Expand Down
3 changes: 0 additions & 3 deletions internal/action/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ autoimport: true
cliptimeout: 45
exportkeys: true
nopager: false
notifications: true
parsing: true
`
want += "path: " + u.StoreDir("") + "\n"
Expand Down Expand Up @@ -82,7 +81,6 @@ autoimport: true
cliptimeout: 45
exportkeys: true
nopager: true
notifications: true
parsing: true
`
want += "path: " + u.StoreDir("") + "\n"
Expand Down Expand Up @@ -117,7 +115,6 @@ autoimport
cliptimeout
exportkeys
nopager
notifications
parsing
path
remote
Expand Down
1 change: 0 additions & 1 deletion internal/action/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestCreate(t *testing.T) { //nolint:paralleltest

ctx := context.Background()
ctx = ctxutil.WithAlwaysYes(ctx, true)
ctx = ctxutil.WithNotifications(ctx, false)

act, err := newMock(ctx, u.StoreDir(""))
require.NoError(t, err)
Expand Down
13 changes: 0 additions & 13 deletions internal/action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/kpitt/gopass/internal/action/exit"
"github.com/kpitt/gopass/internal/notify"
"github.com/kpitt/gopass/internal/out"
"github.com/kpitt/gopass/internal/store"
"github.com/kpitt/gopass/pkg/clipboard"
Expand Down Expand Up @@ -344,28 +343,16 @@ func (s *Action) hasAliasDomain(ctx context.Context, name string) string {
// showHandleError handles errors retrieving secrets.
func (s *Action) showHandleError(ctx context.Context, c *cli.Context, name string, recurse bool, err error) error {
if !errors.Is(err, store.ErrNotFound) || !recurse || !ctxutil.IsTerminal(ctx) {
if IsClip(ctx) {
_ = notify.Notify(ctx, "gopass - error", fmt.Sprintf("failed to retrieve secret %q: %s", name, err))
}

return exit.Error(exit.Unknown, err, "failed to retrieve secret %q: %s", name, err)
}

if newName := s.hasAliasDomain(ctx, name); newName != "" {
return s.show(ctx, nil, newName, false)
}

if IsClip(ctx) {
_ = notify.Notify(ctx, "gopass - warning", fmt.Sprintf("Entry %q not found. Starting search...", name))
}

out.Warningf(ctx, "Entry %q not found. Starting search...", name)
c.Context = ctx
if err := s.Find(c); err != nil {
if IsClip(ctx) {
_ = notify.Notify(ctx, "gopass - error", fmt.Sprintf("%s", err))
}

return exit.Error(exit.NotFound, err, "%s", err)
}

Expand Down
23 changes: 0 additions & 23 deletions internal/action/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import (
"github.com/fatih/color"
"github.com/kpitt/gopass/internal/backend"
"github.com/kpitt/gopass/internal/diff"
"github.com/kpitt/gopass/internal/notify"
"github.com/kpitt/gopass/internal/out"
"github.com/kpitt/gopass/internal/store"
"github.com/kpitt/gopass/internal/store/leaf"
"github.com/kpitt/gopass/internal/tree"
"github.com/kpitt/gopass/pkg/ctxutil"
"github.com/kpitt/gopass/pkg/debug"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -69,12 +67,6 @@ func (s *Action) autoSync(ctx context.Context) error {
func (s *Action) sync(ctx context.Context, store string) error {
out.Printf(ctx, "- Syncing with all remotes...")

numEntries := 0
if l, err := s.Store.Tree(ctx); err == nil {
numEntries = len(l.List(tree.INF))
}
numMPs := 0

mps := s.Store.MountPoints()
mps = append([]string{""}, mps...)

Expand All @@ -89,25 +81,10 @@ func (s *Action) sync(ctx context.Context, store string) error {
}
}

numMPs++
_ = s.syncMount(ctx, mp)
}
out.OKf(ctx, "All done")

// Calculate number of changed entries.
// This is a rough estimate as additions and deletions.
// might cancel each other out.
if l, err := s.Store.Tree(ctx); err == nil {
numEntries = len(l.List(tree.INF)) - numEntries
}
diff := ""
if numEntries > 0 {
diff = fmt.Sprintf(" Added %d entries", numEntries)
} else if numEntries < 0 {
diff = fmt.Sprintf(" Removed %d entries", -1*numEntries)
}
_ = notify.Notify(ctx, "gopass - sync", fmt.Sprintf("Finished. Synced %d remotes.%s", numMPs, diff))

return nil
}

Expand Down
5 changes: 0 additions & 5 deletions internal/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/fatih/color"
"github.com/kpitt/gopass/internal/backend"
"github.com/kpitt/gopass/internal/notify"
"github.com/kpitt/gopass/internal/out"
"github.com/kpitt/gopass/pkg/ctxutil"
"github.com/kpitt/gopass/pkg/debug"
Expand Down Expand Up @@ -275,12 +274,8 @@ func auditPrintResults(ctx context.Context, duplicates, messages, errors map[str
foundErrors := printAuditResults(errors, "%s:\n", color.RedString)

if foundWeakPasswords || foundDuplicates || foundErrors {
_ = notify.Notify(ctx, "gopass - audit", "Finished. Found weak passwords and/or duplicates")

return fmt.Errorf("found weak passwords or duplicates")
}

_ = notify.Notify(ctx, "gopass - audit", "Finished. No weak passwords or duplicates found!")

return nil
}
34 changes: 16 additions & 18 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ var (

// Config is the current config struct.
type Config struct {
AutoClip bool `yaml:"autoclip"` // decide whether passwords are automatically copied or not.
AutoImport bool `yaml:"autoimport"` // import missing public keys w/o asking.
ClipTimeout int `yaml:"cliptimeout"` // clear clipboard after seconds.
ExportKeys bool `yaml:"exportkeys"` // automatically export public keys of all recipients.
NoPager bool `yaml:"nopager"` // do not invoke a pager to display long lists.
Notifications bool `yaml:"notifications"` // enable desktop notifications.
Parsing bool `yaml:"parsing"` // allows to switch off all output parsing.
Path string `yaml:"path"`
SafeContent bool `yaml:"safecontent"` // avoid showing passwords in terminal.
Mounts map[string]string `yaml:"mounts"`
AutoClip bool `yaml:"autoclip"` // decide whether passwords are automatically copied or not.
AutoImport bool `yaml:"autoimport"` // import missing public keys w/o asking.
ClipTimeout int `yaml:"cliptimeout"` // clear clipboard after seconds.
ExportKeys bool `yaml:"exportkeys"` // automatically export public keys of all recipients.
NoPager bool `yaml:"nopager"` // do not invoke a pager to display long lists.
Parsing bool `yaml:"parsing"` // allows to switch off all output parsing.
Path string `yaml:"path"`
SafeContent bool `yaml:"safecontent"` // avoid showing passwords in terminal.
Mounts map[string]string `yaml:"mounts"`

ConfigPath string `yaml:"-"`

Expand All @@ -37,14 +36,13 @@ type Config struct {
// New creates a new config with sane default values.
func New() *Config {
return &Config{
AutoImport: false,
ClipTimeout: 45,
ExportKeys: true,
Mounts: make(map[string]string),
Notifications: true,
Parsing: true,
Path: PwStoreDir(""),
ConfigPath: configLocation(),
AutoImport: false,
ClipTimeout: 45,
ExportKeys: true,
Mounts: make(map[string]string),
Parsing: true,
Path: PwStoreDir(""),
ConfigPath: configLocation(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewConfig(t *testing.T) { //nolint:paralleltest

cfg := config.New()
cs := cfg.String()
assert.Contains(t, cs, `&config.Config{AutoClip:false, AutoImport:false, ClipTimeout:45, ExportKeys:true, NoPager:false, Notifications:true,`)
assert.Contains(t, cs, `&config.Config{AutoClip:false, AutoImport:false, ClipTimeout:45, ExportKeys:true, NoPager:false,`)
assert.Contains(t, cs, `SafeContent:false, Mounts:map[string]string{},`)

cfg = &config.Config{
Expand All @@ -30,7 +30,7 @@ func TestNewConfig(t *testing.T) { //nolint:paralleltest
},
}
cs = cfg.String()
assert.Contains(t, cs, `&config.Config{AutoClip:false, AutoImport:false, ClipTimeout:0, ExportKeys:false, NoPager:false, Notifications:false,`)
assert.Contains(t, cs, `&config.Config{AutoClip:false, AutoImport:false, ClipTimeout:0, ExportKeys:false, NoPager:false,`)
assert.Contains(t, cs, `SafeContent:false, Mounts:map[string]string{"bar":"", "foo":""},`)
}

Expand Down
4 changes: 0 additions & 4 deletions internal/config/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ func (c *Config) WithContext(ctx context.Context) context.Context {
ctx = ctxutil.WithNoPager(ctx, c.NoPager)
}

if !ctxutil.HasNotifications(ctx) {
ctx = ctxutil.WithNotifications(ctx, c.Notifications)
}

if !ctxutil.HasShowSafeContent(ctx) {
ctx = ctxutil.WithShowSafeContent(ctx, c.SafeContent)
}
Expand Down
11 changes: 5 additions & 6 deletions internal/config/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ type configer interface {

func decode(buf []byte, relaxed bool) (*Config, error) {
mostRecent := &Config{
AutoImport: true,
ClipTimeout: 45,
ExportKeys: true,
Notifications: true,
Parsing: true,
Path: PwStoreDir(""),
AutoImport: true,
ClipTimeout: 45,
ExportKeys: true,
Parsing: true,
Path: PwStoreDir(""),
}
cfgs := []configer{
// most recent config must come first.
Expand Down
Loading

0 comments on commit 466a57d

Please sign in to comment.