Add keyboard shortcut feature#160
Conversation
wiiznokes
left a comment
There was a problem hiding this comment.
Hi, thanks for this pr. This is a good work arround while waiting for the flatpak portal implementation.
I have some questions/suggestions. I understand you're not familiar with rust, so you can ask me if you don't understand something.
- Did you test your code? Does it works?
get_signal_file_pathis duplicated- You seems to write the timestamp but never actually use it in the code
- It would be nice if these change be in one module, e.i, the functions to read/write the signal file, and the subscription
- The subscription should be a file watcher, especially if we are doing io every 100ms
- why you define a shortcut in the app code? If i understand correctly, it should only be in the cosmic-comp config
|
Note that the approach looks good otherwise |
|
Thanks @wiiznokes -- I believe I addressed everything, please let me know if not. Tested fully on my local machine-- able to activate, start typing to search, use arrow keys to select, and enter to populate clipboard with selection and close the UI. Escape also exits the UI without altering the clipboard. |
|
So i wanted to make some minor modif before merging the pr (see this branch https://github.com/cosmic-utils/clipboard-manager/tree/pr160-modif), but i've realised that the popup doesn't show near the applet icon now. Maybe @wash2 have some insight about this problem 🙏 |
|
Yep, I noticed the positioning as well- I think it's due to how Wayland treats the layers, so I'm not sure how to align it with the applet icon if it goes that route. Whatever you think is best-- I have a local copy that works for me, so I'm happy to do anything else needed to get the functionality available to others. |
|
I LOVEE this, is it possible to have the selection This would help someone transitioning from windows with my muscle memory. |
|
There's an issue where having more items in history than length and using down arrow to scroll doesn't actually scroll them into view. |
|
Been testing this for a week. functions fine on pop-os 24.04. Could it be that it's missing a pause somewhere? |
Added a 10ms to file watcher to reduce CPU stress.
Implement delay in signal_file_watcher function
|
i'm not sure but i think the line that block us to use a regular xdg shell popup is this one: https://github.com/pop-os/cosmic-panel/blob/8eb8a1b6305213ec7402cb2ec24bef6b501b978a/cosmic-panel-bin/src/xdg_shell_wrapper/server/handlers/xdg_shell.rs#L45 Maybe we could add a check to bypass this if the client is not sandboxed |
|
sorry, i use this now and want to pull in the latest greatest changes so excuse me for butting in but hopefully this can help move this along:
|
- Add --toggle/-t CLI flag to toggle popup via keyboard shortcut - Add --help/-h with setup instructions for COSMIC custom shortcuts - Add file-based IPC (polling) for external toggle signaling - Fix popup positioning: icon click uses XDG popup (anchored), --toggle uses centered layer surface - Fix close_popup to correctly destroy layer surfaces vs XDG popups - Switch clipboard pipe reads from blocking std::io to async tokio with 500ms timeout (based on PR cosmic-utils#170) - Fix search input to support Enter-to-copy focused item - Add db lock file to .gitignore Incorporates and fixes issues from PR cosmic-utils#170 and PR cosmic-utils#160: - Replaces notify-based file watcher with simple 250ms polling to prevent CPU busy-loop caused by inotify on busy /run/user/ dir - Uses Anchor::empty() for centered popup instead of edge-anchored Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I decided to go more with a dbus approach -> https://github.com/Lcstyle/clipboard-manager/tree/feat/dbus-toggle for a oneshot event based trigger rather than polling - reason being :
|
|
I tried this branch on an opensuse system. I rebased it to fix some compile errors, but with the changes in this branch, I do not see the popover when clicking the clipboard icon. I'd like to help. How can I see the logs from the cosmic applet? |
|
Hi everyone, I initially tried the original solution, but I ran into some limitations, so I decided to take a different approach. The main issue I found was popup positioning in the shortcut flow. With the previous approach, the popup could end up opening on the right side of the screen instead of being positioned relative to the applet icon. In practice, if the icon was on the left side and I triggered the shortcut, the popup could still appear on the right. I tried to fix that behavior, but I could not get it working reliably. Because of that, I switched to a different solution. Instead of opening the regular applet popup from the shortcut path, the shortcut now talks to the running applet over D-Bus and opens a dedicated launcher-style overlay, as shown in the screenshot. The normal click behavior remains unchanged and still works the same way as it does today. For the COSMIC custom shortcut, the command should be configured as:
I think this approach should avoid the positioning issue in the shortcut flow. I would appreciate your feedback. https://github.com/luks-santos/clipboard-manager/tree/feature/global-shortcut
|
|
@luks-santos one thing I hate is spending lots of time working on something that someone has already solved, and basically discovering I've just come up with the same solution! Take a look here |
|
@Lcstyle Haha, that’s true 😄 |
|
what's the status of this? |


This adds the ability to assign keyboard shortcuts via the Cosmic keyboard custom settings to activate, search, select, and copy from the UI.
The command to add is:
and you can assign it to any shortcut. This will show/hide the clipboard manager, and allow you to type to search, use the arrow keys to select an item, and enter to copy and close the interface. Escape also works to exit without selecting anything.
Full disclosure: I am not an expert in Rust; I'm scratching my own itch to add this feature, so there may be a more suitable way of doing this.