[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
howtos:window_managers:keyboard_layout_in_i3 [2012/09/25 04:28 (UTC)] – moved from the general howtos namespace mfillpothowtos:window_managers:keyboard_layout_in_i3 [2014/04/26 12:09 (UTC)] – [Displaying the Active Layout in the Panel] sycamorex
Line 5: Line 5:
 ====i3 Window Manager==== ====i3 Window Manager====
  
-[[howtos:i3wm|i3wm]] does not come with stock Slackware. If you want to install this extremely configurable tiling window manager, please visit [[http://slackbuilds.org/repository/13.37/desktop/i3/|SlackBuilds]]. Make sure you also install [[http://slackbuilds.org/repository/13.37/desktop/i3status/|i3status]], which will let you display all sorts of useful information in a panel.+[[howtos:window_managers:i3wm|i3wm]] does not come with stock Slackware. If you want to install this extremely configurable tiling window manager, please visit [[http://slackbuilds.org/repository/13.37/desktop/i3/|SlackBuilds]]. Make sure you also install [[http://slackbuilds.org/repository/13.37/desktop/i3status/|i3status]], which will let you display all sorts of useful information in a panel.
  
 ====Setting the Keyboard Layout==== ====Setting the Keyboard Layout====
Line 55: Line 55:
 The contents of i3script.sh The contents of i3script.sh
  
-<code>#!/bin/sh+<code>#!/bin/bash
  
 # shell scipt to prepend i3status with more stuff # shell scipt to prepend i3status with more stuff
Line 62: Line 62:
 do do
         read line         read line
-        LG=$(setxkbmap -print | grep xkb_symbols | awk -F"+" '{print $2}'+        LG=$(setxkbmap -query | awk '/layout/{print $2}'
         echo "LG: $LG | $line" || exit 1         echo "LG: $LG | $line" || exit 1
 done</code> done</code>
  
-The above will display the current keyboard layout before the standard i3status functions. Obviously you can add much more to [[howtos:i3wm#i3status|i3status]].+The above will display the current keyboard layout before the standard i3status functions. Obviously you can add much more to [[howtos:window_managers:i3wm#i3status|i3status]]. 
 + 
 +=== Using JSON output format (colors) === 
 +The method above uses the simplest output mode (text only). Although easier to use, it lacks color support. For that, you'll need JSON. 
 + 
 +Add the following property in your ''.i3status.conf'' 
 + 
 +<code>general { 
 +    output_format = i3bar 
 +}</code> 
 + 
 +And replace your ''i3script.sh'' for the code below. It displays your default language in green (in the example, ''br'') and any other language in red. 
 + 
 +<code>#!/bin/bash 
 + 
 +i3status --config ~/.i3status.conf | while : 
 +do 
 +    read line 
 +    LG=$(setxkbmap -query | awk '/layout/{print $2}'
 +    if [ $LG == "br"
 +    then 
 +        dat="[{ \"full_text\": \"LANG: $LG\", \"color\":\"#009E00\" }," 
 +    else 
 +        dat="[{ \"full_text\": \"LANG: $LG\", \"color\":\"#C60101\" }," 
 +    fi 
 +    echo "${line/[/$dat}" || exit 1 
 +done</code> 
  
 ===== Sources ===== ===== Sources =====
 howtos:window_managers:keyboard_layout_in_i3 ()