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

clipdel: Delete current clip #98

Open
brunelli opened this issue Jan 8, 2019 · 17 comments
Open

clipdel: Delete current clip #98

brunelli opened this issue Jan 8, 2019 · 17 comments

Comments

@brunelli
Copy link

brunelli commented Jan 8, 2019

I'd like to have a feature in clipdel to delete the current clip (first item of clipmenu), so I wrote a WIP patch which deletes the current clip and sets the clipboard content to the next item. It currently works with clipdel -l.

I'm opening this issue so we can discuss what's the best way to implement this feature.

@GladOSkar
Copy link

While i think the use case is valid, i think it would make more sense to create a "Delete picker" (with dmenu) as described in #57 since that would offer almost the same functionality.

@brunelli
Copy link
Author

Not really, since I wouldn't be able to delete the last clip by just invoking a shortcut combo.

The issue gave me some ideas to implement this together with a clipdelmenu, though. I'll try to hack something when I get some time to spare.

@GladOSkar
Copy link

GladOSkar commented Jan 10, 2019

Yeah i guess ideally you could pass a number as a parameter for which item to delete and if no parameter is passed it asks interactively.

For the interactive mode one could even (for rofi users) use rofi's multi-select.

@brunelli
Copy link
Author

Yeah i guess ideally you could pass a number as a parameter for which item to delete and if no parameter is passed it asks interactively.

I'm not sure about that, as there's no indication of which number corresponds to an entry.

For the interactive mode one could even (for rofi users) use rofi's multi-select.

Yeap, that'll totally be possible.

@GladOSkar
Copy link

GladOSkar commented Jan 11, 2019

I'm not sure about that, as there's no indication of which number corresponds to an entry.

Well i would say in the order of the history: 1 being the last item copied, 2 the one before that etc.

@brunelli
Copy link
Author

Well i would say in the order of the history: 1 being the last item copied, 2 the one before that etc.

Sure, but what's the use case?

The only way to know a entry's position is by running clip{,del}menu interactively, and even there there's no way to tell what's the associated number without counting.

@GladOSkar
Copy link

I only thought of your use case: deleting the last element

@brunelli
Copy link
Author

I was actually thinking of implementing it like clipdel --current.

But don't get me wrong, I'm all in for something like clipdel --entries 1 3-6, but I'm not sure that would be useful with the way clipmenu works.

@cdown have you thought of adding numbers in front of the entries in clipmenu?

Something like:

------------------------------------------------------
| clipmenu:                                          |
------------------------------------------------------
| [1] First entry                                    |
| [2] Second entry                                   |
| [3] A very very very very long entry... (12 lines) |
| [4] Lorem ipsum                                    |
| [5] Dolor sit amet                                 |
------------------------------------------------------

@GladOSkar
Copy link

I guess you're right, i don't really see a reason to automate deleting any other but the last copied entry

cdown added a commit that referenced this issue Mar 25, 2020
This allows avoiding having to delete after the fact for things like
issues #57 and #98.

Why have this over just stopping clipmenud? Well:

1. Stopping clipmenud should usually be an init system action, but we
   are init-system agnostic. If we just exit, we don't have a way of
   reliably starting again.
2. Even if we *do* do it using the init system, we don't want some
   things (like a lingering xsel which owns the selection for
   CM_OWN_CLIPBOARD) being killed as well.
3. This is a nicer interface for things like password managers to stop
   clipmenu rather than stopping clipmenu entirely.
cdown added a commit that referenced this issue Mar 25, 2020
This allows avoiding having to delete after the fact for things like
issues #57 and #98.

Why have this over just stopping clipmenud? Well:

1. Stopping clipmenud should usually be an init system action, but we
   are init-system agnostic. If we just exit, we don't have a way of
   reliably starting again.
2. Even if we *do* do it using the init system, we don't want some
   things (like a lingering xsel which owns the selection for
   CM_OWN_CLIPBOARD) being killed as well.
3. This is a nicer interface for things like password managers to stop
   clipmenu rather than stopping clipmenu entirely.
@ertwro
Copy link

ertwro commented Apr 25, 2020

I use something like this in the clipmenu script when I start it with a flag but I agree is not necessary.

rm_line=$(cut -d' ' -f2- "$cache_file" | grep -Fxn "$chosen_line"  | cut -d':' -f1 | sed 's/$/d/' | paste -sd';')
sed -i "${rm_line}" "$cache_file"
rm -f "$file"

@OJFord
Copy link

OJFord commented May 20, 2020

I guess you're right, i don't really see a reason to automate deleting any other but the last copied entry

Passwords, copied to clipboard on a timeout (for example, pass defaults to 45s) - you might copy something else in that time; the password manager wants to delete a known value, wherever it appears in order.

Edit - sorry, nevermind, I misread and there already is a clipdel, with exactly ^ that (and more general, with regex) behaviour.

@snprajwal
Copy link

@cdown bumping this up since I too use pass with clipmenu, and don't want my password lingering in the clipboard. Would you accept a PR for this?

@cdown
Copy link
Owner

cdown commented Apr 9, 2024

@snprajwal You can disable clipmenud's collection like so when using pass:

clipctl disable
[... do something ...]
clipctl enable

@cdown
Copy link
Owner

cdown commented Apr 9, 2024

As for this general issue, it seems somewhat related to #57, which should be trivial to implement in the current version. PRs welcome, of course :)

@N-R-K
Copy link
Contributor

N-R-K commented Jun 22, 2024

Is this (or #57 for that matter) even needed anymore? Skimming through the thread it seems like the use case was to avoid storing password but we already have CM_IGNORE_WINDOW and also clipctl disable.

@snprajwal
Copy link

snprajwal commented Jun 22, 2024

CM_IGNORE_WINDOW would not work for pass because it does not create a window at all - it simply runs in the terminal you invoke it in. And creating a shell script to disable and enable clipmenu every time when pass is invoked is clumsy. The password manager already has the feature to delete the latest clipboard entry, and support can be added for clipmenu trivially if deleting the latest entry is available as a feature :)

@N-R-K
Copy link
Contributor

N-R-K commented Jun 23, 2024

The password manager already has the feature to delete the latest clipboard entry

I don't use pass but going through it's manpage I don't see anything like this mentioned. This is the closest thing I found to what you're describing.

If by adding "support for clipmenu" you meant patch the source (as opposed to some config) then why can't it be done currently with clipdel? E.g just add the line:

clipdel -d "$(echo -n "$1")"

Below the qdbus command and it'd work.* In fact, this would be more robust than "delete current" because in the 45 second window, the user might've copied something else which would push the password to be no longer the current entry.

*: Only issue is regex escaping since clipdel expects a regex, not literal string. Adding a flag like -F (similar to grep) to match a literal instead of regex could be a nice addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants