Wednesday, 4 September 2013

Use i3wm in Linux ( with dual screen and virtualbox)

Tiling window manager seems to be a good trend. the reason is: you don't have to go to a particular workspace and maximize the window

add
exec --no-startup-id nm-applet
in ~/.i3/config , so that network manager will be displayed in the tray.
two problems here:
1 the taskbar is not displayed properly
2 sometimes the autoscroll in chromium is not working.

-------------let virtualbox working perfectly with i3 with dual screen--------------

1. go to virtualbox->file->preference->input-> untick auto capture keyboard. (If unticked, the windows system will have the previlege to use win key, resulting in the failure of switching between workspaces)
2. put two screen of virtualbox separately on two monitors, each monitor is on different workspace (for example, monitor 1 has workspace 5, that display one virtualbox screen, monitor 2 has workspace 6, which display another virtualbox screen)
3. disable seamless mode, maximum mode.
4. configure ~/.i3config
add
bindsym $mod+z workspace 7;workspace 8
bindsym $mod+x workspace 3;workspace 4
bindsym $mod+c workspace 5;workspace 6
bindsym $mod+shift+z workspace 1;workspace 2

# for merge into new window
bindsym $mod+M focus left;split v;layout stacking;focus right;move left
bindsym $mod+comma focus right;split v;layout stacking;focus left;move right
WARNING: do not add any space to the digits, otherwise the workspace name will be 2[space] rather than 2. semicolon means to separate commands.
5. $mod+shift+c to reload
6. run
# VBoxManage setextradata global GUI/Customizations noMenuBar,noStatusBar


to disable the menubar and status bar in virtualbox windows

now every time we press $mod+c, we come into windows world, when we press $mod+z, we go back to i3 world.  
7. sloving keybinding problem: now the master key in i3wm is windows logo key, which conflicts with some shortcut within windows. (e.g., win+e=explorer, win+left arrow=place window by half screen, win+l=lock pc) for the window move, one can still keep using win key + numbers at number keyboard when numlock is disabled. To make full use of win logo key in guest machine, one has to map the win key to some idle keys (e.g., application key next to right control). it is not easy to change the regstration, we decided to use a software called Sharpkeys (becareful when using it 1. FROM on the left means the key that will be pressed, To on the right means the original function that one needs to be mapped out 2. if messed up, it is better clean all out , log in&out, then reconfiguire, because the modifided key doesn't hold the default function, which will be confusing)
Alternative solution to 7:

the basic idea is that the left windows logo key is used for i3wm, while the right one are still used on the right. However, I had some problem by make the keybinding changed on default.
the problem was if i put the following in ~/.Xmodmap
remove Mod4 = Super_R
add Mod3 = Super_R

and put
exec i3 --force-xinerama
if [ -s ~/.Xmodmap ]; then
    xmodmap ~/.Xmodmap
fi

in ~/.xinitrc, it doesn't change the key bindings at all (the reason I didn't delete this part is to remind myself of the wrong way). the way to work around it is to add the following to ~/.xinitrc

xmodmap ~/.Xmodmap &&
exec i3 --force-xinerama
if one does not put --force-xinerama, the two screens will be considered as one workspace, which may be good for some people. the we assign the left logo key as i3 mod, right one used for windows.

[chenming@T5500 ~]$ xmodmap
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Super_R (0x86)
mod4        Super_L (0x85),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

8. Problems on changing host machine:
when guest is set as 64bit, after copy the file to another host, it says

VT-x/AMD-V hardware acceleration has been enabled, but is not operational. 
Certain guests (e.g. OS/2 and QNX) require this feature.

Please ensure that you have enabled VT-x/AMD-V properly in the BIOS of your
host computer.

this problem can be solved by enabling Intel Virtualization Technology in bios (but remember, may be only this one, nothing else. this happens for my dell 960 pc.

this method is quite good to integrate the performance of dual screen. as i3wm has to enable xinerama, which treats two monitor as separate worspaces. using the above mentioned way could "integrate" two screen together.

Tips: use $mod+d to run a command in a new window, so you don't have to launch an application from a terminal always.
   It is better not use shift or alt key when changing into windows workspace. It is found that the shift key can be "sticked" after switch so that single clicking the icon in the taskbar becomes not focusing the window, but open another new one.

#-----------------------------------------
make ati drivers work
in /usr/src/linux/.conf

# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set
CONFIG_DRM_TTM=m         # this is newly added

#
# I2C encoder or helper chips
#
# CONFIG_DRM_I2C_CH7006 is not set
# CONFIG_DRM_I2C_SIL164 is not set
# CONFIG_DRM_I2C_NXP_TDA998X is not set
# CONFIG_DRM_TDFX is not set
# CONFIG_DRM_R128 is not set
CONFIG_DRM_RADEON=m         # this is newly added
# CONFIG_DRM_RADEON_UMS is not set
# CONFIG_DRM_NOUVEAU is not set


this is equivalent to
Processor type and features --->
<*> MTRR (Memory Type Range Register) support
Device drivers --->
   Graphics support --->
   <M> /dev/agpgart (AGP Support) --->
      (The agpgart option is not present on 64-bit kernels; just choose your chipset support.)
      <M> Intel 440LX/BX/GX, I8xx and E7x05 support
      (Enable your chipset instead of the above.)
   <M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
      <M> (Select your graphics card from the list)

at manual setup
#---------------------------------
can not find rxvt.
install rxvt



-----------------------change i3 as default manager-----------------
put
exec i3

in

~/.xinitrc

actually .xinitrc is the configureation file to specify which wm or de one wants to 

# -----------------add module on boot---
echo 'modules="dbus"' >>/etc/conf.d/modules
#---------------------------------------------


 ------- use mod+printscreen to cropscreen and save ----------------- 
Put the following lines in ~/.i3/config

bindsym  --release $mod+p exec --no-startup-id ~/Dropbox/scripts/scrot_s_2
bindsym  --release $mod+Print exec scrot -s -e 'mv $f ~/Pictures '

the content in ~/Dropbox/scripts/scrot_s_2 are

#!/bin/bash
scrot -s '%Y-%m-%d--%s_$wx$h_scrot.png' -e 'mv $f ~/Pictures'

--------------Make USB 2.0 work on client Windows--------------
1. install Virtualbox Guest Additions in the windows client
2. install Virtualbox extention pack from windows host. this can be done by executing

# emerge -av virtualbox-extpack-oracle
However, it is found that sometimes the installed atom can not be identified by Virtualbox system, as one can not see anything from File->preference->extentions. The way to solve this problem is to download the extention file from website and import the package from extention tab. Then the system will notice one extention has been installed.

--------------allow two virtual machine communicate-------------
There are three methods
Method 1:
(a) Run the following command
VBoxManage dhcpserver add --netname intnet --ip 10.0.1.1 --netmask 255.255.255.0 --lowerip 10.0.1.2 --upperip 10.0.1.200 --enable
(b) change the network adaptor into internal network, and make sure the name of the network is intnet.
(c) if one wants to have public access, e.g., internet, another adapter can be added with NAT network
The disadvantage of this method is the host computer can not access virtual machine at all.

Method 2
(a) choose


1.  make sure to reinstall nvidia and virtualbox after kernel update

my configureation in ~/.xinitrc is as follows
xmodmap ~/.Xmodmap &&
exec i3  --force-xinerama

eval "$(dbus-launch --sh-syntax --exit-with-session)"
export XMODIFIERS="@im=fcitx"
export QT_IM_MODULE=<module>
export GTK_IM_MODULE=<module>

every time I have to run xrdb ~/.Xresources to get the configuration of xterm right. However, sometimes it is needed to use win+shift+r to reload the i3wm as new terminal can not be generated by win+enter. Usually for the second time, everything would be fine.

Every time once new kernel is update, one needs to rebuild nvidia and virtualbox driver, respectively, after the new kernel gets booted.


For the nvidia driver one should do:
emerge -av --quiet-build=y nvidia-drivers

To check the status of the nvidia driver, one can do the following as root.
#journalctl -b |grep "nvidia"
#find /lib/modules -type f -name "nvidia.ko" -print
#eselect kernel list
see http://forums.gentoo.org/viewtopic-p-7591752.html#7591752 for details

If the above things were not done, one may not be able to go to x server using startx.

For the virtualbox, one should run
emerge -1 @module-rebuild
for m in vbox{drv,netadp,netflt}; do modprobe $m; done

Later after version 4.3.18, virtualbox has changed its lisence into PUEL. To further update this, one needs to do
ACCEPT_LICENSE="PUEL" emerge -av virtualbox-bin



-----------------map window key in guest to menukey-----------------
i3wm takes window key as the control key. this is a bit problematic for the guest windows as it is usual to use window key to map the windows.
This problem can be get around by map the win function in guest to other unused key, for example menukey. by using AutoHotkey app. only one liner in the configuration file is able to accomplish this:

Appskey::LWin

Remember to reload the configuration after putting in the mapping.


-----------------dual task bar in the guest windows-----------------
It is very normal to work in linux host in one screen, while windows guest in the other.
However, it is found that it is quite annoying when the guest windows doesn't have the window you want to see, to maximize the winodw, one has to go to the guest screen with task bars to nomalize it.
This issue can be convinently solved by installing dual monitor task bar, an open source application.
after the install, the window displayed in the specific screen will be listed in the bars.
n.  make trackpad less sensitive
following http://askubuntu.com/questions/483707/14-04-touchpad-is-too-sensitive
xinput set-prop "ETPS/2 Elantech Touchpad" "Synaptics Finger" 50 90 255
xinput set-prop "ETPS/2 Elantech Touchpad" "Synaptics Noise Cancellation" 20 20





No comments:

Post a Comment