Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

16 March 2018

Capture audio input + output with pulseaudio

I just wanted to capture a hangouts talk with my friend and got back to an old problem - how to properly record a call so that both myself and my companion can be heard.

Solution is courtesy to this youtube video and for own use I made a script out of it.



03 May 2016

Make 'Open class' dialogue of IntelliJ IDEA behave under Awesome WM

There is a quite well known [in narrow circles]  problem in IntelliJ IDEA (as well as other Jetbrains products) with 'Open class'\'Open file' dialogues (AKA Ctrl+N\Ctrl+Shift+N): in some environments the dialogue tend to often disappear\close as you type. For other environments this problem just never happens.

Recently it was demystified for me with the help of Jetbrains developers and support and the community. There appeared to be a long-hanging issue regarding this weird behaviour IDEA-65043. And once it gained some more attention at least exact conditions triggering the issue were discovered.

The problem was caused by sloppy focus (AKA focus-follows-mouse) which is the default in some environments among which Awesome WM is. Now it can easily be solved!

I'm using default configuration of Awesome WM 3.5.9 as a base (which can be found in /etc/xdg/awesome/rc.lua).

Somewhere in the bottom there is a snippet we're looking for

-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
    -- Enable sloppy focus
    c:connect_signal("mouse::enter", function(c)
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
            and awful.client.focus.filter(c) then
            client.focus = c
        end
    end)
This is the sloppy focus implementation. Need to introduce a flag to switch it on\off. Change it to:
-- {{{ Signals
-- Signal function to execute when a new client appears.
sloppyFocus = true
client.connect_signal("manage", function (c, startup)
    -- Enable sloppy focus
    c:connect_signal("mouse::enter", function(c)
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
            and awful.client.focus.filter(c)
            and sloppyFocus then
            client.focus = c 
        end 
    end)

Now we have a switch, and we need to turn it off while we're working with IDEA (or WebStorm, etc) and the turn back on when we're off it. Find awfule.rules section in your config (for me it's right above the sloppy focus implementation snippet) and add a new rule:

{ rule = { class = "jetbrains-%w+" },
      callback = function(c)
          c:connect_signal("focus", function (client)
              sloppyFocus = false
          end)
          c:connect_signal("unfocus", function (client)
              sloppyFocus = true
          end)
      end
    },
This matches any window of virtually any Jetbrains' product and switches sloppy focus off while it's focused, then switches sloppy back on when focus leaves IDE.

Thanks awesome Awesome developers for allowing patterns in rule preconditions! :-)

22 October 2015

Pulseaudio server in Docker container

The full title should actually read Pulseaudio server in docker container on Raspberry PI 2, but this doesn't really matter.

In short here it is:

Now everything one by one:
  • docker run --rm -ti - run non-persistent docker and prepare it as interactive (shell) run
  • --device=.... make local sound devices available in container. This feature is quite new in docker, so make sure you have recent version (mine is 1.8)
  • -p 4713:4713 set up port forwarding between host and container to make pulse server available to clients 
  • rpi-deb-pulse is my docker image built from armbuild/debian by running system upgrade and install pulseaudio
  • /bin/bash -c "..." is command to run inside container, more on this below
  • groupadd --gid $(...) alsadev create a group inside container named alsadev and having same id as group of /dev/snd/controlC0 device. We need this to allow pulse to access native alsa devices.
  • $(ls -l /dev/snd/controlC0 | cut -d' ' -f4 | xargs getent group | cut -d: -f3) this subshell is executed on host, not in container and prints group id of /dev/snd/controlC0
  • gpasswd -a pulse alsadev adds user pulse to our new group alsadev
  • pulseaudio ... run pulseaudio
  • -L 'module-alsa-sink device=hw:0,0' explicitly load alsa sink and specify which output to use
  • -L 'module-native-protocol-tcp auth-ip-acl=10.2.0.0/24' load tcp protocol listener and (optionally) configure ip-acl to only accept connections from given subnet

How to then use it to play sound remotely (client):
  1. pactl load-module module-tunnel-sink server=10.2.0.1
  2. in pavucontrol on Playback tab select desired sink for a stream
Things to improve:
  • list of devices may be replaced with another subshell to not specify each dev manually
  • add systemd unit to start container automatically
  • tune pulseaudio since sound over tcp tunnel is worse then playing locally
Why was this done :)
I have a Raspberry Pi 2 acting as a wireless router and i didn't wont to install pulse into host system. And i was just curious about whether this will work :)

09 March 2015

Seesu.me, dwb & vk.com

Rather a useless post, but it was fun for me to find all these out.

The story

seesu.me is an awesome online media player or radio or whatever you call it. Just give it try.
dwb is a minimalistic vim-imsnpired browser.
And vk.com is popular (at least in xUSSR countries) social network.

What brings them all here is that there is large music collection available on vk.com which can be very nicely listened to with seesu.me. But me problem was that vk login button wasn't working in dwb browser.

The solution

In short i needed to do the following:
  1. open dev console (dwb is based in webkit, so there is on) to find the login button
  2. check if clicking on it programatically would work
  3. if yes, all done - i'll login to vk, login will be remembered and nothing to worry about
Pressing standard Ctrl+Shift+I didn't worked. With google on my hands i found man 1 dwb which states that enable-developer-extras need to be enabled. I had no idea what it was, playing with command completion in dwb itself didn't helped as well. Again googling i found that option in ~/.config/dwb/settings (close dwb, then edit and save the file, then run browser again).

After that dev console popped up on :wi command, but unfortunately each time it shows up it crashes the whole browser.

I had to pick firefox to check if triggering click programmatically would do the trick and it really did. Invoking $('.sign-in-to-vk').click() in dev console was at least triggering popup blocker and then i was able to reach the popup (BTW popup blocker was veeery important here).

Back to dwb i needed a way to execute arbitrary JS on a page which was quickly and easily found in already opened man page. So on seesu page i typed :js $('.sign-in-to-vk').click() and nothing happened again. Here i remembered about popup blocker and (quickly again) found and option javascript-can-open-windows-automatically which was set to true with ss javascript-can-open-windows-automatically true

After that repeating JS snipped worked like a charm.

12 January 2015

Adventures with Asus P8H61-M LE/USB3 and UEFI boot

On Friday i've broken my boot loader tying to migrate to UEFI and today i was looking forward to fix and get UEFI working! But that wasn't the case.
My PC booted in UEFI mode from Achlinux USB pendrive i've brought from home, but i rejected to boot from HDD.
I don't know how much time would i spent with this, but fortunately our sysadmin guys passed through and noticed me messing about BIOS. That appeared to be a know issue of my motherboard. The version i had was 0306.

I won't provide you with detailed instruction on how to upgrade you BIOS! The only hint i may give you - prior to doing this do reset all setting to defaults.

Now all works for me :)

06 January 2013

LXDM PostLogout script to shutdown user's apps

LXDM is a bit strange in it's behaviour to not to kill your apps running when you log out. After logging out my deadbeef continues to play music and conky is still drawn on top of LXDM greeter. Look funny heh :)
I don't really like this, but I wanted DM to show list of users instead of simple prompt. Arch wiki suggests just to killall --user $USER which would also kill all your background processes they may be running (torrent, screen, etc).
Enough words - here goes the script:
$ cat /etc/lxdm/PostLogout 
#!/bin/sh
#
# Note: this is a sample and will not be run as is.

current_windows=`xlsclients -al | grep Window | cut -d' ' -f2 | sed -e 's/:$//'`
for wid in $current_windows
do
        pid=`xprop -id ${wid} _NET_WM_PID | awk -F ' = ' '{ print $2 }'`
        wmname=`xprop -id ${wid} WM_CLASS | cut -d= -f2 | cut -d, -f2 | sed -e 's/[ "]//g'`
        if [ "p${pid}" != "p" ]
        then
                echo "Killing ${wmname} (${pid})"
                kill ${pid}
        else
                echo "No PID found for ${wmname}"
        fi
done

# for some reason PID for conky cannot be determined
killall --user $USER conky
It requires xlsclients and xprop. Some apps (like conky) are special case and they don't show their PID in X11 properties of a window, so they are killed separately.

05 November 2012

Archlinux moves to systemd. My own remarks.

After notice that systemd is now default in new installations I realised that sooner or later I'll be forced to migrate disregarding whether I like this idea or not :)
After some reading I rebooted, edited kernel loading line in my Grub2 with init param pointing to systemd and booted into my Arhclinux. What was noticable that I received to GUI :) Though I was aware that systemd ignores /etc/inittab (my SLiM used to start from inittab) and I wasn't that surprised. I did sudo systemctl enable slim.service (along with couple of other services which made sense for me) and rebooted again (needed not to forget to put init kernel param in place again).
Basically everything went smooth except just a few points, which weren't clear from documentation and which made me post this writing :)

 

Here I'm talking about pure systemd installations.

 

1. systemd-sysvcompat

Documentation from Archwiki states that you must not remove this package or you won't be able to boot any more. Though this package doesn't seem to contain any things I may need now (file list for systemd-sysvcompat). And it appeared to be true - if you want to remove this package you need to do the following (instructions for Grub2 loader):
  1. edit /etc/default/grub and make sure you have init kernel param present, like this:
    GRUB_CMDLINE_LINUX_DEFAULT="init=/usr/lib/systemd/systemd"
  2. regenerate grub.cfg with
    sudo grub-mkconfig -o /boot/grub/grub.cfg
  3. now when everything went fine you could remove unnecessary things:
    sudo pacman -Rcs sysvinit-tools
    this should remove sysvinit-tools, initscripts, sysvinit and systemd-sysvcompat.

2. PCManFM doesn't show removable drives

While some other tools may show them. If not check documentation first. For me problem was that udisks daemon was inactive. So simple sudo systemctl enable udisks.service fixed this for me.

These seem to be all the troubles with systemd for me, which I find pretty painless! :) And instead of conclusion: if you want to know what else services you could enable (or disable) use systemctl list-unit-files


Update 12.01.2015

After quite some time i concluded that having a /sbin/init makes way more sense in terms of compatibility and stability then having an init= kernel option configured in a boot loader. I just switched to UEFI and had to specify init= again. This time i just symlinked systemd to /sbin/init to end up this fight:
ls -s '../lib/systemd/systemd' /usr/bin/init

28 June 2012

X11 session login with SLiM and no password

Basically task is to allow my mum login to home Linux-box and not to bother her with a password (or I would have to install Windoze again). At same time I want to still have access to same box with my own passworded account and to be able to login (with SLiM) to a X11 session.

I'm not going to dig into security considerations regarding passwordless users here.

So firstly let's create a user for my mum and deprive it a password:
# useradd -m -U username
# passwd -d username

Explanation:
-m force home directory creation
-U automatically creates a group with same name as username and assigns it as primary group for new user
passwd -d removes password from given account

Now you should be able to login with new user into physical terminal session. Though this depends on PAM configuration in your distro (I'm using ArchLinux). You won't be able to su to this user or login into SLiM yet.
To allow SLiM login you with empty password you need to edit /etc/pam.d/slim:
find
auth    required    pam_unix.so
and change to
auth    required    pam_unix.so nullok

That's it. Same instructions should apply to any login manager, not only SLiM.

24 April 2012

Screensharing in Linux with GoToMeeting

Screensharing appears to be a weak part of Linux desktop. Among solutions that do work I have successful experience with TeamViewer and Mikogo. Both of them are not perfect, but they run more or less natively on Linux.
These two were no the case for the event I needed to share my screen for :). Ideally I needed GoToMeeting and made it to share my screen! This instructions should work with most (if not any) of available screensharing solution for Windows.

Prerequisites:

In parenthesis I referred to software I was using.
  1. Windows running on either virtual machine (even non-virtual would work if you have spare one) (Windows XP on VirtualBox)
  2. VNC server running on your Linux desktop (x11vnc)
  3. VNC client on your Windows PC (TightVNC)

Basic idea:

You should have guessed what I'm going to do next :) I explain if not. You share the screen of you Windows PC with screensharing tool of your choice. But what the screen will display is fullscreen VNC client connected to your Linux desktop. I suppose there might be some video issues with the way how VNC client draws the picture and the way screensharing tool captures the screen, that's why I mentioned what software I was using.

Setup:

For sharing my desktop on Linux I ran x11vnc like that:
$ x11vnc -display :0 -auth ~/.Xauthority -forever -nap -noxdamage

Then I had to start another XServer instance to avoid effect of 'endless refraction' (e.g. VNC client shows your desktop running virtual machine with Windows with VNC client showing you desktop...) using:
$ startx -- :1

On the second XServer I ran VirtualBox, started my virtual Windows PC, ran TightVNC and connected to my host Linux box. (At this stage you VNC may not work smoothly, looks like XServer detects that it's not active at the moment and does not update the screen when you try to move windows from within VNC client.) Now start you screen sharing session and once it's started enter fullscreen mode in your VNC client. Now you could minimize you virtual PC window and switch to first XServer (Ctrl+Alt+F7 in my case, your may differ).
That's it and you may lead your presentation :)

Variations:

  • On dual-screen setup you could share only one screen with
    $ x11vnc -display :0 -auth ~/.Xauthority -forever -nap -noxdamage -clip 1680x1050+0+0
    and thus you may try to avoid switching between different XServer by running VirtualBox instance on second screen.
  • Gnome users may use vino instead of x11vnc, though I haven't tried this.

06 October 2011

[Ubuntu] Reverting upgrade from thir party PPA

History
I got new hardware for my PC at work (i3-2100 with integrated Intel HD Graphics 2000). My Ubuntu 10.10 installed didn't feature proper drivers for this GPU, but some folks over the Web advised to add xorg-edgers PPA which hosts bleeding edge version of Xorg and drivers.
It's worth saying that I my Xorg rejected to extend my desktop to both monitors after this upgrade :)

Task
So I started searching for the way to revert this update :)

Solution
Finally Synaptic saved me! I'll appreciate if somebody will teach me how to do the same from command line.

So:
  1. open Synaptic
  2. select group by Origin (bottom left corner)
  3. in the list on the left find the source repo you did the upgrade from
  4. now select installed packages (from this repo) one by one and for each to Package - Force Version... (Ctrl + E)
After that you could remove the PPA and don't do that again :)
Some more helpful info is available at https://help.ubuntu.com/community/CleanUpgrade

01 June 2011

Some more useful Skype scripts

I was going to write a script to mute\unmute Skype during a call, but I was unable to find DBus API documentation for Skype (I would be very pleased if you share a link or a document if you have one). Today I've found the script I need along with few more useful scripts:
All these stuff could be easily bound to a hotkey depending on environment you're using.
Happy Skyping :)

21 November 2010

How to restore Linux loader after installing Windows without Live-CD

Often having both Linux and Windows installed on the same PC I face trouble when after reinstalling Windows my Linux loader (GRUB\LILO\whatever) got erased with nasty one from M$. Before I always had to look up some live-CD distro to boot and restore GRUB. Today I was too lazy to do that - I had no suitable CD (or maybe it's time to throw away my CD drive) and after a quick look through the web I've found GRUB4DOS. So what magic does it provide? Here is the trick - GRUB4DOS allows you to install it from withing your running Windows instance, it boots up a GRUB-like stuff where you can select another partition to boot from. Basically you then boot to your broken GRUB record, then boot up your Linux distro and then having complete environment you just restore your broken GRUB MBR record. Easy, ha! To install the GRUB4DOS we don't even need to perform any dangerous manipulations with MBR. You just download grub4dos or grubinst package from http://sourceforge.net/projects/grub4dos/files/, copy grbldr from the package to your system drive root (e.g. C:\grbldr) and add following line to boot.ini:
C:\GRBLDR="GRUB4DOS"
Now you just need to reboot the PC, boot your Linux distro and reinstall GRUB On my ArchLinux I did the following:
$ sudo grub-install --root-directory=/ \(hd0\)
This installed GRUB to the MBR of my first hard drive and put staging files under /boot/grub directory.

08 May 2010

Using D-Bus to shutdown the machine

I don't know why I don't like using /sbin/shutdown to switch off the computer :) But that is the fact! I am not using Gnome\KDE\XFCE\whatever_else_complete_DE. I'm running Archlinux with Openbox and several tools. So I wanted to allow non-privileged user to be able to shutdown the computer by a single click. Firstly I had to find out, what should I send over D-Bus (and whom to) to make my PC shutdown. Crawling the web I found an utility which allowed me to find what I needed in a few minutes. It's called DBus-Inspector. So having a message and destination it just remained to send it using dbus-send:
$ dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
If you will try to execute it, you may receive and error saying that you don't have permissions to send messages to org.freedesktop.Hal.devices.computer interface. If you did, you should open hal.conf from system config directory of D-Bus (mine is /etc/dbus-1/system.d/hal.conf) and add the following policy:
 <policy group="shutdown">
   <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
 </policy>
Now all the members of group shutdown will be able to switch off the computer by D-Bus. You just have to create the group:
# groupadd shutdown
And add your user to this group:
# gpasswd -a user shutdown
Finally you may want to create a script or desktop entry:
[Desktop Entry]
Icon=system-shutdown
Name=Shutdown
Exec=dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

15 March 2010

IE Developer Toolbar for IEs4Linux

IEs4Linux is know the best approach of running Internet Explorer under Linux. Working on a web project I faced a need to fix some style bugs in IE. So I tried to install IE Developer Toolbar (for those who don't know - just like FireBug, but far less cool) and saw error message from msiexec saying "Internet Explorer Development Toolbar requires Windows 2000 or newer".

So this post is about how to install the toolbar anyway! :)

The point is that IEs4Linux runs IE in wine environment with Win 98 version (at least for IE6 this is true), that why developer toolbar doesn't installs. To fix this, execute:

$ cat `which ie6` | grep WINEPREFIX
export WINEPREFIX="/opt/.ies4linux/ie6" 

You will most probably see other path instead of  /opt/.ies4linux/ie6. So now we know where the wine environment for wine is located. The next thing to do is to run winecfg for this environment and change target Win version:

$ WINEPREFIX="/opt/.ies4linux/ie6" winecfg

A dialog window will appear and in drop-down in the bottom of the window select Windows XP and press OK.

With this changes your IE won't run. So, download MSI of developer toolbar to your home directory with your favourite browser and install it to your wine environment with the following:

$ cd ~ 
$ WINEPREFIX="/opt/.ies4linux/ie6" msiexec /i IEDevToolBarSetup.msi
 
After installing the toolbar, run winecfg just like we previously did and switch Win version back to Windows 98.

Voila, we have IE with developer toolbar :)

17 February 2010

Analogue of FreeBSD watch for Linux

Being using watch (8) utility in FreeBSD I have never knew it's analogue for Linux. When facing such a need I always managed to find another ways to meet it. Just yesterday I had much alike case :) and finally I've found what I needed all this time. Well, there are plenty of them actually :). I have found snoop, ttysnoop (haven't found web site, but there are a lot of prebuilt packages in the web) and ttyrpld.

Though the most watch-like of them seem to be snoop, other also may be worth trying. I have yet tried nothing of them, so comments are appreciated.

And before the end I would mention well-known screen.

04 October 2009

Toggle Skype main window with keyboard

Here is another script I often use. It toggles visibility of Skype's window. The script is written in Python (I have just found most clear example of using D-Bus in Python) and relies on Skype supporting D-Bus remote API (OSS build of Skype does not support it). Other dependencies are python-dbus and wmctrl. Wmctrl is used to really give focus to Skype main window and to switch to the desktop where it is (BTW the script should work even without wmctrl installed, but may not bring up the main window to the top sometimes) and python-dbus is needed to send messages to Skype to show and hide it's main window.
Using is again simple: save the source to some file (lets say skype-toggle.py), make it executable (chmod 755 skype-toggle.py) and add a hotkey to your window manager to run this script. That's all! :)
#!/usr/bin/env python
import dbus
import os

remote_bus = dbus.SessionBus()

out_connection = remote_bus.get_object('com.Skype.API', '/com/Skype')

out_connection.Invoke('NAME SkypeToggler')
out_connection.Invoke('PROTOCOL 5')
wnd_state = out_connection.Invoke('GET WINDOWSTATE')

if 'WINDOWSTATE NORMAL' == wnd_state:
    print 'Hide'
    out_connection.Invoke('MINIMIZE')
elif 'WINDOWSTATE HIDDEN' == wnd_state:
    print 'Show'
    out_connection.Invoke('FOCUS')
    wId = os.popen('wmctrl -lp | grep Skype | sort -n | head -n 1 | awk "{print $1}"').read()
    print wId
    os.system('wmctrl -ia ' + wId)

03 October 2009

xkbswitch - simple keyboard layout switcher for X11

I've been thinking of what to post here for a long time and couldn't find anything interesting, useful and at the same time that is not copy-pasted from somewhere else in Internet. Today I was just searching for a source of one my tiny utility and realized that firstly it is useful (as I'm searching for it after a year passed when I wrote it) and secondly it cannot be a duplicate of anything from the Internet because I have written it by myself :)

So here is the prehistory: I am trying to build a handy and lightweight desktop environment based on Linux (or FreeBSD) at home long since. So I am not the one using Gnome, KDE and even XFCE. Now I am pretty satisfied with Arch Linux and Openbox with a few utilities (I can write separate post about my environment if someone would be interested. Just for info my desktop uses 68 Mb of RAM when it starts). Another aspect of my non-standard requirements is that I'm used to switch keyboard layouts using separate hotkeys for each layout. (For example I am using Ctrl+Shift+1 for English, Ctrl+Shift+2 for Russian and Ctrl+Shift+3 for Ukrainian.) Xxkb cannot handle such things, so the only way is some kind of thirdparty tool. I know two programs that can behave the way I need (well... the first one I am actively using and the second one should also handle different hotkeys, but I haven't checked it personally), they are xneur and kkbswitch. I like xneur very much but it stucks in Arch and further keyboard input is impossible until xneur is restarted. I am using it at work on Ubuntu 9.10 and everything is ok, so I don't know whether it is a bug of xneur or Arch's one. Kkbswitch is designed for KDE and depends on it's libraries, that is why I haven't even tried it.

Been stuck with all this for some time I opened sources off xxkb and taken the "engine" of it. (I just needed xxkb because I have never dealt with Xlib and wanted to get something working ASAP.) So the idea was to make a command line tool which would enable the layout given as it's argument. What for? To use it with hotkeys handled by your window manager :). Almost any WM allows you to define custom hotkeys. Given the above it is very easy to achieve the behavior I wanted. Here is the source of layout switching utility:

#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>

void PrintUsage();

int
main(int argc, char **argv)
{
    int xkbGroup;
    if (argc < 2 || (xkbGroup = atoi(argv[1])) < 0 || xkbGroup > 3)
    {
        PrintUsage();
        exit(0);
    }

    int xkbEventType, xkbError, xkbReason;
    int mjr = XkbMajorVersion, mnr = XkbMinorVersion;
    Display *display = NULL;

    display = XkbOpenDisplay(NULL, &xkbEventType, &xkbError,
   &mjr, &mnr, &xkbReason);
    if (NULL == display)
    {
        warnx("Cannot open X display %s", XDisplayName(NULL));
        switch (xkbReason)
        {
            case XkbOD_BadServerVersion:
            case XkbOD_BadLibraryVersion:
                warnx("Incomatible versions of client and server xkb libraries");
                break;
            case XkbOD_ConnectionRefused:
                warnx("Connection to X server refused");
                break;
            case XkbOD_NonXkbServer:
                warnx("XKB extension is not present");
                break;
            default:
                warnx("Unknown error from XkbOpenDisplay: %d", xkbReason);
                break;
        }
        exit(1);
    }

    Bool status = XkbLockGroup(display, XkbUseCoreKbd, xkbGroup);

    XCloseDisplay(display);

    return status ? 0 : 1;
}

void
PrintUsage()
{
    printf("Usage: xkbswitch [0-3] sets keyboard layout\n");
}

Use cc -I/usr/include -L/usr/lib -lX11 -o xkbswitch xkbswitch.c to compile it. Using it is simple and straightforward too: xxkbswitch 0 enables layout with index 0 (in my case Ctrl+Shift+1 executes xkbswitch 0 and sets English layout, xkbswitch 1 and sets Russian).