Skip to content

Instantly share code, notes, and snippets.

@jdmallen
Created February 4, 2025 14:38
Show Gist options
  • Select an option

  • Save jdmallen/15db795479091fbf582140008644ee60 to your computer and use it in GitHub Desktop.

Select an option

Save jdmallen/15db795479091fbf582140008644ee60 to your computer and use it in GitHub Desktop.
GNOME desktop shortcut to switch primary mouse button (I'm ambidextrous and switch often), written for Ubuntu 24.04.1
# Place in ~/Desktop
[Desktop Entry]
Type=Application
Name=Toggle Mouse Button
Exec=zsh -c "~/bin/toggle-primary-mouse-button.zsh"
Icon=/usr/share/icons/Adwaita/scalable/devices/input-mouse.svg
Terminal=false
Categories=Utility
#!/bin/zsh
# Place in ~/bin
current_button=$(gsettings get org.gnome.desktop.peripherals.mouse left-handed)
if [[ $current_button == "true" ]]; then
echo "Switching to right-handed mode..."
gsettings set org.gnome.desktop.peripherals.mouse left-handed false
notify-send -e -u normal -c device -i "🖱<fe0f>" -a "Toggle Mouse Button" "Mouse Button Switched" "Primary mouse button is now:\rLEFT (Right-handed) 🖱"
else
echo "Switching to left-handed mode..."
gsettings set org.gnome.desktop.peripherals.mouse left-handed true
notify-send -e -u normal -c device -i "🖱<fe0f>" -a "Toggle Mouse Button" "Mouse Button Switched" "Primary mouse button is now:\rRIGHT (Left-handed) 🖱"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment