Victor Vran on Linux

victorvranI’ve been playing Victor Vran lately on Arch Linux, it’s an excellent action RPG that works great on Linux. I’m playing it on my laptop using the discrete Nivdia GPU (860m) via Bumblebee with no issues at all. Visually the game is impressive with plenty of effects. Controller support is top notch, using my PS3 controller with bluetooth and no issues as all.

I like the way the game plays and character development is quite interesting, there are no skills rather the type of build you have is determined by what outfits, weapons, destiny cards and powers you have equipped. If you want to try a different build type then just swap items around, no worrying about making a mistake choosing the wrong skill.

Highly recommended, get it on Steam, currently 10% off.

 

 

Lavender GTK Theme

I really like the work that Sam Hewitt’s Moka Project has put together with their icons, Moka gnome shell and Orchis GTK themes. Unfortunately the Orchis theme isn’t fully compatible with GTK 3.14 and has a number of small issues that were annoying me. As much as I stuck with it due to the outstanding design of Orchis still those issues kept bugging me.

I initially ended up forking Orchis and fixing a few of the most egregious issues, at least to me, and submitted a pull request back to the project. As I was looking at fixing more things though it became apparent that this would take more time then I had available due to my general unfamiliarity with GTK theming and not understanding the nuances of the changes between 3.12 and 3.14 at the theme level. Also, while I’m comfortable with CSS having done Java development for web sites at various points in my career, I’m certainly not a designer nor a CSS guru.

So I ended up looking for alternatives and I came across the Numix theme. It was also well designed and supported 3.14 however the color palette was not to my taste. Having said, I had a look at how it was coded out of curiousity and noticed that it would be very easy to change it’s color palette. Rolling up the sleeves, I spent a couple of days playing with things and soon had a variant of Numix that used the Orchis color palette and assets and worked acceptably for my needs, thus was born Lavender.

Lavender Theme

Lavender Theme

Lavender is my first attempt at customizing a GTK theme. Lavender includes the GTK 2, GTK 3 and metacity themes from Numix with minor modifications, to the best of my ability, to support the Orchis color schemes. It also replaces the Numix assets for radio buttons, checkboxes, etc with the equivalent ones from Orchis. Lavender is not as attractive as Orchis, which is a superb design, but it gets the job done and works well with GTK 3.14 so it meets my needs.

Lavender also includes a slightly modified version of the Moka gnome shell theme. The primary change being a small purple bar shown to the left of running applications, similar to what Vertex does, to make them easier to pick out. As I get older I find I’m having trouble seeing contrast differences in blacks so this change was geared to my older eyes.

Finally let me clear that my effort pales in comparison to what the folks who originally built Numix and Moka/Orchis have put into their themes. Quite literally this work would not exist without those two giants, if you like this theme please, please donate to both these projects using the links below.

Moka Donation Page: mokaproject.com/donate/
Numix Donation Page: numixproject.org/

You can download Lavender at DeviantArt.

Create an UEFI Arch USB Rescue Stick

I’ve been running Arch for awhile now and one of the items on my todo list as been to create a USB rescue stick in case my installation ever gets borked with an upgraded. The process of creating a stick is really straight forward and I thought I would document the steps I used here. The first thing someone should review is the Arch Installation Guide and it will be referred to at various points. This guide assumes you are already running Arch Linux on your PC.

The first step is to partition and format the stick. I used GParted but any similar tool will do. In GParted I created a GPT table on the stick followed by two partitions. The first partition is FAT32 and only 384 MB in size, it will be the EFI boot partition. Remember to set the boot flag for the EFI partition. The second partition will contain the Arch Linux installation and it’s set to Ext 4. The screenshot below of GParted shows the final configuration.

GParted UEFI USB Stick

The next step is to get the Arch Linux install scripts on the PC you are going to use to create the USB rescue stick. This is simply done with the following command:

pacman -S arch-install-scripts

Next we need to mount the partitions on the stick, replace [x] in the commands below with the right letter for your USB stick.

mount /dev/sd[x]2 /mnt
mkdir -p /mnt/boot
mount /dev/sd[x]1 /mnt/boot

Once the stick is mounted we can install Arch Linux on it and generate an initial fstab:

pacstrap -i /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab

Next, follow the install guide as per the System Configuration (https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system) section and use arch-chroot to switch to the stick and do an initial configuration of the new install.

I chose to use rEFInd as the boot loader as it is very straight forward to install and configure. To install and do an initial configuration run the following from the change root shell (i.e. Within arch-chroot /mnt) remembering to once again replace the [x] with the letter for your device.

pacman -S refind-efi
refind-install --usedefault /dev/sd[x] --alldrivers

Once this is done, go into /etc/fstab and note the UUID for the second partition (the EXT4 partition) on the stick. edit the file /boot/EFI/BOOT/refind.conf and add the following at the end of the file, replace the UUID in the options line with your UUID that you noted from /etc/fstab.

menuentry "Linux Rescue" {
icon EFI/BOOT/icons/os_linux.png
loader /vmlinuz-linux
initrd /initramfs-linux.img
options "rw root=UUID=[YOUR UUID HERE]"
}

I would also recommend commenting out all of the other menuentry items besides this one but that’s optional.

Once done, exit arch-chroot and re-start your computer. Using the BIOS boot menu, select to boot from the stick and if everything went well it should boot to a text based login. At this point you can continue configuring Arch for your specific needs.

GNOME Boxes and Samba Shares

This is a followup to my earlier post about using GNOME Boxes to manage a Windows virtual machine. One of the comments I made was that I used Samba on the host (Arch Linux) to share the host file system with the Windows guest. I got a comment asking for further details about this as I mentioned it pretty superficially originally and thought it would make a good follow-up blog post.

This blog post is assuming Arch Linux as the host, if you are using a different variant of Linux check your distribution’s documentation on installing Samba. For Arch Linux, the Arch wiki does an excellent job of explaining how to install and configure Samba and this is what I followed with one exception.

That exception is that I opted to enable the smbd.socket service instead of smbd.service. Also, I didn’t bother enabling the nmbd.service which is used for Netbios since I only use the Samba service for my VM and not to share my local file system on the network at large.

Once you have followed the Arch install procedure, you need to create and modify smb.conf so that the host folders are available to the guest. As per the Arch wiki, this simply involves copying /etc/smb.default to /etc/smb.conf and adding an entry for each folder at the end of the file. Here is my entry for the Documents folder as an example:

[Documents]
    comment = Documents
    browseable = yes
    writeable = yes
    path = /home/[username]/Documents
    valid users = [username]
    public = no
    read only = no
    create mask = 0700
    directory mask = 0700

Make sure to replace [username] in the above with the name of the user you login into Linux with. I keep things simple by using the same username/password in the host and the guest, if you don’t you may need to do some tinkering to a to enter credentials in the guest to access the shares.

Once this is done, run the Windows Guest and open the File Explorer. I believe the default IP for the host in QEMU when using the slirp network stack is 10.0.2.2 so in Windows File Explorer, try accessing the network share using \\10.0.2.2\Documents. If everything is configured correctly you should see the host’s folders and files under Documents appear. If it works, you can opt to create permanent shares by creating mapped drives (right click Computer in Windows File Explorer and select Map Network Drive…).

So that’s it in a nutshell, pretty straight forward and hopefully it helps.

Learning Python, GNOME and GTK+3

While it’s a new year and I thought for my new years resolution that I would get back into doing a side project in my spare time. In my day job I do a lot of Java development but in the past I’ve typically taken on a side project doing something different from what I do for work to exercise the brain and keep my skills sharp. The last side project I did was an Android application called OnTrack Diabetes and it was a good experience that gave me some appreciation for mobile development.

I’ve been using Linux now for almost three years with the GNOME desktop environment so this time around I figured I’d get into writing a GTK+ 3 application and blog about the experience here. In terms of an application, I’m going to start with something relatively simple which is a Visual Grep tool. While I’m perfectly comfortable using grep from the command line, there are use cases for me where I like to have a GUI as I’m doing some analysis on code or other files that requires me to access the grep results in a random but persistent way.

So my first task was selecting a language for the development of this application. The two languages I considered are Python and Vala since they are both first class GNOME languages with excellent GTK+ 3 bindings. After doing some investigation, I decided to go with Python for this application for a couple of reasons. The first is that Python is more widely used then Vala which isn’t used anywhere outside of GNOME development as far as I can tell. This leads into the second reason which is that learning Python better actually benefits my day job as I’m often writing WebLogic scripts in Jython. The final reason is that Python has more mature tools then Vala.

Now that the language decision was made, the second order of business was to get an IDE setup. I opted for the PyCharm Community Edition from JetBrains. It appears to be a robust Python IDE with full support for code completion, re-factoring and debugging. Also, it didn’t hurt that I have heard nothing but good things about IntelliJ which is the JetBrains IDE for Java. Installing PyCharm in Arch is simple using the AUR package for it.

After installing PyCharm, I copied in my first GTK 3 program from a tutorial as follows:

from gi.repository import Gtk

win = Gtk.Window()
win.connect("delete-event", Gtk.main_nquit)
win.show_all()

Gtk.main()

And this is where I ran into my first problem. The first line had a red underline for the Gtk import indicating PyCharm could not resolve it and code completion wasn’t working for any GTK classes. After doing some googling I could see that this was a common complaint. Apparently GTK 3 uses introspective bindings which are problematic for some IDEs. PyCharm was supposed to handle it by generating a skeleton (hit Alt-Enter after Gtk and select “Generate stubs for binary module”)  but it never worked for me.

Instead I ended up using a package called fakegir which generates skeleton source files for the GTK 3 API. To use fakegir, I first imported the python-lxml dependency fakegir requires and then executed the fakegir script using the following commands:

git clone https://github.com/strycore/fakegir
cd fakegir
python3 fakegir.py

And this is where I hit my next issue when I got the following error:

...
Parsing /usr/share/gir-1.0/Cogl-2.0.gir
Traceback (most recent call last):
  File "fakegir.py", line 234, in <module>
    generate_fakegir()
  File "fakegir.py", line 226, in generate_fakegir
    fakegir_content = parse_gir(gir_path)
  File "fakegir.py", line 195, in parse_gir
    namespace_content = extract_namespace(namespace)
  File "fakegir.py", line 165, in extract_namespace
    namespace_content += insert_enum(element)
  File "fakegir.py", line 88, in insert_enum
    if enum_name[0].isdigit():
IndexError: string index out of range

To work around this, I patched the fakegir.py to simply ignore this exception. Not sure if this is the best route to fixing the issue (Hey I just started learning Python!) but it worked for me:

def insert_enum(element):
    """Returns an enum (class with attributes only) as text"""
    enum_name = element.attrib['name']
    docstring = get_docstring(element)
    enum_content = "\n\nclass %s:\n    \"\"\"%s\"\"\"\n" % (enum_name, docstring)
    members = element.findall("{%s}member" % XMLNS)
    for member in members:
        enum_name = member.attrib['name']
        try:
            if enum_name[0].isdigit():
                enum_name = '_' + enum_name
        except IndexError:
            print("Enumeration failed " + enum_name)
            continue
        enum_value = member.attrib['value']
        enum_value = enum_value.replace('\\', '\\\\')
        enum_content += "    %s = '%s'\n" % (enum_name.upper(), enum_value)
    return enum_content

Notice the new try…except, apparently the XML element causing this issue does not have a ‘name’ attribute hence why it fails. Like I said my fix probably isn’t the greatest but it gets it going.

Once the fakegir cache is generated, you have to add it as a content root in PyCharm as per the screenshot below:

Screenshot from 2015-01-10 15:01:48

Once this is done, code completion works successfully:

Screenshot from 2015-01-10 15:02:34

However if you try to run the application within PyCharm it now fails because the fakegir files are supplanting the real GTK 3 implementation. To workaround this, I disabled the options in Run Configurations to “Add content roots to PYTHONPATH” and was able to run the code successfully within PyCharm.

PyCharm Run Configuration

So that’s my first entry on my foray into the world of Python, GNOME and GTK+ 3 development. As I work through this application I’ll update the blog with my progress, hope you’ll find it interesting.

PS4 Controller and PC

I do a lot of traveling for my job and one thing I enjoy doing on the road is gaming on my laptop. While the keyboard and mouse works great for many games sometimes nothing beats a controller. I also prefer a wireless controller so that I can connect the laptop to the hotel TV if so desired for some bigger screen gaming. So the question is, what is the best wireless controller out there for the road warrior who wants to do some PC gaming?

In my opinion the answer is the PS4 controller. It has a number of advantages over other controllers including that it is wireless (bluetooth) and uses the same standard micro USB connector as an Android phone thereby cutting down on cables. It has all the same buttons as the 360 controller and can mimic it flawlessly on Windows and Linux with third party help.

I previously tried the Logitech F710 wireless controller but it has batteries that needed constant replacing plus requires a dongle. The wireless 360 controller is excellent, but it has a non-standard charging connector and also requires a dongle.

On Windows, I use DS4Tool to get the PS4 controller to mimic the 360 controller. On Linux, I’m using the ds4drv for the odd time a game requires a 360 controller (looking at you Dead Island).

In short, I highly recommend the PS4 controller, give it a try and I’m sure you won’t be disappointed.

WPS Office (Kingsoft), Arch and Gnome Shell

I’ve used Libreoffice for quite awhile but mostly as a document viewer as I’ve found it’s compatibility with the various complex MS Office documents I have to deal with somewhat lacking. It’s also a large package and a bit slow for my tastes even though performance is much improved in later versions.

I’ve heard a lot of positive things about WPS Office (formerly Kingsoft) and I decided to give it a whirl. I haven’t used it long enough to post any kind of review, however I did want to comment on two minor issues I ran into and how to fix them.

The first issue I had is that the font selector in WPS Writer always reverted to Dejavu whenever I tried to use a Microsoft font like Arial or Times New Roman. After much head scratching, I realized that the infinaltiy font package (highly recommended for good looking fonts in Arch) had configured font substitution in /etc/fonts/conf.d. After reading the documentation here, I realized I needed to run the command sudo fc-presets set and select the ms option, after that the issue was resolved.

As an aside, dealing with Microsoft fonts in Linux is a bit of a pain. I had originally used the ttf-ms-win8 package but this required you to have the actual fonts on hand which was a pain to assemble. Also every time the package would be updated I would be missing new fonts added to it which I would have to track down, it was a complete pain. As part of sorting out my font issue in WPS Office, I also removed the ttf-ms-win8 package and simply copied over the fonts manually from my Windows partition as per the instructions here.

The second issue I had was that the Gnome Shell dock wasn’t displaying the right icon in the dock when running the WPS Office applications as per the picture below. Notice the ugly default Writer icon (the blue W) instead of the nice icon from the icon theme I am using.

Screenshot from 2014-11-12 13:43:36

Another issue I found was that the dock menu option “Add to Favorites” that appears when right clicking the icon in the dock was not showing and thus I could not pin the app to the dock.

After some investigation, I found out that the Gnome Shell dock expects the name of the desktop file to be the same as the binary. To get this working, I copied the wps desktop files to new ones as per the following table.

Application Existing New
Writer wps-office-wps.desktop wps.desktop
Spreadsheet wps-office-et.desktop et.desktop
Presentation wps-office-wpp.desktop wpp.desktop

Note that I could have opted to simply moved the existing files to the new names, but this means that whenever the package is upgraded the files will re-appear resulting in duplicate applications showing up in Shell. Instead, I simply copied the desktop files and then used menulibre to hide the old desktop files.

After these changes, the lovely icons from the icon theme starting appearing as per the picture below and the dock menu works as expected.

Screenshot from 2014-11-12 15:32:09

Moto 360 Charging Image Retention


There have been some reports on the web about issues with regards to the charging image the Moto 360 displays and image retention along with possible burn-in. In short, the Moto 360 displays a largely static image that shows the percent charged when placed in the charger. Since this image is displayed for several hours with minor changes there is the possibility of image retention occurring and in extreme cases burn-in.

Unfortunately Android Wear doesn’t have an option to turn off the screen while charging. While there are a few programs that purport to do this, what they really do is throw up a black image but the screen is still on. While this does eliminate the image retention issue, it’s by no means ideal.

The only way I have found to reliably disable the screen while charging is to use the following sequence of steps:

  1. Place watch on charger
  2. On your phone, open the Android Wear app, go into Settings and enable Ambient Screen by clicking the check box
  3. Wear 2 or 3 seconds then disable it
  4. Watch screen should now be off

While this solution works well, you do have to do these steps every time you place the watch on the Charger. Hopefully Google will add an options for this top Wear in a subsequent version.

Here’s a screen shot showing the Ambient Screen setting:

Screenshot_2014-10-20-12-43-09

 

 

Borderlands 2 and Linux

The Borderlands 2 port for Linux was released this week and was on sale for $5 initially so I couldn’t resist picking up a copy. I fired up the game last night and played for a couple of hours, this is a quality port for Linux. On my laptop under Arch Linux and with an Nvidia 860m the game played flawlessly at 1920×1200 with good framerate and smooth play. The only issue I had was a bit of audio stuttering during the opening movie sequence but the game itself ran great.

I highly recommend this game for Linux and well worth picking up, particularly if you have Nvidia hardware.

Gnome Boxes and Windows Guest

I recently decided to try switching to Gnome Boxes for my Windows Virtual Machine from Virtual Box simply to see if the integration with Gnome Shell would be better. What follows is a summary of my experience getting things running optimally, hopefully it will be helpful to others interested in trying the switch. Note that I’m using Arch and Gnome 3.12 at the time this was written.

While not strictly necessary, the first step for me was to uninstall VirtualBox and all it’s dependent packages such as guest additions and the host packages. After that, I installed the gnome-boxes package which automatically drags in Qemu. I would also recommend installing virt-manager and virtviewer in case you need to perform more advanced tasks then Boxes will allow.

With the packages installed, I tried Boxes and found I could not do anything because it would fail as libvirtd was not starting automatically as it should. A bit of explanation, under the hood Gnome Boxes uses libvirtd, a library that abstracts virtualization implementations, to interact with Qemu. In turn Qemu has two different scopes for virtual machines: system and session.

The system scope is when the libvirtd is running as a daemon and the virtual machines have wider access to resources due to the higher privileges of the daemon. Session scope is when the VM is running in the current user context and only has access to what the current user is permitted.

Gnome Boxes uses the session scope so there is no need to enable the libvirtd daemon in Arch for Boxes, however as mentioned there is an annoying issue where libvirtd doesn’t start automatically as it should. Therefore when you start up Boxes you can an error message similar to the below:

Unable to open qemu+unix:///session: Failed to connect socket to
'/run/user/1000/libvirt/libvirt-sock': No such file or directory

You can check out this thread here (https://bbs.archlinux.org/viewtopic.php?id=186874) for more information on it, I simply worked around it by adding a script libvirtd.sh to /etc/profile.d to start it on login:


libvirtd -d

Make sure to include the -d switch to run it in the background otherwise your login will hang.

Once that was fixed, I used Boxes to convert my Windows 7 VirtualBox image over to Qemu and fire it up. It ran fine but performance was terrible, after doing some reading I found there are two must do items to achieve decent Windows performance under Boxes and Qemu:

a. Uninstall the VirtualBox Guest Additions if you have them installed.

b. Install the Windows Guest Tools here which includes the QXL video driver, clipboard support, etc. This makes the VM experience much more performant and seamless similar to what the VirtualBox Guest Additions provide.

c. Install the virtio driver in the Windows guest for optimum network performance in the VM, they can be found here

At this point I had a well running VM but I still had an issue with Boxes that whenever I closed and re-opened the Windows VM Boxes would complain that it couldn’t be started and I had to start it from scratch. This was really irritating, but after a fair amount of troubleshooting I discovered the issue was that I had a inTSC feature enabled in the VM which was causing the issue. Using virsh, I modified the image in ~/.local/share/gnome-boxes/images to remove this feature and everything worked fine afterwards.

Finally the last issue is that in VirtualBox sharing folders between the host and guest is a snap, in Boxes there is no way to configure this easily in the Boxes UI. Looking at Qemu and KVM, it looks like there is a way to directly share folders but I opted to simply use Samba on the host to expose it to the Windows Guest. To do this, I installed the samba package in arch and then copied the file /etc/samba/smb.conf.default to /etc/samba/smb.conf and modified the newly copied file to expose the desired shares. In the guest, you can use the gateway address (10.0.2.2) to access the folders, i.e. \\10.0.2.2\Documents.

So after a bit of work everything is up and running at about the same performance level as VirtualBox. I love the integration of Boxes with Gnome Shell such as the search provider and will likely stay with Boxes. I do have one minor issue where I wish there was an option for Boxes to stop starting my VM in full screen mode however apparently this is addressed in Gnome 3.14 which should be available for Arch shortly.