9

I am trying to set which calculator will be called when I press the calculator button on the keyboard. My favourite calc app is Qalculate.

How can I set it be the default one so I can open it via calc button on my keyboard?

  • 2
    the exact same question was asked here – Wilf Dec 31 '13 at 10:10
  • 1
    @wilf Thanks. I posted my solution for further reference and help to others. – ubuntico Jan 2 '14 at 20:34
  • I didn't add the smiley - :-) – Wilf Jan 2 '14 at 20:47
8

I came here to find an answer which doesn't include moving around executables and creating links. Then realized that the answer is actually very simple and obvious:

Go to settings and create a custom key binding for whichever calculator app you want and calc key. Let it disable the old one. And that's it :)

2

The best option IMHO is to redefine the keybinding of the Calculator key, just as @user58635 said.

In order to make it more programatically, for example to include in a script to be executed after a new installation, these steps may be useful for more than one:

  1. Set the current binding to none:

    gsettings set org.gnome.settings-daemon.plugins.media-keys calculator ''
    
    • Or you can set it to another keybinding, e.g. pressing Shift+Calculator:

      gsettings set org.gnome.settings-daemon.plugins.media-keys calculator '<Shift>Calculator'
      
  2. Create a new custom keybinding for the Calculator key1:

    1. If you have no other custom keybinding:

      # Create a new set of custom keybindings
      gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
      
      # Set the new custom keybinding (key, command, name)
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding 'Calculator'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command 'qalculate-gtk'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'Qalculate'
      
    2. If you already have some custom keybinding in operation, you must add this as another one. For example:

      # Create a new set of custom keybindings
      gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']"
      
      # Set the first custom keybinding (key, command, name)
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding 'Launch5'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command 'iceweasel -ProfileManager -no-remote'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'Iceweasel'
      
      # Set the second (new) custom keybinding (key, command, name)
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding 'Calculator'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command 'qalculate-gtk'
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name 'Qalculate'
      
  3. If nothing happens at first try, just restart Gnome. In Gnome Shell it is just Alt+F2 and then press r+Enter


References:

1: Take this excellent answer as advice: https://askubuntu.com/a/597414/17564

2

I solved it following the link in this comment by @Wilf to this Ubuntu Forums thread

Ubuntu 13.10 uses the calculator tool gnome-caculator. So instead of messing with the system, the easiest is to fake this shortcut with a symbolic link bound to qalculator tool.

sudo mv /usr/bin/gnome-calculator /usr/bin/gnome-calculator_original
sudo ln -sT /usr/bin/qalculate /usr/bin/gnome-calculator

The shortcut works instantly.

  • Upgrading gnome-calculator may cause this to break by overwriting the symlink with an upgraded version of gnome-calculator. Updating a keyboard shortcut that goes directly to qalculate is recommended instead. – Mark Stosberg Aug 14 '19 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.