Welcome to the Slackware Documentation Project

Devastator, Scroll Lock and I3WM keyboard

I recently received a donation from cryptographic friend Ayr, a Devastator CM-STORM keyboard from Cooler Master.

A keyboard that is beautiful, soft and enjoyable to use. However I faced a very annoying problem on my I3wm. Because it is a keyboard that has LEDs, its function works through Scroll Lock.

And each time I pressed Scroll Lock the keyboard was locked and I couldn't move through the Virtual Desktops with my bind (windows). That is, to get to work I needed to use the LED off.

This problem was not noticeable in Xfce and Kde, but in I3wm there was no way to continue with the game.

So I started thinking and banging my head what would be the best solution to solve my problem. The first idea was to remap the keyboard! But pissed work eh?

So I decided to appeal to Shell Script and with a few steps I was able to solve my problem temporarily.

With a simple Find Value Scroll Lock recipe and create a script, your problem will be solved!

Disabling Scroll Lock

The first joke is to use the xev command, you will need to enable and disable Scroll Lock to be able to see its value. To do this send the output to a file for better visibility. After that we will use grep to filter and awk to get only the fields we need.

$ xev > result
$ grep "Scroll" result | awk '{print $3,$4}'
keycode 78

Or if you prefer you can take the exit uncut.

$ grep "Scroll" result
state 0x30, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,

Note that the Scroll Lock Keycode is 78, let's now disable Scroll Lock, so you won't have any problems with it.

For this purpose we will use thexmodmap command, its syntax is: xmodmap -e 'keycode <value> = <action>' .

In <value> you will use the value captured with the xev command, and after the = sign you will leave it blank.

$ xmodmap -v -e 'keycode 78='
! 1:  keycode 78=
        keycode 0x4e =
!
! executing work queue
!
        keycode 0x4e =

The Colorful Script

To make our life easier I created a script which should be executed in the graphical interface auto-start! For TTY or Non-GUI environments, you will need another recipe.

In the led_off variable, notice that the value is 00000000. This returns when all keyboard LEDs are off!

If in case you need to find another return type use the command:

xset -q | grep "LED" | awk '{print $10}'

If not you can follow.

#!/usr/bin/env bash
#==================HEADER============================================|
#AUTOR
# Jefferson Rocha
#
# Resolve o problema para ativar o led no teclado CM-DEVASTATOR
# Cooler Master Devastator - LED Gaming Keyboard 
#====================================================================|

#=======================VARS

led_off='00000000'
key_code='78'

# LED Mask
LED_STATUS=$(xset -q | grep "LED" | awk '{print $10}')

# Scroll Lock off
xmodmap -e 'keycode ${key_code}='

# On
if [[ "$LED_STATUS" = "${led_off}" ]]; then
    xset led 3 # on LED
else
    xset -led 3 # off LED
fi

exit 0

Give execute permission and send the script to /usr/bin for global access.

# cp led_devastator /usr/bin/

Now let's add in the i3 configuration file, .config/i3/config present in your user's home the following command:

exec led_devastator

And now, your keyboard will now have the led on without problems. Just restart your interface and have the led color your life.

Sources


In Other Languages
Translations of this page?:
QR Code
QR Code howtos:misc:devastator_scroll_lock (generated for current page)