Advertisement
Guest User

less verbose output of keymap_switch

a guest
Nov 10th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. local function get_current_keymap()
  2.     local fd = io.popen("setxkbmap -query")
  3.     if not fd then return end
  4.  
  5.     for line in fd:lines() do
  6.         if line:match("layout:") then
  7.             local keymap = line:match("%s+.*")
  8.  
  9.             fd:close()
  10.             if not keymap then
  11.                 return "unknown layout"
  12.             else
  13.                 return keymap:gsub("%s", "")
  14.             end
  15.         end
  16.     end
  17.  
  18.     fd:close()
  19.     return "unknown layout"
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement