7

Update: My main goal is to change the function (or even turn off) the CAPSLOCK key.

At work, we have a long domain name. I'm lazy. I'd like to map my CAPSLOCK key to type out a string such as "outlongdomain.com". This is only to save me from typing.

I've seen numerous questions about how to remap the key to a different function. While neat; I couldn't see how to tell the system to "print out these next set of letters where the cursor has focus."

Update: I would like to use Autokey but I don't see an option for CAPSLOCK enter image description here

5
  • See the section on autokey in askubuntu.com/questions/254424/…
    – user68186
    Jan 29, 2015 at 16:46
  • Great Utility but I don't see an option for CAPSLOCK
    – Rick
    Jan 29, 2015 at 17:21
  • 1
    Why not create a .desktop file that will open firefox or other browser of your choice on that domain ? Or create a separate shortcut on another key ? Want me to post that as answer ? Apr 13, 2015 at 20:38
  • @Serg I've never created a desktop file. Yes, I'm looking for a working solution in gnome shell.
    – Rick
    Apr 13, 2015 at 20:39
  • I'm pretty sure that capslock is a hardware key, and can't be reassigned, kind of like the fn key. Apr 15, 2015 at 23:23

5 Answers 5

4
+50

If you can be satisfied with it just being disabled, here's what you can do.

  1. Run sudo apt-get install gnome-tweak-tool.
  2. Open Tweak Tool by searching for it in the Dash.
  3. Select the Typing menu and change Caps lock key behavior to Disabled.

Example

Source: https://mkaz.com/2014/02/08/disable-caps-lock-in-ubuntu/

2
  • works even in Ubuntu 16.10! Oct 25, 2016 at 19:03
  • this solution is easy but incomplete, this will only work under gnome applications, and won't work, for example, in wine applications Oct 27, 2018 at 11:27
2

To remap the Capslock to something like Control, Esc, I'd recommend using the gnome-tweak-tool.

Open the Tweak Tool application or press Alt-F2 and run gnome-tweak-tool.

Select the "Typing" tab, and change the dropdown for Caps Lock key Behaviour.

Here's how it looks on my system:

The Gnome Tweak Tool on the 'Typing' Tab.

Now for making a key combination to type "outlongdomain.com":

I have scoured the internet for an answer to this question, but I haven't found anything straightforward, so here's my workaround idea using the xclip package:

Open Settings > Keyboard > Shortcuts > Custom Shortcuts and add a shortcut. Name it whatever you want, and use this command:

echo "hello" | xclip -selection clipboard

But replacing "hello" with your long domain name that you want to type. Now just click the Disabled text on the shortcut and set it to whatever you set your Capslock key to.

Now when you use the new keyboard shortcut, that long domain name will instantly be copied to your clipboard, ready to use with Ctrl-V

1
  • I have been using xmodmap since early X-windows days, and this still works flawlessly. Run man xmodmap and you should get some good examples. For console (i.e. /dev/tty*), you can use dumpkeys and loadkeys combo to manipulate key-mapping. However, if you are using GNOME, gnome-tweak-tool is the most simple solution and will save you lots of hassle. Oct 15, 2017 at 16:33
1

Solution #1:

Create a new shortcut in System Settings -> keyboard -> shortcuts tab -> custom shortcuts, click + in the lower left, and name it whatever you like. For command type `firefox yoururl.com. enter image description here

Next , assign the buttons by clicking on the right side once, and pressing the buttons you want

enter image description here

Solution #2

Make sure you enable "Run executable files" in file manager preferences, create a text file on your Desktop with the following contents

#!/bin/sh
firefox yourlongurl.com

Now, in terminal (CtrlAltT), make that file executable by running sudo chmod +x Desktop/yourfilename.

Now you can double click on that file as if it were a shortcut.

Solution #3

With AltHOME buttons you can access homepage in firefox so you can also set your long URL as bookmark or home-page in firefox or whatever browser you use.

1
  • Good but I specifically want to map the CAPS LOCK key and replace it's functionality.
    – Rick
    Apr 15, 2015 at 19:28
1
  • Check keycode of Caps key:

    1. Run:

      xev -event keyboard
      
    2. Press/Release Caps key.

  • To disable Caps_Lock

    1. Create ~/.xmodmap file contains

      remove Lock = Caps_Lock
      keycode 66 =
      
    2. Add this line to ~/.xinitrc to be run on startup

      xmodmap .xmodmap
      

    If you want test run xmodmap .xmodmap in the terminal.

  • Assign long string to its key

    1. Install xbindkeys & xautomation
    2. Create ~/.xbindkeysrc file contains

      "xte 'str outlongdomain.com'"
        Release + c:66
      
    3. Add this line to ~/.xinitrc to be run on startup

      xbindkeys
      

    As above, to test run it in terminal.

References:

0

Why so complicated?

Just use an ALIAS for this. And for everything else that get's on your nerves, too.

It's easy to do, auto-loaded with the bash and you can even choose your own name for it. It so much fun and so easy to make.

You just need a file, and your command

Go into your home folder and create the file put an ALIAS into it. As an example

echo "ALIAS hp='wget http://thisisareallongnameforanurl.com'" > /home/${USER}/.bash_aliases

then to directly use it, do

source .bash_aliases

I called the ALIAS hp. So you just type hp into a terminal and your command will be executed.

This works with any command or script.

To autoload the aliases when you open a terminal, make sure that the following section in your .bashrc file is not commented out.

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

but AFAIR correctly it's on by default.

To add more just

echo "ALIAS hp2='wget http://thisurlisevenmuchlongerthenthefirsone.com'" >> /home/${USER}/.bash_aliases
2
  • My main goal is to remap my CAPS LOCK key. At this point I'd be happy to remap it to TAB.
    – Rick
    Apr 16, 2015 at 13:29
  • 1
    another way would be to bet on a logitech g15 gaming keyboard. these are older but supported. you have 18 programmable keys and a small display you could use. check it
    – s1mmel
    Apr 16, 2015 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .