hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.55k stars 439 forks source link

Disable selection to clipboard for customized apps. #575

Closed amosbird closed 7 years ago

amosbird commented 7 years ago

My configuration looks like this

While using emacs to incrementally select a bunch of text, the clipboard will be populated with all the deltas of text selections. Can I disable the store text selected using mouse just for specific app?

hluk commented 7 years ago

Following command could help -- change the window title to match Emacs.

[Command]
Name=Ignore Selection from Emacs
Window=emacs
Command="
    copyq:
    var clipboardMode = str(input())
    if (clipboardMode == 'selection')
      ignore()"
Input=application/x-copyq-clipboard-mode
Automatic=true
Icon=\xf05e
amosbird commented 7 years ago

cool. Can I make it match more than one window? I'd like to mask intellij as well.

hluk commented 7 years ago

"Window" field in command dialog is regular expression so you can have emacs|GVIM|etc. Alternatively you can leave "Window" empty and check currentWindowTitle() in script.

amosbird commented 7 years ago

thank you @hluk

amosbird commented 7 years ago

I just updated to the latest copyq and it broke the Window filter. Here is the window I'm trying to disable copy-on-select,

_NET_WM_STATE(ATOM) = 
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
_NET_WM_DESKTOP(CARDINAL) = 2
WM_STATE(WM_STATE):
        window state: Normal
        icon window: 0x0
WM_HINTS(WM_HINTS):
        Client accepts input or input focus: True
        Initial state is Normal State.
        bitmap id # to use for icon: 0x3000214
        bitmap id # of mask for icon: 0x300021a
        window id # of group leader: 0x3000001
_GTK_THEME_VARIANT(UTF8_STRING) = 
_NET_WM_ICON(CARDINAL) =    Icon (32 x 32):
                ▒▒▒▒▒▒▒▒            
             ▒▒▒▒▒▒▒▒▒▒▒▒▒▒         
           ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒       
          ▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒      
         ▒▒▒▒▒▒▒▒░░░░░░     ░▒▒     
        ▒▒▒▒▒▒▒░░░░░░░░░░░    ▒▒    
       ▒▒▒▒▒▒░         ░░░    ░▒▒   
      ▒▒▒▒▒▒▒░                ░▒▒▒  
      ▒▒▒▒▒▒░░                ▒▒▒▒  
     ▒▒▒▒▒▒▒░░░   ░░░░░░░░░░░▒▒▒▒▒▒ 
     ▒▒▒▒▒▒▒░░░░   ░░░░░░░░▒▒▒▒▒▒▒▒░
    ▒▒▒▒▒▒▒▒░░░░░   ░░░░░░▒▒▒▒▒▒▓▓░▒
    ▒▒▒▒▒▒▒▒▒░░░░░   ░░░░▒▒▒▒▒▒▓▓░▒▒
    ▒▒▒▒▒▒▒▒▒░░░░░░░   ░▒▒▒▒▒▒▓▓░▓▓▒
    ▒▒▒▒▒▒▒░            ░▒▒▒▒▒▓░▓▓▒▒
    ▒▒▒▒▒░               ░▒▒▒▓░▓▓▒▒▒
    ▒▒▒▒░         ░░░░░░░░▒▒▒▒▓▓▒▒▒▒
    ▒▒▒▒░      ░░▒▒▒▒▒▒▒▒▒▒▒░▒▓▒▒▒▒▒
    ▒▒▒▒░     ░▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒
    ▒▒▒▒▒     ░▒▒▒░░░░░░▒▒▒▓▓▒▒▒▒▒▒ 
     ▒▒▒▒▒     ░▒▒░░░░░░▒▒▒▓▒▒▒▒▒▒▒ 
     ▒▒▒▒▒▒░     ░░░░░░▒▒▒▓▒▒▒▒▒▒▒▒ 
      ▒▒▒▒▒▒▒░      ░░▒▒▒▓▓░▒▒▒▒▒▒  
      ▒▒▒▒▒▒▒▒░░      ▒▒▓▒░▒▒▒▒▒▒▒  
       ▒▒▒▒▒▒▒░░░░░  ▒▒▓▒  ░▒▒▒▒▒   
       ▒▒▒▒▒▒░░░░░░░▒▒▓▒    ░▒▒▒    
        ▒▒▒▒▒░░░   ░▓▓▒    ░▒▒▒     
         ▒▒▒▒▒▒▒░░░▓▓▓░░░▒▒▒▒▒      
           ▒▒▒▒▒▒▒▓▓▓▒▒▒▒▒▒▒▒       
            ▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒         
              ▒▒▒▓▓▒▒▒▒▒▒           
                 ▓                  

XdndAware(ATOM) = BITMAP
_NET_WM_OPAQUE_REGION(CARDINAL) = 
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 50331941, 50331942
_NET_WM_USER_TIME(CARDINAL) = 178718154
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x3000124
WM_CLIENT_LEADER(WINDOW): window id # 0x3000001
_NET_WM_PID(CARDINAL) = 16210
WM_LOCALE_NAME(STRING) = "zh_CN.UTF-8"
WM_CLIENT_MACHINE(STRING) = "t450s"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
        program specified minimum size: 25 by 18
        program specified resize increment: 9 by 18
        program specified base size: 25 by 18
        window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "emacs@t450s"
_NET_WM_ICON_NAME(UTF8_STRING) = "mail"
WM_NAME(STRING) = "mail"
_NET_WM_NAME(UTF8_STRING) = "mail"

I put emacs|mail in "Window" field. It didn't filter the selections happened in above window.

hluk commented 7 years ago

The filtering still works for me with version 2.8.3.

You can use following command to show and copy window title to clipboard on Win+Ctrl+W.

[Command]
Command="
    copyq:
    popup('Window Title', currentWindowTitle())
    copy(currentWindowTitle())"
GlobalShortcut=meta+ctrl+w
Icon=\xf009
Name=Show and Copy Window Title

Can you paste here the command you use to omit the selections?

amosbird commented 7 years ago

Well, I get emacs as usual. Here is the command,

[Command]
Automatic=true
Command="
    copyq:
    var clipboardMode = str(input())
    if (clipboardMode == 'selection')
      ignore()"
Icon=\xf05e
Input=application/x-copyq-clipboard-mode
Name=Ignore Selection from Emacs
Window=emacs|IDEA
hluk commented 7 years ago

What distro and window manager do you use?

amosbird commented 7 years ago

Archlinux and i3wm

hluk commented 7 years ago

I cannot reproduce the bug even with i3wm and emacs (on Arch Linux).

Do you have other automatic commands triggered before this one?

amosbird commented 7 years ago

Well, no. I feel like it's related to emacs. Intellij still gets filtered correctly.

hluk commented 7 years ago

Hmm, could be that emacs is setting also clipboard when selecting with mouse (more info).

amosbird commented 7 years ago

Cool, I'm making progress. After setting

   x-select-enable-primary t
   x-select-enable-clipboard t

selection gets filtered correctly, but cut/copy also get filtered.

amosbird commented 7 years ago

hmm, this is cause by emacs evil. I set (fset 'evil-visual-update-x-selection 'ignore) and the problem is gone :smiley: