Archive for October, 2015

position two windows next to each other

October 31, 2015 Leave a comment

Note: scroll down to Update #1 to see a built-in solution.

I’m playing with the Brackets text editor and it has a live preview feature, which means that as you edit an HTML code, you can see its effect immediately in the browser. You don’t need to save and refresh the browser to see every change. Pretty cool. So I wanted to tile my windows: Brackets on the left side, Firefox on the right side. How to do that?

Maybe there is a shortcut for this under Ubuntu, but under Manjaro I didn’t find it. But there is a cool project thet can do this for you called QuickTile (written in Python :)). Here is a great video tutorial on how to use it: .

In short
Install it and then you get a script called “quicktile“. Run it once and it generates a basic config file at “~/.config/quicktile.cfg“. I modified just one line in the config:

ModMask = <Control><Mod4>

Then start QuickTile in daemon mode: “quicktile -d“. Then you can place your windows by pressing Ctrl + left Super key (aka Windows key) + numbers on the number pad (on the right side). So for instance Ctrl + Super + 6 positions the current window to the right side.

To make it run after a reboot, put “quicktile -d” among your startup apps.



Update #1
Arrgh… Just when I finished this post, I found another video ( ), which shows that this feauture is available in newer XFCEs (from version 4.10). Open Settings Manager -> Windows Manager, and select the Keyboard tab. Scroll down to “Tile...” and you can assign hotkeys to the different positions.

Update #2
Under Ubuntu (using Unity) it works out of the box. The hotkey is Ctrl + Alt + numbers on the numeric pad.

Categories: manjaro Tags: , , live preview doesn’t work

October 31, 2015 Leave a comment

When using the text editor Brackets, the live preview feature doesn’t work under Manjaro.


sudo ln -s /usr/bin/google-chrome-stable /usr/bin/google-chrome

Tip from here.


Categories: manjaro Tags: ,

playing Heroes 3 under Linux

October 29, 2015 Leave a comment

I don’t play much but a few days ago I decided to play with Heroes 3 again. offers the complete package for less than $10. There is a new HD version but the critics are not very good. Everyone says that the original is much better.

I tried it with Wine and I could install it without any problems. The game worked well for 10 minutes, but then I couldn’t click on some buttons, there was a problem with the mouse handling, so the game became unplayable.

I have dual-boot on my machine but I didn’t want to restart it each time I wanted to play this game. But I also had a Windows 7 in VirtualBox. I use that for work, so I didn’t want to pollute it with games. So I made a linked clone about this virtual machine. It means that the linked clone requires the original image and it only registers the differences. Thus, a linked clone doesn’t require much space. In this linked clone I installed Heroes 3 and it was playable. However, there were some problems with the resolution. The game has a fixed resolution of 800 x 600, so it started in a small area. I wanted to stretch it to fullscreen, so switched on the “Scale Mode” under the “View” menu point of VirtualBox. It was fine on one of my machines, but on another one it bacame terribly pixelated. Upgrading VirtualBox from version 5.0.0 to 5.0.8 solved this issue.

Summary: I can play Heroes 3 again under Linux using VirtualBox. The resolution of Windows is set to 800 x 600 and “Scaled Mode” is activated in VirtualBox.


Categories: games Tags: , , , ,

cut a column where the delimiters are whitespaces

October 26, 2015 Leave a comment

You have a text where the delimiter between the columns is just one character. In this case you can use the “cut” command:

$ cat /etc/passwd | head -2

$ cat /etc/passwd | head -2 | cut -d: -f1

However, what to do if the delimiters are whitespaces (notice the plural form)? Take for instance the output of “ps ux“. How to cut the 2nd column with the PIDs?

Use the right tool. In this case, “awk” will rescue us:

$ ps ux | tail -2
jabba    28302  0.1  0.0 136216  6436 ?        S    14:20   0:09 /usr/lib/virtualbox/VBoxXPCOMIPCD
jabba    28307  0.2  0.1 785908 10568 ?        Sl   14:20   0:22 /usr/lib/virtualbox/VBoxSVC --auto-shutdown

$ ps ux | tail -2 | awk '{print $2}'
Categories: bash Tags: , ,

file sharing on your home network with Samba

October 24, 2015 Leave a comment

I have several machines at home and an old laptop is connected to our TV with a VGA cable. When I download something on my main machine and I want to watch it, I need to copy it on a USB or an external HDD to take it over to the old laptop. A few days ago I came up with the idea to use file sharing at home. My main machine is almost always switched on, so it could be the file server, and my old laptop connected to the TV would be the client.

There are several solutions for this, e.g. NFS and Samba, just to mention the most well-known ones. First I tried NFS but I ran into some problems. First, I had to create one subnet at home. When I had two, the machines in different subnets couldn’t ping each other (refer to this post to see how to create one subnet with two routers). Once I had one subnet, I couldn’t always make NFS work. Sometimes it worked, sometimes it didn’t. And very often I got “permission denied” error when I wanted to connect to the server.

I talked to a friend of mine about it, Todi, and he suggested that I should try Samba instead. I did and it worked like a charm :) So here I sum up the steps for sharing directories at home with Samba between two Linux machines. Samba also works with other operating systems (Windows, Mac), but I will try that later.

I used the excellent Arch wiki as a starting point. I tried this method on two Manjaro machines but Ubuntu should be the same.

Server configuration

This is the machine that contains files that you want to access on other machines. Install the “samba” package and create the config file:

# cp /etc/samba/smb.conf.default /etc/samba/smb.conf

To provide basic file sharing, enable and start these services: “smbd.service” and/or “nmbd.service“. I’m not sure if “nmbd.service” is needed.

I like to see my shared folders in one place. Create the “/srv/samba” folder and mount here the folders you want to share. I added the following lines to my “/etc/fstab“:

/mnt/ext1/movies      /srv/samba/movies       none   bind   0   0
/mnt/ext1/torrent     /srv/samba/torrent      none   bind   0   0
/mnt/ext1/tutorial    /srv/samba/tutorial     none   bind   0   0

Of course, in the “/srv/samba” folder I created three empty folders first (movies, torrent and tutorial).

When ready, run the command “sudo mount -a” to mount these new folders. Verify if they are correctly mounted.

Now, it’s time to edit the /etc/samba/smb.conf file. My global part looks like this:

   workgroup = MYGROUP
   hosts allow = 192.168.0. 127.

It means that all machines on my home network and my localhost can connect to the server. The abbreviations mean 192.168.0.* and 127.* .

The next thing is to create a share. Add these lines to the bottom of the config file:

   comment = Jabba's stuff
   path = /srv/samba
   available = yes
   valid users = jabba
   browsable = yes
   public = yes
   read only = no
   writable = yes
   create mask = 0777
   directory mask = 0776

It means: the folder “/srv/samba” is served on the server (recursively); the client will need to authenticate itself (see later), and the client will have write permission too.

Note: I could set up Samba quickly but the client couldn’t do any modifications. The shared folder was read-only. The trick is to create a Samba user. On the server allow this user to connect, and on the client use the credentials of this user when connecting to the server. Let’s see how to do that.

On the server create a Samba user:

sudo smbpasswd -a 

For the sake of simplicity here I chose the same username that is my account’s name on Linux. Provide a password for this user and add this user in the “valid users = …” line (as seen above).

After editing the config file, always run the command “testparm -s”, which checks for syntax errors. Restart the “smbd.service” and you are done with the server side.

Client configuration

Install the package “smbclient“, that’s all you need. To see public shares on a server, run this command:

smbclient -L <server> -U%

I like to see my mounted Samba directories in one place, so I created the directory “/smb”:

# mkdir /smb

Then mount the shared folder of the server. Don’t forget to use the credentials of the Samba user that was created before:

#!/usr/bin/env bash

sudo mount -t cifs //hq/share/ /smb/ -v -o username=jabba,password=***

Here “hq” is the name of my server and “share” is the name of my share that comes from the Samba config file (it’s under the section name “[share]“, so this is its name). The username and password belong to the previously created Samba user.

If everything went well, then you should see the shared folders under “/smb“. The shared folders are writable on the client side.

File manager configuration

If you want to access Samba shares from Thunar, Nautilus, etc., then install the package “gvfs-smb“. Then in the location bar (CTRL+L jumps there) simply write “smb://hq/share” (in this example). Provide the Samba username and password and you are good to go.

On my home network the speed of Samba is not very fast. From the server I can copy with a speed of 1.5 MB/sec. When NFS worked, its speed was 1.7 MB/sec. So NFS was a bit faster, but there is no big difference. And Samba was easier to configure. However, for watching movies on a client, this speed is enough.

Windows client

The Windows client must be in the same workgroup with the server. As seen above in the “[global]” part, the server is in the workgroup called “MYGROUP“. Here is a help that explains how to join a workgroup. Here are some screenshots (sorry for the Hungarian version but that’s what I have at home). Click on the images to enlarge them:


After changing the workgroup’s name, you must restart the computer (yeah, it’s Windows). Then open the Explorer, go to the networks and you should see the Samba server. Connect with your credentials.

Ubuntu client

Install the package “cifs-utils” and proceed as described above.

Categories: network Tags: , , ,

home network with two routers but with one subnet

October 22, 2015 Leave a comment

When we moved to our new home, we had just one router. However, the wifi was very weak at places that were far from the router. So I added a second router that was another wifi spot with a different SSID. It was good, because we had strong wifi connection everywhere. Today I had the idea to set up NFS (network file system) and thus I could access all the movies on my main machine. However, I ran into a problem. As it turned out, I had two subnets at home: each router had its own subnet, and I didn’t manage to link two computers with NFS in different subnets. I made some study and actually you can create one subnet with two routers and the two routers can have the same SSID. Below I present the two approaches.

From now on, I will use the following terms. The router that receives internet in its WAN port is the “primary router”. The other router that is connected to it via a network cable is the “secondary router”.

(1) Old way: two routers, two subnets, two different SSIDs
This method was also good, the secondary router shared Internet (wired and wireless). However, it created a different subnet.

The IP address of my primary router was . A network cable connected it to the secondary router, and this cable went into the WAN port of the secondary router. The default IP of the secondary router was . The secondary router also had DHCP, and all machines connected to the secondary router had Internet. Machines connected to the primary router received an IP address of the form 192.168.0.* , while the secondary router distributed addresses of the form 192.168.1.* . It resulted in two different subnets. Both routers had DHCP enabled. Wifi was enabled on the secondary router too and it had a different SSID. Thus at home we had two different wifi networks with two different SSIDs.

It worked well until I wanted to have NFS…

(2) New way: two routers, one subnet, one SSID
I found the solution here. A big thanks to Scott Hanselman because following his blog post I could set up my home network correctly.

Here I just want to sum up the steps for future references.

The primary router is OK. Its IP is and it has DHCP enabled. In the DHCP settings make sure that the distributed IP addresses start with at least . Why? Because we will want to set the IP of the secondary router to be . In my router the starting IP address was, so I left it like that. Wifi is configured.

As the secondary router will also have wifi, set different channels in the routers. The channels should be far from one another. For instance channels 6 and 11 are good. So in the primary router set the channel to be 11.

Now switch off the primary router. We want to modify the IP of the secondary router but if the primary is running (and they are connected), then you can’t modify the secondary. So, the primary is switched off. Log in to the web interface of the secondary (in my case its IP was and modify its IP address to be . Save it and visit the new address, . In the secondary router disable the DHCP server. It has nothing to do with IP addresses; the primary router will distribute the IPs in our whole network. Enable the wifi and set the same as in the primary router: same SSID, same authentication method, same encryption, same password, etc. However, set the channel to be 6 for instance (it should be different from the primary router’s channel). Save everything.

The network cable comes out of a LAN port in the primary router and goes in to a LAN port of the secondary router. Warning! This time we use the LAN port on the secondary router, while in the previous method it was the WAN port! Switch on both routers, and the network should work with the secondary router too.

My wifi settings of the primary router:

My wifi settings of the secondary router:

Categories: network Tags: , , , , , ,

feh: a fast and light image viewer

October 18, 2015 Leave a comment

feh is an X11 image viewer aimed mostly at console users. Unlike most other viewers, it does not have a fancy GUI, but simply displays images. It is controlled via commandline arguments and configurable key/mouse actions.” (source)

feh has lots of features, thus it has lots of command line options too. Here I sum up the most important options. For more info refer to the manual.

feh [options] [files | directories | URLs ...]

command line options
-F             fullscreen
-x             borderless window
-Z             auto zoom to fit window size
--draw-exif    display some EXIF info
-d             display filename
-Y             hide mouse pointer
-l             don't show images, just list their dimensions
-z             randomize
-D float       delay for slideshow
-t             show thumbnails
    scrolling: mouse or 
               Ctrl+Up/Down (soft scroll) or 
               Alt+Up/Down (bigger jumps)
-k             keep files in /tmp (useful when browsing URLs)
               (Note: it didn't seem to work for me).

commands in view mode
d           toggle filename
e           toggle exif
h           toggle pause (in slideshow mode)
m           show menu
q, ESC      quit
s           save image
v           toggle fullscreen
z           random jump
Ctrl+Del    delete file from file system
keypad +    zoom in
keypad -    zoom out
Ctrl+Up/Down/Left/Right    scroll
*           zoom 100%
/           zoom to fit window size
o           toggle mouse pointer
Home / End  jump to first / last image
PgDn        go 5% forward in file list
PgUp        go 5% backward in file list

$ feh
    browse images in the current directory
$ feh -Fd
    fullscreen, file info
$ feh -Fdz
    fullscreen, file info, random order
$ feh -Fdz -D 5
    fullscreen, file info, random order, slideshow with 5 sec. delay
$ feh -t
    show thumbnails
$ feh img.jpg
    Show this image only. Browsing other files is not possible.
$ feh . --start-at ./img.jpg
    Show img.jpg but allow browsing the other images too.
    You must write "./img.jpg" instead of "img.jpg"!
$ feh . --start-at ./img.jpg -Fd
    as before + fullscreen and file info
$ feh . --start-at ./img.jpg -FdZ
    as before + images are auto-zoomed to the window size

At the Arch Wiki you can find more info about feh. There is also a file browser image launcher script.

I also made a simple script:

#!/usr/bin/env bash


if [[ ! -f $1 ]]; then
    echo "$0: first argument is not a file" >&2
    exit 1

feh . --start-at "./$1" -Fd

Usage: “ cool.jpg“. It will open the specified image in fullscreen. File info is displayed and you can browse other images too.

Categories: bash Tags: , ,

stop frustration: navigate among directories in command line easily

October 18, 2015 2 comments

Doing file manipulations in plain command line is a pain. That’s why I use Midnight Commander for tasks like copying, deleting, etc. But I’m still in pain :) If there are more than two directories that I want to work with, then even in MC I need to browse a lot and pass time with changing directories. Help!

I started to use two utilities that are very helpful. I found both of them in this thread.

This script was originally published in a Linux Gazette article in 2004. It’s available here.

Simply download the script and add these lines to your ~/.bashrc:

source ~/bin/
alias l="cd --"

“This is a scripts which defines a CD replacement function in order to keep, display and access history of visited directories. Normally the script will be sourced at the end of .bashrc.

cd —

Shows the history list of visited directories. The list shows the most recently visited names on the top.

This command is also assigned to ctrl+w.

cd -NUM

Changes the current directory with the one at position NUM in the history list. The directory is also moved from this position to the top of the list.” (source)

Since we need to use the command “cd --” a lot, I put a shorter alias on it called “l“, which stands for “list”.

This script is great but it has a drawback. It’s local in your current terminal. So if you open a new terminal and call the “cd --” command, the list is empty. I also wanted a global solution, that maintains a list among several terminal windows too. And this is how I found:

(2) autojump
Here is a nice blog post about it that I don’t want to quote completely just its abstract:

“autojump is a self-learning directory changer for navigating your filesystem. It works by maintaining a database of the directories you use the most from the command line. As soon as it’s installed it’ll start saving you time. Making easy to switch to the directories that are most important to you.” (source)

Install the package “autojump” and add these lines to the end of your ~/.bashrc:

# autojump
source /usr/share/autojump/autojump.bash

The official wiki is here.

Good to know:

  • To see the content of its database, use the command “j -s” (or “j --stat“).
  • TAB-completion is supported.

Remove “conflicted copy” files in your Dropbox folder

October 13, 2015 Leave a comment

Here is a quick solution to remove conflicted copies:

#!/usr/bin/env bash

# just print
find . | grep "conflicted copy 2015" | while read i; do echo $i; done

# print and DELETE
#find . | grep "conflicted copy 2015" | while read i; do echo $i; /bin/rm "$i"; done

Put it in your ~/Dropbox folder and launch it. First it will just print the conflicted copies. If you want to get rid of these files (verify!), then uncomment the last line.

The string “2015” is added to narrow the produced list. But normally “conflicted copy” should be enough.

Categories: bash Tags: ,