Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dmenu support #47

Merged
merged 8 commits into from
Feb 13, 2017
Merged

Conversation

metalmatze
Copy link
Contributor

Closes #43

The passmenu works but doesn't support mounts.

This add the script into the binary, just like auto completion for bash & zsh.
Some parts are still WIP and are probably going to change.

Usage: eval "$(pass completion dmenu)"

What do you think @notandy & @fortytw2?

[[ -n $password ]] || exit

if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does gopass install as pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that's by mistake and worked for me because I alias pass=gopass... 😄 Thankfully still WIP and will be update, thanks for pointing out anyway! 😊

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might make more sense overall to switch on os.Args[0] as gopassmenu or passmenu and just run xdotool from within the program

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.Args[0] 👍

@metalmatze metalmatze mentioned this pull request Feb 10, 2017
@dominikschulz dominikschulz added this to the 1.0.1 milestone Feb 11, 2017
action/list.go Outdated
filter := c.Args().First()

// Don't show a tree only new lines
if raw {
//TODO(metalmatze): Support filtering
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do:

list, err := s.Store.List()
for _, v := range list {
 if smth(v) {
  fmt.Println(v)
 }
}

@dominikschulz dominikschulz added the feature Enhancements and new features label Feb 11, 2017
@metalmatze metalmatze changed the title WIP: Add support for dmenu Add dmenu support Feb 12, 2017
@metalmatze
Copy link
Contributor Author

I reworked the PR and got completely rid of the bash script. We simply don't need it.
It's now all within the binary itself.

Tested on my system. 😊

Called dmenu from within the binary made this one obsolete, dropping it
return s.copyToClipboard(name, content)
}

// dmenu runs it with the provided strings and returns the selected string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me (i.e. a person unfamiliar with dmenu) this comment is not very helpful.
What is dmenu?
Why does it need/how does it use completion?
Why do we need to run dmenu in here?

}

if typeit {
return exec.Command("xdotool", "type", "--clearmodifiers", string(content)).Run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is xdotool and why is it called here? What is typeit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So xdotool is a fake keyboard/mouse input, window management, and more. It is used to type the secret into the focused element on your screen. This can be a terminal, Slack Desktop App. Everything that has a keyboard input. It types the secret's chars into that field one after another.

@@ -20,36 +19,34 @@ func (s *Action) Show(c *cli.Context) error {
return s.List(c)
}

if c.Bool("clip") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to dmenu. Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a first sight, but clip and dmenu use the clipboard in the background. We only want to copy the first line of the secret into the clipboard with gopass show -c and also with gopass completion dmenu. So instead of doing the first line extraction inside the copyToClipboard func is moved it to the store with a func First(name string) that returns only the first line of the secret.

@@ -303,6 +304,21 @@ func (r *RootStore) Get(name string) ([]byte, error) {
return store.Get(strings.TrimPrefix(name, store.alias))
}

// First returns the first line of the plaintext of a single key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to dmenu. Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the other comment.

Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dominikschulz dominikschulz merged commit 91f95a7 into gopasspw:master Feb 13, 2017
@metalmatze metalmatze deleted the feature/dmenu branch February 13, 2017 13:21
come-maiz pushed a commit to come-maiz/gopass that referenced this pull request Feb 20, 2017
* Support gopass list --raw that just prints lines
* Add gopass completion dmenu command
* Create func First for RootStore that only returns first line of content - Also it trims the first line's spaces
* Implement dmenu support without bash scripts by calling from within
* Add a section about dmenu support to the README
* Drop obsolete gopass list --raw support - Called dmenu from within the binary made this one obsolete, dropping it
samuelnilsson pushed a commit to samuelnilsson/gopass that referenced this pull request Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Enhancements and new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants