You are not logged in.

#1 2009-03-27 19:27:05

josomebody
Member
Registered: 2008-06-20
Posts: 190

Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

Has anybody done this? My eeepc 900 doesn't have keyboard leds, so it would be really useful for me to just have a couple of textboxes indicating whether capslock and numlock are on in the toolbar. If nothing else, does anybody know a way to read this status out of somewhere in /proc or wherever? I tried using setleds, but it doesn't work in X. It really makes a mess if I hit J repeatedly in vi not realizing capslock is still on.

EDIT: I threw together a quick and dirty wicked widget to do this, and a brief shell script to do the actual readings. It was pretty straight forward, but if anyone not too savvy with bash or lua ends up needing it I could post it here on request. Thanks a lot.

Last edited by josomebody (2009-03-28 20:14:06)


: () { : | :& } ;:

Offline

#2 2009-03-28 01:24:22

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

$ xset q | grep LED

Will tell you the status, each number coresponds to a state, caps, scroll, both. Writing a widget would be extremely easy and it would be a nice little exercise for you: http://awesome.naquadah.org/wiki/index. … nd_widgets  You could also allow changing states with mouse clicks (read man xset).


You need to install an RTFM interface.

Offline

#3 2009-03-28 02:22:39

josomebody
Member
Registered: 2008-06-20
Posts: 190

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

Cool I think that's all I'll need. Thanks a ton.


: () { : | :& } ;:

Offline

#4 2009-03-29 00:17:19

awfullyawesome
Member
Registered: 2008-08-23
Posts: 12

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

josomebody wrote:

Has anybody done this? My eeepc 900 doesn't have keyboard leds, so it would be really useful for me to just have a couple of textboxes indicating whether capslock and numlock are on in the toolbar. If nothing else, does anybody know a way to read this status out of somewhere in /proc or wherever? I tried using setleds, but it doesn't work in X. It really makes a mess if I hit J repeatedly in vi not realizing capslock is still on.

EDIT: I threw together a quick and dirty wicked widget to do this, and a brief shell script to do the actual readings. It was pretty straight forward, but if anyone not too savvy with bash or lua ends up needing it I could post it here on request. Thanks a lot.

this is a great idea!
i would love to see the script smile

Offline

#5 2009-03-29 00:34:47

josomebody
Member
Registered: 2008-06-20
Posts: 190

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

There's really not much to it.
My shell scripts is just called leds

#! /bin/bash
ledstate=`xset q 2>/dev/null | grep LED`  
ledstate=`echo $ledstate | sed s/[^1-9]//g`  
case "$ledstate" in
        '1')
        echo "C."
        ;;
        '2')
        echo ".N"
        ;;
        '3')
        echo "CN"
        ;;
        *)
        echo ".."
esac

In mine, C=capslock on, N=numlock on, and dots for not on. I have no use to scroll lock. you can change that as needed in the case...esac echos.

And be sure to require "wicked" in your rc.lua and have wicked installed, then the actual widget is like

myledbox = widget({ type = "textbox", name = "myledbox" , align = "right" })
function run_script()
        local filedescripter = io.popen('leds')
        local value = filedescripter:read()
        filedescripter:close()
        return value
end

wicked.register(myledbox, run_script, "$1", 1)

That updates every second. Change the last value in the wicked.register() statement to speed it up or slow it down, and then just include it somewhere in your list of stuff in the toolbar.


: () { : | :& } ;:

Offline

#6 2009-03-29 18:37:39

awfullyawesome
Member
Registered: 2008-08-23
Posts: 12

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

thank you.
i have a problem though. when i make the bash script executable then awesome3 will crash/freeze.

Offline

#7 2009-03-29 20:59:39

josomebody
Member
Registered: 2008-06-20
Posts: 190

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

Do you have wicked installed? Follow the wicked widgets guide on awesome's wiki, make sure there aren't any typos or mistakes in your rc.lua.


: () { : | :& } ;:

Offline

#8 2009-03-30 19:49:02

awfullyawesome
Member
Registered: 2008-08-23
Posts: 12

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

i dunno everytime i called xset from wicked, awesome would just freeze... ??
i worked it around by basically calling it from awful.hooks writing the output of your leds script to a file then output it with wicked.

thanks though smile

Offline

#9 2009-03-30 20:44:51

josomebody
Member
Registered: 2008-06-20
Posts: 190

Re: Capslock, Numlock indicators in awesome3 toolbar?[SOLVED]

Oh you were doing differently from me. The first script I put up is a bash script, then all wicked got was the output of that script (in the form of echo's).


: () { : | :& } ;:

Offline

Board footer

Powered by FluxBB