You are not logged in.

#1 2012-09-21 13:18:11

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

[SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

Hey, I've got an emachines laptop that doesn't have any LED indicators for the lock keys (numlock, capslock and scrolllock) and it's pretty frustrating when you type a password four times and have to switch out to some other text entry to check if capslock is on. Is there any systray applets or something to show their status onscreen? I'm running MATE. I tried lock-keys-applet in the AUR but it won't build for gnome 2 dependencies.

EDIT: This is essentially what I want, but this is for windows http://www.binaryfortress.com/TrayStatus/ (I'm so desperate I tried it under wine sad )

Last edited by MisterAnderson (2012-09-22 15:39:05)


D:

Offline

#2 2012-09-21 13:46:56

xinit
Member
Registered: 2011-11-12
Posts: 23

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

Hello,

perhaps this is an option for you?
AUR: key-mon

check this: http://stackoverflow.com/questions/1005 … keyboard-h

Offline

#3 2012-09-21 13:59:57

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

That would be ok, but other than it being constantly onscreen, it also doesn't constantly show it. I was think more an applet who's icon had some sort of indicator, like maybe NCS and each changed colour when they were on or off. key-mon seems to be designed for recording what you're doing in a screencast.


D:

Offline

#4 2012-09-22 12:37:14

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

I've been trying the suggestions here: http://ubuntuforums.org/showthread.php?t=1348042&page=3
They create a script and link it as a shortcut in CCSM to capslock. Unfortunately I have no idea how to link it to a keyboard key in MATE (or Gnome 2 for that matter).
Here is the script I've got:

#!/bin/bash
icon="/usr/share/icons/gnome/scalable/devices/keyboard.svg"
case $1 in
  '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 is on"
else
  output="$key Lock is off"
fi
notify-send -i $icon "$output"

I ran it manually from the terminal with lock_keys caps but no notification appears. I can't remember the last time a notification appeared for anything though, so maybe they're not working.


D:

Offline

#5 2012-09-22 13:39:31

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

It looks like notifications are broken in Mate 1.4 so that's why the script isn't working when called manually. It doesn't matter because I can't see how to map it to a keyboard key anyway.

I found keybled in the AUR which would also do the job, but after installing over 200MB in kde dependencies it doesn't install anyway due to being based on KDE3... Getting really frustrated that something small like this is so hard to do apparently.

EDIT: added edit to the first post with an example of what I'm looking for.

Last edited by MisterAnderson (2012-09-22 13:50:15)


D:

Offline

#6 2012-09-22 15:01:13

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

Ok, I've got a working solution now. All credit goes to http://ubuntuforums.org/showthread.php?t=1348042 where I got the script (bottom of first page), I edited it slightly to make notification only show for one second. I also added "sleep .2" to the start because otherwise it would constantly say capslock was on. You may need to make this delay longer if this happens to you.

Create a file "lock_keys" and throw this in there:

#!/bin/bash
sleep .2

icon="/usr/share/icons/matefaenza/devices/scalable/keyboard.svg"
case $1 in
  '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 is on"
else
  output="$key Lock is off"
fi
notify-send -t 2000 -i $icon "$output"

Then run "chmod +x lock_keys" - you can chown this to root if you like but I didn't bother.

Copy the file to /usr/bin/lock_keys (optional)

Now this is where it gets tricky. You can't directly map to CapsLock so you have to create a link or something for it.

Open ~/.Xmodmap and add this (just create the file if it isn't there):

keycode 66 = XF86Launch0

Change the keycode if it doesn't work for you. You can get your capslock keycode by running "xev" in a terminal and pressing capslock then checking the output in the terminal.

Now run mateconf-editor
Navigate to apps -> marco -> keybinding_commands and edit command_1 (or whatever) to have the value "/usr/bin/lock_keys caps".
Navigate to apps -> marco -> global_keybindings and find run_command_1 and change the value to "XF86Launch0".

Now reboot and you'll get a notification whenever you press capslock! I assume this works for all systems with some form of notification daemon. You'll just have to change how you map capslock to the command. I couldn't get /usr/bin/lock_keys num to work with numlock because mapping it stopped numlock working, but I don't really need it anyway.

Change the icon directory! There's a good chance you don't have my icon theme installed. If you don't want an icon just point at something like "/not/real/icon".

Note: mate-notification-daemon 1.4 doesn't appear to work so downgrade to 1.2 if you are running it.

Last edited by MisterAnderson (2012-09-22 15:37:50)


D:

Offline

#7 2012-09-25 14:49:30

kpiche
Forum Fellow
From: Ottawa, ON, Canada
Registered: 2004-03-30
Posts: 246
Website

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

There's the lock-keys-applet for GNOME2 in the AUR.

Offline

#8 2012-09-27 12:12:55

MisterAnderson
Member
Registered: 2011-09-04
Posts: 285

Re: [SOLVED]Laptop w/ no lock keys LEDs, is there a systray applet for it?

kpiche wrote:

There's the lock-keys-applet for GNOME2 in the AUR.

MisterAnderson wrote:

I'm running MATE. I tried lock-keys-applet in the AUR but it won't build for gnome 2 dependencies.


D:

Offline

Board footer

Powered by FluxBB