Linux middle-click paste is problematic and needs to be automatically disabled

The core of the issue

  • Obsidian uses the middle-click for various functionality like opening links in new tabs/windows.
  • But this is conflicting with the default Linux OS behavior in which the middle-click pastes the clipboard.
  • Unfortunately, there is no sure way to turn this pasting feature off on the OS level. Maybe on some specific distributions, using a specific set of non-typical terminal tools, for limited types of applications, X desktop vs. Wayland, etc, it is possible. But not consistently, not easily and without any guarantee that it will work. I am using one of the most popular Linux distros available and I couldnā€™t find a way to disable it for Obsidian, let alone the whole OS. Itā€™s a really big mess.
  • Basically, the only solution is for the specific application developer to disable this pasting functionality for his software. And this is exactly what I ask you to do. Not having a toggle in the settings is not a problem.

Examples of problems

Example 1

  1. Have some text in the copy&paste buffer.
  2. Be in note1 writing.
  3. Want to open note2 in a new window.
  4. Middle-click on the name note2 in the file explorer.
    4.a) note2 opens in a new window
    4.b) BUG. note1 now has a pasted text

Example 2

  1. Have ā€œtextā€ in the copy&paste buffer.
  2. Be in edit mode of note1 and want to open an internal link to note2 in a new window
  3. Middle-click on [[note2]] link
    3.a) note2 opens in new window
    3.b) while the [[note2]] in note1 becomes [[nottexte2]] (or similar, depending on where the cursor was at the moment of the middle-click
    3.c) so I have to remember to undo this change. If I donā€™t, it will influence my Zettelkasten workflow more than you would think (wonā€™t go into details)

In order to circumvent the problems, I have to remember to:

  1. switch to preview mode
  2. middle-click the link from there
  3. go back to the old document and switch back to the edit mode

Environment

  • Operating system: Linux Mint 20.3 Cinnamon
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v0.13.33
    Installer version: v0.13.31
    Operating system: #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 5.13.0-35-generic

Additional information

Related topic:

18 Likes

I understand. I think you can disable this behavior from your window managerā€™s option system-wise. We will consider adding a switch to by disable X11 selection clipboard in the future.
Moved to Feature Request.

1 Like

Alas, the option does not exist and there is no info on whether it will ever be implemented. :frowning:

Here is a little taste of how ridiculously difficult or even impossible disabling the feature is.

Same here. Just do add more information:

Iā€™m using Pop!_OS. There is an option ā€œMiddle Cick Pasteā€ option (in Gnome Tweaks). I already disabled it.

In the operating system as a whole, it worked.

But in Obsidian, the problem continues.

Environment:

  • Operating system: Linux Pop!_OS 22.04 LTS (64 bits; GNOME version: 42.2; Window Manager: X11)
    Kernel Version: 5.17.15-76051715-generic
    Kernel Revision: #202206141358~1655919116~22.04~1db9e34
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v0.15.9
    Installer version: v0.14.15

This should had been considered as bug report rated at BLOCKER level than feature request. Now that primary clipboard handling is outright broken it basically halts the user experience. Random pastes corrupt my well organized documents, multiple times.
And then disabling primary clipboard globally is just fat lazy decision, fix your programā€™s mouse handling so it doesnā€™t trigger pasting when opening a new tab.

4 Likes

I have the same problem on Linux Mint 21.

same for me but with the difference that even if disabled in gnome tweaks, the problem persists outside of obsidian tooā€¦

Same for me! Finally discovered why I found random clobbered notes occasionally.

I researched how to disable middle click paste, and funny how it is extremely challenging since so baked into Xorg.

The following works for me and I run it as a user service:

while true; do
    xsel -fin </dev/null
done

This 100% disables middle click paste in all circumstances, strangely except for Obsidian.

The reproducer for the issue with Obsidian for me is very specific. Trying to copy random text doesnā€™t seem to reproduce it, but if I do

  • take screenshot
  • copy image to clipboard
  • middle click in obsidian repeatedly

then I get e.g.

![[Pasted image 20221004202731.png]]
![[Pasted image 20221004202745.png]]
![[Pasted image 20221004203311.png]]
![[Pasted image 20221004203314.png]]

Trying the same in another app that I can paste images (e.g. LibreOffice) I cannot paste images like this with middle click.

Edit: actually more details since Iā€™m finding the reproducer behaving weird.

  1. Close obsidian. Then open 2 vaults
  2. Copy image to clipboard
  3. Middle click in first vault (results in paste image)
  4. Middle click in second vault (nothing happens)
  5. Copy image to clipboard again
  6. Try middle click pasting just into second vault again (nothing happens)
  7. Do Ctrl+v in second vault (pastes image now)
  8. Now middle click in second vault (also pasting images now)

peculiar

1 Like

Obsidian is the only program where middle-click paste causes issues.

Iā€™ve now disabled middle-click paste only because of Obsidian. Iā€™d like to use it, but itā€™s so buggy in Obsidian, that I decided to disable it system-wide.

To successfully disable it in Ubuntu 22.04, I had to:

I really wish Obsidian would fix this bug (not a feature), since itā€™s the only program (that I use) that behaves badly. Iā€™d like to use middle-click paste in some other places, but not when opening a link in a new tab, or when closing a tab (i.e. when middle-click does something else rather than pasting).

2 Likes

I just wanted to add my 2 cents in here. Iā€™m not an Obsidian user but I was seriously considering switching my knowledge base software to Obsidian. I did a lot of research to find a good option and Obsidian kept coming to the top of my list.

I then decided to make the switch! But within 10 minutes of starting to add data into it, I encountered this bug (not a feature request).

The solution of disabling middle click paste across my entire system to avoid a bug in your software is laughable. I literally use it all day every day and there is no way that Iā€™m going to disable it. Itā€™s an important feature and if your software bugs out when I use the middle click then I just canā€™t use your software.

Itā€™s really concerning that this hasnā€™t been addressed in months. If this was a new issue, I would likely just wait to see what happened. But with this little attention about a very serious issue, Iā€™m just moving on.

2 Likes

I know this is important to you since you took the time to add your voice on the forum of a product you admittedly do not use.
But, consider the percentage of linux desktop users, consider the even smaller percent of those using linux with mouse-centric workflows and even smaller percent of that using middle click at all (I used linux as a daily driver for years, never used middle click).

Thanks for the reply!

Considering that the default in most Linux desktops is to have middle click paste enabled, you donā€™t have to ā€œuseā€ that feature to hit this bug. You could just be middle clicking in Obsidian to open a new tab or whatever and youā€™ll end up with random pastes of stuff that you may have highlighted previously.

Also, this is literally the ONLY app Iā€™ve ever used that had this kind of problem. Iā€™ve been a desktop Linux user for about 20 years now and this is the first time Iā€™ve ever run into this. Iā€™m not some purist that only runs OSS either. I have plenty of proprietary software installed on my computer.

Thatā€™s fine if it ā€œworks for youā€ and everything but I put a lot of time into my knowledge base and use it daily so I need something that is maintained well. i.e. if they are going to say they support Linux, then they actually should. Middle click paste is nothing new and literally everything else supports it fine, including other proprietary software (Google, Microsoft, Adobe, Valve, etc).

I already know based on how this thread has gone that this wonā€™t get fixed, and thatā€™s fine. I do wish that it would get fixed. But unfortunately, I will have to move on to other software that actually does support my system. :slight_smile:

4 Likes

We have looked into this. There are two issues

  1. You donā€™t notice this problems in other apps because other apps donā€™t do anything with the middle click or if the do donā€™t have the ambiguity of editing or opening a link.
  2. The way this middle click paste is triggered in Linux is different from the more common middle click trigger (shared among OSes). This makes overriding this action and writing cross-platform code harder.

Moved to bug reports. No ETAs on fixing this.

Thanks for the reply!

On point 1, thatā€™s definitely not true. I can actually think of several examples off the top of my head and all are file editors or note-taking apps and none have this problem. Here are 2 good examples:

VSCode
Libreoffice

Middle click paste works fine and also middle clicking on links works fine in those apps too. Again, this is the ONLY app Iā€™ve ever seen this behavior in.

Just to be clear, because Iā€™m not sure if you understand what the problem is. The problem is that when you middle click somewhere in Obsidian, it pastes at random places in the document. It took me a minute to notice it because the paste happens no where even close to where the middle click happens. Itā€™s kind of crazy!

On point 2, I canā€™t really speak to that. My coding ability is limited to server-side and command line stuff. I donā€™t write GUI apps so I canā€™t say how middle click is different from other OSs. But I can say that Iā€™ve never seen this kind of behavoir in any other app. And itā€™s not because none of the other apps I use arenā€™t similar to Obsidian (I am looking for a replacement for my old knowledge base software after all).

If you can fix this before I make a decision on different software then I may reconsider and use Obsidian. Thanks for at least looking into this. :slight_smile:

3 Likes

kde bug where itā€™s been discussed they canā€™t/wonā€™t create an option to disable middle click paste for X11: 441668 ā€“ Please make middle-click pasting optional

itā€™s weird how middle click paste was forced on all X11 users. I use the xsel -fin </dev/null workaround to disable middle click paste, e.g. just to avoid pasting sensitive info in apps where I use middle click a lot (e.g. opening tabs in chrome, or closing tabs with middle click then accidentally clicking the addressbar and poof pasted a whole load of stuff that google is now trying to search withā€¦), but as shared above, strange the workaround does not work for obsidian when it does for other apps.

I used linux as a daily driver for years, never used middle click)

Iā€™m curious, you donā€™t use middle click to open new tabs in your web browser? Or referring to middle click paste? For the latter I also would never want to use middle click paste.

1 Like

Since you asked, no. I try to drive with the keyboard, but also, I havenā€™t a mouse device with middle click since the 90s. ctrl-t for new tab.

1 Like

I think zerkshop was not referring to opening blank new tabs, but rather opening links on a page into a new tab by middle-clicking it. I personally use Ctrl+T for opening blank tabs, but middle click for links.

For me, this bug is most apparent in Obsidian when opening note links to new tabs either from the note itself or from the file list when another note is open.

I donā€™t think this is true. At least in Chrome I can be editing a text field and then middle-click a link at the same time. The link will open in a new tab, and nothing gets pasted in the active text field.

7 Likes

I second, @ecchina_ko s suggestion, that this ambiguity exists in browsers as well, and @proc1io s suggestion that similar issues donā€™t crop up in comparable situations in e.g. VSCodium (installed and verified it myself).

Where this issue conflicts most severely with my workflow, is when using middle clicks for closing open tabs. I could use Ctrl-W to close the one in focus, but over time a lot of ā€œsludgeā€ tabs build up, and I usually want to close a lot (but not all) of the ones that are NOT in focus. Middle-clicking them is the most intuitive way to do that for me, but that pastes into the focused note.

Also on general principles I can understand the scorn of vimmers and other special folk for any and all kind of mouse interaction with control interfaces, but OTOH I think if this can be fixed, and there are no more urgent or important problems, then it should be, because saying ā€œhey, you could just change your workflowā€ is not really a suitable answer when you could just fix the bug. Just my 5ct.

I did a little bit of digging, and stumbled over a somewhat similar issue in VSCode, in which one of the contributors explains how they suppress middle click paste on notifications.

Out of context code snippet for (in)convenience:

 this.inputDisposables.add(addDisposableListener(this.template.container, EventType.AUXCLICK, e => { 
 	if (!notification.hasProgress && e.button === 1 /* Middle Button */) { 
 		EventHelper.stop(e, true); 
  
 		notification.close(); 
 	} 
 })); 

I think the AUXCLICK Event fires on every non-primary mouse-button click, and thatā€™s where the secret sauce is made.
But since I donā€™t know all that much about java-/typescript in general, electron specifically, and the code bases of vscode and obsidian super specifically, I canā€™t say, whether this might help with designing a solution that fits obsidian, or if it is completely worthless, but here you go anyway.

BTW This Issue only popped up for me with the jump to 1.0.0 I think, because I didnā€™t have any tabs to close before :wink: Iā€™m going to keep using obsidian despite this, because itā€™s an awesome note-taking software, but this is a very annoying issue nevertheless.

I hope this helps, and thanks for the cool software!

PS:

Some anecdotal evidence, that Wayland also doesnā€™t solve the ā€˜problemā€™ (I actually like middle click paste a lot and use it daily) for some popular desktop environments.

7 Likes

Iā€™m experiencing this bug as well. Hope it getā€™s fixed soon, as it super annoying to find your notes messed up with random, unintentional pastes all the time.

Also, Iā€™ve never experienced these types of issues with VSCode, LibreOffice or any other application for that matter.

Environment: Linux Mint 20.3
Obsidian: v1.0.0

5 Likes

Steps to reproduce

  • Open two tabs (A and B)
  • Copy some content in the clipboard
  • Close tab B

Expected result

The content of tab A is not altered.

Actual result

The content of the clipboard is pasted in tab A

Environment

  • Operating system: Linux 5.15.0-52-generic #58-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.0.0
    Installer version: v1.0.0
    Operating system: #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 5.15.0-52-generic
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: light
    Community theme: none
    Snippets enabled: 0
    Restricted mode: on
5 Likes