Skip to content

Instantly share code, notes, and snippets.

View ItsProfessional's full-sized avatar

ItsProfesssional ItsProfessional

View GitHub Profile
@ItsProfessional
ItsProfessional / disable-mouse-paste.md
Last active April 21, 2024 11:46
Disable middle click pasting in Linux

Disable middle click pasting in Linux without breaking middle click functionality (X11/Wayland)

Context

  • Both X11 and Wayland have clipboard and primary clipboards. The clipboard clipboard stores the text you copy. The primary clipboard stores the text you select (not copy!) using the mouse.
  • When you paste using your keyboard, it pastes the text stored in the clipboard clipboard, but when you paste using middle click, it pastes from the primary clipboard.
  • The idea is to clear the primary clipboard, when you middle click so that nothing gets pasted, and we only clear the primary clipboard so the text you copied previously will remain as-is.

Clearing the "primary" clipboard on middle click

  • Install a key binding daemon that is capable of listening to mouse button clicks (middle click in our case) and executing shell commands. I personally recommend evsieve.
  • If you are using X11, make sure xsel is installed. If you are using Waylan
@ItsProfessional
ItsProfessional / keepenv.patch
Last active December 12, 2024 16:30
Pkexec patch to pass-through ALL environment variables as-is (warning: this is insecure and introduces vulnerabilities via environment variables like LD_PRELOAD and LD_LIBRARY_PATH)
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
index 65c1309..51329c9 100644
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -339,99 +339,6 @@ find_action_for_path (PolkitAuthority *authority,
return action_id;
}
-/* ---------------------------------------------------------------------------------------------------- */
-
@ItsProfessional
ItsProfessional / patch-discord.sh
Last active June 2, 2023 07:06
Pacman hooks for auto repatching discord without manual intervention (system electron, vencord, openasar)
#!/bin/sh
# Extract asar and rename original file
asar e /opt/discord/resources/app.asar /opt/discord/resources/app
mv /opt/discord/resources/app.asar /opt/discord/resources/app.asar.default -f
# Patch extracted asar
sed -i "s|process.resourcesPath|'/usr/share/discord/resources'|" /opt/discord/resources/app/app_bootstrap/buildInfo.js
sed -i "s|exeDir,|'/usr/share/pixmaps',|" /opt/discord/resources/app/app_bootstrap/autoStart/linux.js