Ubuntu keyboard shortcuts - two-part question

Posted by Don on Ask Ubuntu See other posts from Ask Ubuntu or by Don
Published on 2012-06-16T13:07:13Z Indexed on 2012/06/17 9:23 UTC
Read the original article Hit count: 310

Filed under:

Background: I come from a Windows background and just started dual-booting Ubuntu (my first Linux experience) about 4 days ago. So my systems are Windows 7/Ubuntu 12.04, and so far I'm loving Ubuntu.

I am a dedicated mouse-abolitionist (trackpads are hell) and do most of my browsing and navigation with keyboard shortcuts. However, on switching to Ubuntu, a lot of my keyboard shortcuts are gone, and my productivity has resultantly taken a huge hit anytime I am using Ubuntu.

Problem 1: My computer was designed to display on-screen notifications for a second when I hit caps-lock or num-lock, and there are no constant indicators of the lock status (LEDs, etc). In Ubuntu, the keys still worked, but the notifications were gone.

Googling got me a tutorial on key-binding(Compiz) and scripts, so now I have capslock and numlock running this script:

#!/bin/bash
icon="/usr/share/icons/gnome/scalable/devices/keyboard.svg"
case $1 in
 'scrl')
 mask=3
 key="Scroll"
 ;;
 'num')
 mask=2
 key="Num"
 ;;
 'caps')
 mask=1
 key="Caps"
 ;;
esac
value=$(xset q | grep "LED mask" | sed -r "s/.*LED mask:\s+[0-9a-fA-F]+([0-9a-fA-F]).*/\1/")
if [ $(( 0x$value & 0x$mask )) == $mask ]
then
 output="$key Lock"
 output2="On"
else
 output="$key Lock"
 output2="Off"
fi
notify-send -i $icon "$output" "$output2" -t 1000

But, whether turning it off or on, the notifications always say that I have turned it on. Is there an easy fix for this, or an easier way to work it to get it do display the CORRECT notifications?

Problem 2: I'm not sure if this is because of my keyboard or Ubuntu. In Windows, I use Chrome and use the ctrl+pgUp/pgDwn shortcuts quite a bit to switch between tabs. On my keyboard, I can enter pgUp and pgDwn by either disabling NumLock and hitting 9 or 3 respectively on the 10key. Alternately I can hold the fn key and hit up or down arrow.

The first method is the one I very heavily relied upon, and it works in Firefox for Ubuntu, but not in Chrome nor in Chromium.

The second method (ctrl + fn + up/down) works fine in Chrome. However, I'd dearly like to find a method to make the first method work. Any suggestions?

Thanks in advance for your help.

Update: @julien: I've checked the keyboard layout options - I didn't find anything that seemed useful for this goal.

@Marty: The script runs once when the button is pressed. In Compiz, I've tied those two keys to the script, so when I press the button, it runs the script with the button pressed as a parameter.

Update: @elmicha: Thanks. That one works a lot better, and it even pops an icon into the status bar when caps lock is on. There's still a very slight problem in that if I quickly tap the key twice, the image will show that it has been turned on and then turned off, and the notifaction will come and go from my status area, but the text of both notifications will be "Caps Lock on". Same with Num Lock. However, if the time between presses is long enough for the first notification to disappear, everything displays correctly. Given how quickly the notifications disappear, I don't expect this will pose too much of a problem for me.

© Ask Ubuntu or respective owner

Related posts about shortcut-keys