Skip to content

Commit

Permalink
Fix link issue in the Lib. Add vimtest.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-mironov committed Feb 28, 2016
1 parent 7527a89 commit 3da7ebc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OPTION(BUILD_XKBSWITCH_LIB
if(BUILD_XKBSWITCH_LIB)
SET(xkblib xkbswitch)
ADD_LIBRARY(${xkblib} SHARED XKbSwitchApi.cpp XKeyboard.cpp)
TARGET_LINK_LIBRARIES(${xkblib} X11)
TARGET_LINK_LIBRARIES(${xkblib} X11 xkbfile)
endif()

ADD_CUSTOM_TARGET(ctags
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ Usage
VIM integration
---------------

Xkb-switch now contains a library libxkbswitch.so which can be called from
within Vim scripts. See this [article in Russian](http://lin-techdet.blogspot.ru/2012/12/vim-xkb-switch-libcall.html) for
details. Thanks to lyokha for contribution.
Xkb-switch goes with a library libxkbswitch.so which can be called from
within Vim scripts like this:

let g:XkbSwitchLib = "/path/to/libxkbswitch.so"
echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
call libcall(g:XkbSwitchLib, 'Xkb_Switch_setXkbLayout', 'us')

See also [article in Russian](http://lin-techdet.blogspot.ru/2012/12/vim-xkb-switch-libcall.html)
describing complex solution.

Layout groups
-------------
Expand Down
26 changes: 26 additions & 0 deletions vimtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

LIB=`dirname $0`/build/libxkbswitch.so

if ! test -f "$LIB" ; then
echo "$LIB not found. Try building it first" >&2
exit 1
fi

if ! which gcc ; then
echo "GCC not found" >&2
exit 1
fi

STDLIB=$(gcc --print-file-name=libstdc++.so)
export LD_LIBRARY_PATH="`dirname $STDLIB`:$LD_LIBRARY_PATH"

cat >/tmp/vimxkbswitch <<EOF
let g:XkbSwitchLib = "$LIB"
echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
call libcall(g:XkbSwitchLib, 'Xkb_Switch_setXkbLayout', 'us')
quit
EOF

vim -S /tmp/vimxkbswitch && echo OK

0 comments on commit 3da7ebc

Please sign in to comment.