Thursday, 31 December 2015

Copy paste in terminal via system clipboard in VIM in Fedora 23

The trouble

When you edit a file via vim editor in Fedora 23, then sadly by default you don't have access to the system clipboard. It means that you are not able to copy some text in the editor and then paste it for example to the browser or vice versa.

Luckily this issue has an easy solution.

Test if you need to fix it or not

To test if your vim supports x11 sytem clipboard run
vim --version
I expect that you will see -xterm_clipboard.  Our goal is to make it +xterm_clipboard.

Solution (Redhat/CentOS/Fedora)

sudo dnf install vim-X11
After that you will be able to use vimx command to start vim with xterm_clipboard support.
Try this:
vimx --version
Now you should see the desired +xterm_clipboard.

Test the result

To test it, just open a file in vim, select a text and then go different application where you can paste the text and hit mouse middle button. The selected text should be pasted there.

Tip'n tricks

As an improvement you can add an alias to your .bashrc file to use vimx even when vim command is started. Add this one line to your .bashrc file:
alias vim="vimx"

If you want to find out more about vim and system clipboard check the referred link below.

Source


Wednesday, 23 December 2015

Yakuake terminal global shortcut in Fedora 23 LXDE

Yakuake

Few years ago I felt in love with Yakuake terminal. It's probably because of two main things - at first it's the drop-down feature - you just hit a shortcut and terminal appears/hides. The second one is splitting the screen and seeing several terminals at once.


Yakuake default Open/Retract shortcut is F12, but as I'm a web developer, I use F12 for browser developer toolbar. So for the terminal I started to use F9. (Yes I know that it interfere with debugger shortcut, but I got used to it ;)

Open/Retract shortcut stopped working

Recently I did a fresh install of Fedora 23 LXDE spin and after installation of Yakuake the default F12 wasn't working nor I wasn't able to assign my own global shortcut key (F9).

When I opened the shortcuts settings, selected the global setting for the Open/Retract -> custom -> hit F9  it wasn't assigned. It just changed from "Input ..." to "None" always. I tried also another shortcut but no shortcut was assigned either.

Solution in Openbox window manager

After googling and finding nothing relevant I decided to try different approach.

I had an idea that yakuake command could have a --drop-down parameter or something like that. I started with even more simple method -  just tried to start yakuake command several times. And it worked just as I needed - first yakuake comand started Yakuake in the background, second run of the command opened the terminal and the third hid it, fourth opened it again .... awesome.

So the solution was easy as fedora lxde spin uses the openbox window manager.

Openbox uses simple xml file for configuring global shortcuts. I just added one keybinding for my need.

~.config/openbox/lxde-rc.xml:

    <!-- Keybinding for yakuake dropdown -->
    <keybind key="F9">
      <action name="Execute">
        <command>yakuake</command>
      </action>
    </keybind>

Those settings are loaded during window manager startup therefore I logged out, logged in and tadaaa - problem solved ;)

Sunday, 20 December 2015

Fedora 23 - resolution only 800x600 with Intel Corporation Sky Lake Integrated Graphics (rev 07)

I've bought new laptop ASUS F555UB-DM035T and installed linux Fedora 23.
What surprised me a litte bit was that it started with a basic resolution 800x600 and it wasn't possible to set a better one.

As this notebook has NVIDIA GeForce 940M with Optimus technology, I thought it's caused by that and it will be fixed by Bumblebee installation.

But even after I successfully installed bumblebee the resolution wasn't fixed. At that moment I realized that bumblebee is just for enabling of the discrete Nvidia GPU and not a driver for the graphic adapters. So the problem is probably in a driver for the currently used graphic chip.

I can see that I have this one (when 3D chip is not enabled by bumblebee):
$ lspci | grep VGA 
00:02.0 VGA compatible controller: Intel Corporation Sky Lake Integrated Graphics (rev 07)
Just note that my current kernel is:
$ uname -r 
4.2.7-300.fc23.x86_64
After googling a little bit I find out for example this article with an explanation that Skylake GPU is considered as of "preliminary hardware support" by the Intel DRM kernel driver. And to be able to use it with all resolutions which the graphic card supports you have to start your kernel with i915.preliminary_hw_support=1 parameter.


How to add the kernel boot parameter to the GRUB?

It's written in the article I mentioned, but I will shortly repeat it.

A) Temporary - for test:

Reboot your pc and when Grub menu appears hit "E". There you can add it to the appropriate line:

B) Permannent

At first I tried to use graphic utility grub-customizer, but it didn't work so I went with the command line, which was much more easier when I found the right manual how to do it ;) Editing grub in Fedora really well described here, so I will not repeat it.
Here is just a screenshot so you can see how easy it is ;)


Ok, that's it.

As there are more things which bothers me - touch-pad is not working, wifi is regulary dropping, I have thousands of warnings about hardware recoverable error in the system log (probably connected with the wifi)... I will probably add few more articles when I solve it.

Edit (few days later): no more articles about this notebook:


  • New problem appeared - total freezing of the system - I had to do hard reset (probably after installation of VirtualBox, but I'm not 100% sure it was caused by that)
  • And as I was very sad because of all those incompatibility issues with the linux system I returned the Asus notebook and took Lenovo IdeaPad z51 instead

Monday, 19 October 2015

Fedora 22 vagrant 1.7.2 - virtualbox machine in gurumeditation state

Description of the problem

Today I've started my vagrant with as usual, but it hanged after writing the message "configuring network interfaces". I cancelled the machine booting by Ctrl+C and tried to restart the VM by vagrant halt, vagrant up. Unfortunately my machine ended in a gurumeditation error (thanks Virtualbox, I've learned something about Amiga on wikipedia ;)

virtualbox guru meditation error

Fixing

I found a lot of results via google about this problem. Mostly it were bugs in Virtualbox, problems with drivers, kernels incompatibility issues. Sometimes it helped somebody to disable nested paging or hardware virtualization.
It didn't help to me.

Fixed

Finally I've solved my issue by uninstalling Virtualbox 4.3.30, installing Virtualbox 5 and uninstalling Vagrant 1.7.2 and installing Vagrant 1.7.4

Virtualbox 5 was already in my oficial Fedora repo so sudo dnf install VirtualBox-5.0 did the trick. For Vagrant 1.7.4 I had to download the rmp package from vagrantup.com because there is only 1.7.2 version in the official repo at the moment.


Saturday, 10 October 2015

Virtualbox interface vboxnet0 blocked by firewall on Fedora 22

Fedora 22 and firewall zones

On Fedora 22 the firewall has so called zones. It's quite a nice feature. You can have different configurations of firewall for each zone and you can simply assign network interfaces and network connections into the zones.
You can for example assign your wifi connection at home into to zone "home" and when you are on a public wifi, you will assign that connection to the "public" zone which will be probably more strict.

My configuration for virtualbox (vagrant)

On my notebook I got zone "internal" and in this zone I have enabled services for NFS server (mountd, rpc-bind, nfs) which I use from the virtual machine as a client.
In this zone I got only network interfaces which are created by virtualbox for the virtual machines. They are named "vboxnet0", "vboxnet1".

In the past when I started the virtual machine (vagrant up) the network interface vboxnet0 appeared in the firewall configuration gui (firewall-config) and after I assigned it once into the internal zone it remained there.

Vagrant mounting of NFS folder

After one recent update of Fedora22 packages it happened that the vboxnet0 and vboxnet1 disappeared from the firewall configuration and therefore mounting of NFS folder stucked.
It stucked after "vagrant up;vagrant ssh", the terminal looked like this:
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
...
...
==> default: Mounting NFS shared folders...


Because I already had some troubles with the firewall in the past, the first thing which I did was that I've stopped the firewall for a minute and as the mounting continued I knew that the problem is in the firewall.

Fixing the firewall configuration

After opening the firewall configuration GUI (firewall-cmd) I saw that the vboxnet0 interface is not in the internal zone and unfortunately was not there at all and I was not able to create it (in the past it was always there)

Luckily the firewall got also command line tool for configuration - firewall-cmd.
In the  man pages you can find commands for listing interfaces and zones and also other useful commands for firewall configuration including the command adding an interface into a zone.

So simply with the commands
sudo firewall-cmd --zone=internal --add-interface=vboxnet0
sudo firewall-cmd --zone=internal --add-interface=vboxnet1
 
I've added both virtualbox interfaces into the the internal zone. And the NFS mount command continued. Great, it's so simple :)

But, there is one more thing, which the firewall experienced guys probably suspect...

After I restarted my computer the NFS mount was hanging again. And by
sudo firewall-cmd --zone=internal --list-interfaces command I find out that the interfaces are not in the internal zone again. I told to myself - "I need to make those firewall settings permanent somehow". And what do you think... there is a "permament" parameter ;)

sudo firewall-cmd --permanent --zone=internal --add-interface=vboxnet0

So simple. Lesson learned - command line tools overpower the graphic ones ;)


Monday, 5 October 2015

Virtualbox NFS troubles with freezing box - I have not solved this yet

I use vagrant for developement environment

For data sharing between host and box (synced folder) the best option seems to be NFS (regarding the performance).

My setup:
  Host: Fedora 22 / Ubuntu 14.10
  Box: CentOS release 6.7

Unfortunately even though NFS gives the best performance, I have troubles when reading or writing big files from/into the directory which is mounted by NFS protocol.
The vagrant box simply stops responding sometimes - got fronzen - and I have to restart it


After some digging I improved the freezing a little bit by switching the network adapter type of Virtualbox machine to "virtio-net" - Paravirtualized network.

After switching the virtualbox to the paravirtualized network adapter type the freezing stopped for smaller files.

Unfortunately it helped only for a file about 500MB, when I tried to copy bigger file (> 4GB), the box frozen again :-/


If you got any idea how to solve this, I would love to hear it in the comments, thanks ;)

Wednesday, 19 August 2015

phpcs problem with utf-8 encoding - mbstring.func_overload

I was strugling with utf8 files when I wanted to check them with phpcs. Even when the file was ok (checked by removing utf-8 characters) phpcs reported errors and warnings. I assumed that the problem was because of badly parsed file.

I started with fixing phpcs configuration - Setting default encoding for phpcs
phpcs --config-set encoding utf-8

Then I verified that the config is set properly
> cat composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf
<?php
 $phpCodeSnifferConfig = array (
  'encoding' => 'utf-8',
)
?>

Checked the file and again errors...
> phpcs --standard=MyStandard path/to/file/MySuperObject.php

FILE: ...path/to/file/MySuperObject.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 40 | ERROR | Doc comment for parameter "$cookies" missing
 40 | ERROR | Doc comment for parameter "$cakes" missing
 49 | ERROR | Missing @return tag in function comment
----------------------------------------------------------------------


Also phpcs command with encoding specified did not helped
phpcs --standard=MyStandard --encoding=utf-8 path/to/file/MySuperObject.php

I started to be suspicious about php encoding.
When I found that in my php.ini file the 'default_encoding' is not set I was happy that it must be it.
I set the encoding as UTF-8 and ... same, again same errors.

Then I got an idea - it must be some php configuration which does something with encoding and voala, I spotted this configuration in my php.in

mbstring.func_overload = 6 ; All string functions to mbstring functions

When I deleted this configuration from my php.ini file, phpcs started to work correctly.

Unfortunately I need that ugly configuration for  my application. So now I have to figure out how to left it in php.ini and get rid of it for phpcs.

As I was not successfull with changing that php.ini setting for phpcs maybe the best option is to get rid of mbstring.func_overload.

Thursday, 28 May 2015

Skype opens links in Firefox instead of default browser (Google Chrome) - Fedora 21 LXDE

Check file

~/.local/share/applications/mimeapps.list

make sure that there is

[Default Applications]
text/html=google-chrome.desktop
x-scheme-handler/http=google-chrome.desktop
x-scheme-handler/https=google-chrome.desktop
x-scheme-handler/about=google-chrome.desktop
x-scheme-handler/unknown=google-chrome.desktop


Also check that google chrome is installed and google-chrome.desktop is in /usr/share/applications/


Pages which helped me to solve it:
- askubuntu.com/questions/79305
- askubuntu.com/questions/96080