You are not logged in.

#1 2011-04-07 01:46:31

thelastknowngod
Member
Registered: 2008-01-11
Posts: 110

Awesome Window Manager Caps Lock icon

i just got a thinkpad x120e. there is no led for when the caps lock key is on.

does anyone know if there is a way to show an icon in the wibox when the caps lock is on?

Offline

#2 2011-04-07 09:19:20

kowalski
Member
Registered: 2009-05-07
Posts: 82

Re: Awesome Window Manager Caps Lock icon

Well, you could use a combination of xbindkeys and awesome-client.

You will need a icon named "capslockicon" of widgettype "imagebox".

Bind the following shell script to Caps_Lock in .xbindkeysrc.

#! /bin/bash

status=$(cat /tmp/capslock)

case $status in
    0)
        echo 1 > /tmp/capslock
        echo "capslockicon.visible = true" | awesome-client
        ;;
    1)
        echo 0 > /tmp/capslock
        echo "capslockicon.visible = false" | awesome-client
        ;;
    *)
        echo 1 > /tmp/capslock
        echo "capslockicon.visible = true" | awesome-client
        ;;
esac

I haven't tried this yet, so let me know if it doesn't work or something.

Cheers


He who says A doesn't have to say B. He can also recognize that A was false.

Offline

#3 2011-04-09 16:48:02

greyscale
Member
From: Sweden
Registered: 2011-01-02
Posts: 59

Re: Awesome Window Manager Caps Lock icon

You could also check it with a little help from xset

#!/bin/bash
# Here's a example in bash, doesn't do much more then just echo on or off

CAPS_STATE=$(xset q)
PATTERN='Caps Lock:\s+(on|off)'

if [[ "$CAPS_STATE" =~ $PATTERN ]]; then
  # Match
  echo ${BASH_REMATCH[1]}
  exit 0
else
  # Nothing...
  exit 1
fi

You could call that shellscript for your widget to get caps lock's state.

Or you could run xset q directly from lua in your widget and
take care of it there and have one script less to care about wink

Since I haven't done anything else in lua other than the settings
for awesome.. this can likely be done better wink

function caps_is()                                                                                                          
  local f = io.popen("xset q")                                                                                              
                                                                                                                            
  for line in f:lines() do                                                                                                  
    local _, _, caps_state = string.find(line, 'Caps Lock:%s+(%w+)')                                                        
                                                                                                                                                            
    if caps_state ~= nil then                                                                                               
      f:close()                                                                                                             
      return caps_state                                                                                                     
    end                                                                                                                     
  end                                                                                                                       
                                                                                                                            
  f:close()                                                                                                                 
  return "unknown"                                                                                                          
end

A tiling window manager simply manages your windows, not just letting you have em
:: Configs etc @GitHub

Offline

Board footer

Powered by FluxBB