Dear Alexis,
I uses the following code for rc.lua of 3.5:
////////////////////////////////////////////
kbdcfg = {}
kbdcfg.cmd = "setxkbmap"
kbdcfg.layout = { { "us"," " }, { "ir"," " } }
kbdcfg.current = 1 -- us is our default layout
kbdcfg.widget = wibox.widget.textbox()
kbdcfg.widget:set_text(" " .. kbdcfg.layout[kbdcfg.current][2]
.. " ")
kbdcfg.switch = function ()
kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
local t = kbdcfg.layout[kbdcfg.current]
kbdcfg.widget.text = kbdcfg.widget:set_markup(t)
os.execute( kbdcfg.cmd .. " " .. t[1] .. " " .. t[2] )
end
-- Mouse bindings
kbdcfg.widget:buttons(awful.util.table.join(
awful.button({ }, 1, function() kbdcfg.switch() end )
))
-- Alt + Right Shift switches the current keyboard layout
awful.key({ "Mod1" }, "Shift_R", function() kbdcfg.switch() end
)
-- Mouse bindings
-- Add widget to your layout
local right_layout = wibox.layout.fixed.horizontal() --init an
layout with wibox widget
local layout = wibox.layout.align.horizontal() --init another layout
layout:set_right(right_layout)
right_layout:add(kbdcfg.widget)
//////////////////////////////////////////////////////////////////////
My awesome is 3.5 and rc.lua doesn't any error with -k .
Regards,
Mohsen
On 12/05/2014 12:12 PM, Alexis Brenon
wrote:
Hi,
Of course, I send you the link for the latest default
awesomerc.lua wich only work for awesome 3.5 !
I agree with you, the Awesome API doc is sometime incomplete
or cryptic, but I remember that someone start to fix this (see
the mailing list archives).
So, sorry, I don't really understand your message but, does
all work well, or have you got any error again ?
Just some advice for your code :
- replace kbdcfg.widget.text = t with
kbdcfg.widget:set_markup(t)
- replace your function in awful.key and awful.button :
function () kbdcfg.switch() end become kbdcfg.switch
No more needed as your function doesn't require any
arguments. it increases the readability.
Regards,
Alexis
Le Thu Dec 04 2014 at 20:41:58, Mohsen
Pahlevanzadeh < moh...@pahlevanzadeh.org>
a écrit :
Oh by the way, i find api ref now.
On 12/02/2014 11:37 AM, Alexis Brenon wrote:
Hi Mohsen,
The { Mod1 }, Shift_R stand for the Alt modifier plus the
Shift key, but the right one, not the left one.
To make sure that the right keys are detected, you
can use the xev program (see the ArchLinux wiki page for a quick
guide). You can also add a notification in your switch
function to see if it is called :
kbdcfg.switch = function ()
naughty.notify({text = "Keyboard layout switch"})
kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) +
1
local t = " " .. kbdcfg.layout[kbdcfg.current] .. "
"
kbdcfg.widget.text = t
os.execute( kbdcfg.cmd .. t )
end
Regards,
Alexis
Le Mon Dec 01 2014 at 20:43:52,
Mohsen Pahlevanzadeh < moh...@pahlevanzadeh.org> a
écrit :
On 12/01/2014 11:49 AM, Alexis Brenon wrote:
Hi Mohsen,
Frome here, I don't see any particular error in
your code or anything. But maybe you can start
by remove some useless parts which can interact
with others or whatever.
Firstly, in your xorg.conf file, remove the
line :
> Option "XkbOptions"
"grp:shifts_toggle"
I commented at xorg.
This line, allow you to switch layouts with
the shift keys, but without any interaction
with Awesome (so your widget will not be
updated), it's not what you want, but it can
interfere.
Then, as you define your layout in the
xorg.conf file, you don't need to use
> setxkbmap
us,fa
in
your xinit.rc file. When X starts, it reads
the xorg.conf file and so this line is
useless.
I remove it from ~/.xinitrc
Finally,
you say that you can't change to persian
language, but I see 3 layouts in your
kbdcfg.layouts. Can you change between us
and fa, but not to Persian, or you can't
change at all. In both cases, try to execute
manually the commands in your terminal,
maybe setxkbmap will report you an error
(missing the -layout option, unrecognized
layout name, etc.).
Just
to finnish ; it's now recommended to not use
the xorg.conf file, but the xorg.conf.d/
folder with one file for each device.
Hopping
that it will help you.
Regards,
Alexis
Le Mon Dec 01 2014 at
03:21:46, Mohsen Pahlevanzadeh < moh...@pahlevanzadeh.org>
a écrit :
Dear all,
I migrate to awesome, But may be awesome
depend on X, At first i provided xorg.conf
with:
Xorg -configure
Then i changed InputClass such as :
///////////////////////////////////
Section "InputClass"
Identifier "keyboard0"
Driver "evdev"
#MatchIsKeyboard "on"
Option "XkbModel" "evdev"
# Switch between layouts by pressing both shift keys
Option "XkbLayout" "us,fa"
Option "XkbOptions" "grp:shifts_toggle"
EndSection
////////////////////////////////
Then :
cp /etc/xdg/awesome/rc.lua
~/.config/awesome/
Add the following change to it:
//////////////////////////////////////////////////
-- Keyboard map indicator and changer
kbdcfg = {}
kbdcfg.cmd = "setxkbmap"
kbdcfg.layout = { "us", "fa",
"Persian" }
I change abobe line to :
kbdcfg.layout = { "us", "fa"}
kbdcfg.current = 1 --
us is our default layout
kbdcfg.widget = widget({ type =
"textbox", align = "right" })
kbdcfg.widget.text = " " ..
kbdcfg.layout[kbdcfg.current] .. " "
kbdcfg.switch = function ()
kbdcfg.current = kbdcfg.current %
#(kbdcfg.layout) + 1
local t = " " ..
kbdcfg.layout[kbdcfg.current] .. " "
kbdcfg.widget.text = t
os.execute( kbdcfg.cmd .. t )
end
-- Alt + Right Shift switches the
current keyboard layout
awful.key({ "Mod1" }, "Shift_R",
function () kbdcfg.switch() end),
-- Mouse bindings
kbdcfg.widget:buttons(awful.util.table.join(
awful.button({ }, 1, function ()
kbdcfg.switch() end)
))
-- end by me
////////////////////////////////////////////////////////
Also i add the folloiwoing section to
layout:
/////////////////////////
right_layout:add(kbdcfg.widget)
//////////////////////////////////////////
Then i create a ~.xinitrc and pu into it:
//////////////////////////////////
#!/bin/sh
setxkbmap us,fa
///////////////////////////////
Also i put into the following code in rc.lua:
////////////////////////////////////////////
awful.key({ "Mod1" }, "Shift_R", function () kbdcfg.switch() end),
//////////////////////////////////////////////
I "have to" learn lua, But i don't know above line
(define hot key,) What's key binding for changing
layout?
mod+shift+R?
How can i find out which hotkey active is?
--Regard
Mohsen
But i can't change my keyboard language to persian language, how can i do it?
Where's my problem?
Please give me a link from key codes....
--Regards
Mohsen
-- To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.
--
To unsubscribe, send mail to awesome-unsubscr...@naquadah.org.
|