Arch Linux Running OSX High Sierra In QEMU

I’m not a fan of Mac or OSX by any means however, there comes a time where I need to test either using their native Safari browser or some other native Mac environment. To solve this issue, I set out to install OSX into QEMU. It wasn’t very straight forward but I figured it out so hopefully you won’t have to go through the same issues I had to.  Please make sure to follow along exactly with the steps provided, any missed or skipped step could easily lead to a failed install.

Prerequisites

Make sure you already have QEMU installed on your system.

Also ensure you have cfdisk installed on your system, or something comparible that you’re comfortable using.  We’ll be using this later to create a GPT partition.

You’ll also need to get a hold of an OSX High Sierra ISO.  At the time of this publication I was able to located a download of OSX High Sierra 10.13.1 at High Sierra 10.13.1. If for some reason the provided link is unavailable simply do a search or use an actual OSX install disc.

I found the best luck using the enoch_rev2902_boot BIOS.  At the time of this publication I was able to located a download at enoch_rev2902_boot.  If this specific version is no longer available a later version may work as well.

Create The OSX QEMU Image

First we need to create the OSX QEMU image.  Issue the following command:

qemu-img create -f raw osx 32g

Replace the 32g with the actual hard disk size you want to use (ie. 64g, 128g, 256g, etc.).

Next, let’s create a GPT partition on the “osx” image.  Issue the following command:

cfdisk osx

cfdisk gpt

You should be presented with the above image.  When you are hit enter to select “gpt” as the label type.

cfdsik new partition

Next, select “New” and hit enter.  At this point you can select the size of the partition or partitions you would like to create.  I created a single partition.  Hit enter when you’ve chosen your size or just hit enter for the default max size.

cfdisk write

After the partition has been created, we’ll need to write it back to disk and quit.  Select the “Write” option and hit enter, then when prompted enter “yes” to confirm the writing of the partition to disk and hit enter.  Next, select “Quit” and hit enter.

At this point we’ve created the osx disk image which we’ll be using with QEMU, next we’ll need to configure a boot script for QEMU to load the installer ISO.

Install Mac OSX High Sierra

To make life easy on ourselves, let’s create a start-mac.sh script so that we don’t have to type out a ton of information each and every time we want to launch the qemu image.  Create a start-mac.sh script and add the following to it:

#!/bin/sh

qemu-system-x86_64 \
	-enable-kvm \
	-boot c \
	-m 8192 \
	-machine pc-q35-2.4 \
	-usb \
	-device usb-kbd \
	-device usb-tablet \
	-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
	-kernel ./enoch_rev2902_boot \
	-smbios type=2 \
	-device ich9-intel-hda \
	-device hda-duplex \
	-device ide-drive,bus=ide.2,drive=MacHDD \
	-drive format=raw,id=MacHDD,if=none,file=./osx \
	-cpu Penryn,vendor=GenuineIntel \
	-smp 4,cores=2 \
	-netdev user,id=eno1 -device e1000-82545em,netdev=eno1,id=vnet0 \
	-device ide-drive,bus=ide.0,drive=MacDVD \
	-drive id=MacDVD,if=none,snapshot=on,file=./macOS_High_Sierra_10_13_1_Official.iso \
        -monitor stdio \

Take note of a few things here.  If you’re network device differs from mine which is “eno1” then rename anything in the -netdev from “eno1” to whatever your network interface is called.  Next, if you named your QEMU disk image anything other than “osx”, make sure you change the -drive line to reflect that.  Lastly, before we move on and spin up the image, make sure you have your High Sierra install ISO and the “enoch_rev2902_boot” BIOS all in the same directory or at least referenced correctly in the start-up script.

Now, let’s set the execute bit on the script and spin it up:

chmod +x start-mac.sh

./start-mac.sh

As the image starts up you should see something like the following:

QEMU BIOS

Hit enter to start the OSX installer.

NOTE: from this point forward if your mouse gets stuck in the QEMU window, use the key combination “CTRL + ALT + G” to release the mouse.

Next you’ll see the following if everything went well:

Apple Start

This will take a while and you may see no progress for quite some time.  Don’t shut the image down, just wait.  Seriously, it could take up to 30 minutes on just that screen along.  Eventually however, you will be presented with the black loading screen:

Apple Black Start

This screen will take a little bit at first too, once again, just be patient it will eventually load.  Eventually you will be presented with the language selection screen.  Go ahead and select your choice of language and hit the next arrow.

DO NOT SELECT “Install macOS” YET, OR IT WILL FAIL!

First we’ll need to drop down into a terminal and format the disk image “osx” we created to be of the proper Apple type.  All the work we did up until this point was just getting it so the Apple installer would recognize it.  Also, don’t try and using the graphical Disk Utility either, it will fail and complain about the the disk saying:

Operation failed...

Running operation 1 of 1: Erase "MacOS"...
Unmounting disk
MediaKit reports nout enough space on device for requested operation.
Operation failed...

Re-partition The OSX Disk

Once you reach the macOS Utilities screen, click on the Utilities drop down at the top of the screen and select the “Terminal”.

macOS Utilies Terminal

Once the “Terminal” app has launched we’ll need to re-partition the disk and format it using a Mac readable format.

Mac Terminal

By default, the disk we’re looking to format should be labelled as “disk2”.  If for some reason you’ve deviated from the above steps your label may be different.  To ensure you’re partitioning the correct drive issue the following command:

diskutil list

Once you’ve identified the correct drive, we’ll need to partition it.  Issue the following command to re-partition the drive:

diskutil partitionDisk /dev/disk2 GPT JHFS+ New 0b

Once complete you should see the following:

diskutil complete

Finally, close the open terminal application and select Terminal -> Quit Terminal from the top drop down.

Now, we can actually install macOS to our drive.  Select the “Install macOS” option and click continue.

macOS Install

Follow the next few screens and agreements until you get to the disk selection screen.

macOS Install

macOS Install Disk Selection

Now you can actually select the installation drive we labelled as “New”.  You may have chosen a different label and if so select that drive and continue the installation.

Shortly after the installer finishes, you may be presented with a black screen and an error which reads:

ParseTagDate unimplemented

ParseTagDate Unimplemented Error

Don’t panic! Hit F12 and the boot BIOS screen will be presented.  Select the “New” drive “hd(1,2) () New”, hit enter and complete the macOS installation.

macOS Install BIOS

At this point you’ll be presented with the gray Apple loading screen.  Once again, this may take quite a while.  Don’t terminate the instance, let it complete fully.

Apple Start

Eventually you’ll be presented with the black Apple loading screen again.

Apple Black Start

Finally, you’ll see the actual install progressing.

macOS Installing

Hooray! After the install completes you’ll see the BIOS boot screen once more.  This time it will contain your Installer, your installed macOS image disk and a recovery disk.  Select your macOS image disk “hd(1,2) (10.13) New”, finish up the welcome installer and enjoy your new OSX QEMU instance.

macOS Install Complete BIOS

Post Install Tweaks

The follow are some final tweaks to make the overall experience a little better.

Screen Resolution

If you see your OSX resolution stuck at something you don’t like say 1024×768, there’s a simple fix that can be applied to change this.  Do the following:

First, apply any Apple updates to the OS currently outstanding or available.

Next, open your “Finder” application, select “Applications” and go to the root of your drive by using Apple/Metakey + Option/Alt + Up arrow.

macOS Drive Root

Create a directory called Extra

macOS Extra Folder

Next, copy the file /Library/Preferences/SystemConfiguration/com.apple.Boot.plist into the /Extra directory you just created.

Now, edit the file and change the following from:

<key>Kernal Flags</key>
<string></string>

org.chameleon.Boot.plist from

To:

<key>Kernal Flags</key>
<string></string>

<key>Graphics Mode</key>
<string>1920x1080x32</string>

org.chameleon.Boot.plist after

Or change it to whatever graphics resolution you would like.  The format of which is:

Next, shutdown the OS completely by selecting “(Apple Icon) -> Shutdown”.  Once the instance has completely shutdown, relaunch manually by issuing:

./start-mac.sh

You should see an error in the QEMU window:

Booting with plist

Press any key and you should see the window resized to the width and height you specified above.  Next, to get rid of the boot error, rename the com.apple.Boot.plist file to org.chameleon.Boot.plist in the /Extra directory.

org.chameleon.Boot.plist

Finally, shutdown fully using the “(Apple Icon) -> Shutdown” and start the instance again using:

./start-mac.sh

Now your resolution should be set and you’re good to go.

Remove the ISO image from the start script

Edit the start-mac.sh script and comment out the last 2 -device and -drive lines:

#!/bin/sh

qemu-system-x86_64 \
	-enable-kvm \
	-boot c \
	-m 8192 \
	-machine pc-q35-2.4 \
	-usb \
	-device usb-kbd \
	-device usb-tablet \
	-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
	-kernel ./enoch_rev2902_boot \
	-smbios type=2 \
	-device ich9-intel-hda \
	-device hda-duplex \
	-device ide-drive,bus=ide.2,drive=MacHDD \
	-drive format=raw,id=MacHDD,if=none,file=./osx \
	-cpu Penryn,vendor=GenuineIntel \
	-smp 4,cores=2 \
	-netdev user,id=eno1 -device e1000-82545em,netdev=eno1,id=vnet0 \
	#-device ide-drive,bus=ide.0,drive=MacDVD \
	#-drive id=MacDVD,if=none,snapshot=on,file=./macOS_High_Sierra_10_13_1_Official.iso \
        -monitor stdio \

This will remove the macOS Installer selection from the boot BIOS defaulting the selected item to the “New” drive.  Next time you boot, just hit enter and you’re good to go.

Bartop Arcade Cabinet Build

I’ve always wanted to build a game cabinet from scratch. In this build, I create a bartop arcade game cabinet using some pre-cut CNC templates, Happ and Seimitsu controls and an HP all in one monitor.

Build Components

The following is a breakdown of all the parts used in my build.

  • CNC bartop templates by LEP1 Customs, LLC on eBay
  • 1 can of spray shellac from Home Depot
  • Rough and fine grain sand paper from Home Depot
  • 3 cans of black semi gloss spray paint from Home Depot
  • HP all in one monitor from eBay
  • AK81 Mini Wireless Keyboard Mouse Combo from Tmark.com
  • Happ control joysticks and buttons from BSA Gaming on eBay
  • LED Happ style player and coin buttons from Magic Stone on eBay
  • Seimitsu buttons for pinball paddle controls from Focus Attack
  • Kinter 2 channel mini amp from Nargos on Amazon
  • Lanmu USB DC 5V to DC power converters from Lanmu direct on Amazon
  • BOSS Audio BRS540 50 watt 4 inch speakers from Speece, Inc on Amazon
  • Joystick mounting from amazingtreatsure123 on eBay
  • Electrical wire terminal crimp connectors from eBay
  • Rubber non-slip adhesive feet from Home Depot
  • 2 sheets of 12×24 x .093 plexiglass from Home Depot
  • 1 1/8″ drill bit from Home Depot
  • Small gauge wiring and screws from eBay

6 GPU Mining Build With MSI RX 570 Gaming X Video Cards

Building a mining machine can be a daunting task when trying to figure out the right balance of investment versus return.  This build is a minimum investment build which yields a high return, both in terms of hashrate/solves as well as electrical usage.

VBIOS Modding

After the initial setup and build I began the process of modifying the VBIOS on the cards as well as tuning the settings on the cards to get the highest performance while maintaining a low electrical footprint.

The VBIOS I used was originally modified by Shados and was the 1500 strap modified BIOS. I used the ATIFlash utility to flash all of the cards and eventually put together a batch file to better facilitate this. Please be aware that flashing your VBIOS can render you card unusable if you don’t know what you’re doing, take care when doing so ensuring that you’re using the correct flashing utility for your respective card.

The ATIFlash utility is available here: Download ATIFlash Utility

The VBIOS used was originally downloaded from anorak.tech and all the credit for this goes to shados.  The video cards I used all contained Elpida memory therefore I used the msirx570gamingX_memshift_1500Mem2000.rom.  If your card has a different type of memory make sure you either modify the VBIOS yourself or find one that matches your chipset.

Performance Tuning

I found that for the series of GPUs I was using, namely the 6x MSI RX Radeon 570 Gaming X cards, the following settings worked best using Claymore’s Dual Miner while mining Ethereum.

-cclock 1075
-mclock 1900
-cvddc 900
-mvddc 900

Build Components

The following is a breakdown of all the parts used in my build.

  • ASUS Z170 PRO GAMING LGA 1151 Intel Z170 HDMI SATA 6Gb/s USB 3.1 ATX Intel Motherboard
  • 6x MSI Radeon RX 570 DirectX 12 RX 570 GAMING X 4G 4GB 256-Bit GDDR5 PCI Express 3.0 HDCP Ready CrossFireX Support ATX Video Card
  • 6-Pack USB RISER PCIe 6-Pin PCI-E 16x to 1x Powered Adapter Card w/ 60cm USB 3.0 Cable & PCI-E to SATA Power – GPU Mining Ethereum ETH Zcash ZEC
  • Intel Celeron G3930 Kaby Lake Dual-Core 2.9 GHz LGA 1151 51W BX80677G3930 Desktop Processor Intel HD Graphics 610
  • Rosewill Quark Series 1200W Full Modular Gaming Power Supply with LED Indicator, 80Plus Platinum Certified, Single +12V Rail, Intel 4th Gen CPU Ready, SLI & Crossfire Ready – Quark-1200
  • Biwin® 120GB MLC m.2 80mm Sync NAND flash SSD Solid State Drive, Read: 561MB/s Write: 450MB/s
  • Steel Crypto Coin Open Air Mining Frame Rig Case For 6 GPU ETH BTC Ethereum
  • G.SKILL NT Series 8GB (2 x 4GB) 288-Pin DDR4 SDRAM DDR4 2133 (PC4 17000) Intel Z170 Platform / Intel X99 Platform Desktop Memory Model F4-2133C15D-8GNT

Idea: Building A Quantum Interface Card (QIC)

A few years ago, an idea came to me regarding quantum entanglement and networking/communication technology.  After some time and research into trying to patent the idea, I found that others had similar ideas but were not at all interested in acting on its development.  To this end, I thought I might share my idea with the world, freely, in the hopes that perhaps someone, someday might find it useful in the furthering of how we not only communicate digitally, but how we share information as a whole.  The idea is as follows and is described using the simplest terms possible not to loose viewers not currently versed in quantum theory.  This post will also contain a simple entanglement primer.

Understanding Quantum Entanglement

To start, one must understand some simple quantum theory observations.  The first, particles entangled at the quantum level, retain their entangled state regardless of distance between said particles.  These particles, share an interesting state which can be described by the following.

Imagine for a moment that in front of you sat a quantum blender.  This magical device would take two particles, blend them up and spit out entangled resulting particles.  Now, imagine that the quantum particles where actually two tennis balls.  One orange and one green.  Once the tennis balls have been placed in the blender and turned on, the resulting particles could be observed as having the following characteristics:

The first ball which was orange, becomes half orange and half green.
The second ball which as green, becomes half green and half orange, in that order and yes, the order does matter and here’s why.

The state of the first tennis ball will always be the exact opposite state of the second and vice versa.  If the first tennis ball is imagined as being rotated 180 degrees, the second tennis ball could be visualized as rotating the opposite direction and have the opposite state.  This is where the importance of quantum communication begins.

If the state of the first tennis ball, when it’s orange state facing you could be thought of as 1, then the opposite state could be expressed as 0.  At the same time that the first ball’s state is 0 the second ball’s  state would be 1.  This is important because synchronization of the two states requires that one end of the entangled particles become inverted or not-ed.  This would render a synchronous state so that when the first tennis ball is facing with a state of 1, the second would also have a state of 1 and once again when changed, vice versa (ie. Orange:1 = Green:1, Orange:0 = Green:0).

Hopefully all of the above helps in understanding of the quantum theory being employed here.  If not, please feel free to ask questions in the comments and I will do my best to answer them.  Also, please keep in mind the idea above is a simplified example to only be used as a reference or mental model for understanding what’s to be explained in the development of a QIC.

Building A Quantum Interface Card (QIC)

In quantum physics it is understood that the sheer act of observing a quantum system changes the state of the system and this must be taken into account.  Currently two large hurdles exist at the time of this writing, the first of which is stabilizing a quantum particle or particles for a long duration of time.  The second, is creating a non-disruptive observance of a quantum particle or at the very least, a system of observance by which the state can be obtained from a quantum system before/during disruption as to obtain the correct state of the particle at the point in time of observance.

The Client Interface

In this model, the client interface could be thought of as a hand held device such as a phone or other user machine such as a desktop/laptop computer, tablet, etc..

The Service Interface

In this model, the service interface could be thought of as the side in which has direct or near direct communication with the service provider or access point into a provider infrastructure such as a data center.

Implementation

The implementation for the QIC requires one or more particles to be entangled at the quantum level and stabilized, with client particle(s) residing in the device used by the end user (ie. phone, tablet, computer, etc.) and the service particles remaining at the data center or provider’s data hub.  Information exchanged from the service end will be instantaneously observed by the client and vice versa.  A protocol will need to be established whereby client communication is recognized and service communication is recognized and handled to avoid collisions.  The simplest approach that comes to mind is to have a series of observed particles dedicated as client to service, and another dedicated as service to client.  This would allow for truly bidirectional and parallel communication.  Information exchanged in this manner could initially be interpreted using simple states such as 1 and 0.  By determining an initial quantum state, any state changes thereafter would determine the transmission state of either 1 or 0 (1 -> 0, 0 -> 1).  Current compression and optimization techniques used for optimizing and encrypting network communication could still be used although, being that this implementation takes place at the quantum level, one might argue that for the time being at least, such techniques may not be necessary for quite some time, if at all.

Realization

Once realized, quantum communication opens up an entirely new avenue of real time information sharing easily measured in the gigabyte, terabyte and potentially in the petabyte per second range.  This caliber of wireless data sharing would allow any device supporting a QIC to download/upload information far beyond what current wired/wireless technology allows, thus putting new bottlenecks on the side of the service provider and the speed in which the client can actually process and persist the data as received.

Other applications for QIC communication go beyond terrestrial technology and into that of deep space communication, allowing instantaneous communication with deep space vehicles and probes.

Conclusion

The above idea expressed reflects my vision for the future of wireless communication in the hopes that it be put into practical use.  If you use this idea, please mention me as one of the authors and I wish you the very best of luck.  Please feel free to ask any questions regarding any of the information listed above.  Thanks.

Windows 10 Tips And Tricks: Keyboard Shortcuts

Windows 10 is chalked full of very helpful keyboard shortcuts, seemingly more so than any of its predecessors. The following is a list of keyboard shortcuts and combinations that can really help to accelerate your speed and use of applications and features.

Window Commands
Minimize All: Win + M
Toggle Desktop: Win + D
Peek Desktop: Win + ,
Maximize Window: Win + Up
Minimize Window: Win + Down
Pin Window Left: Win + Left
Pin Window Right: Win + Right
Next Window: Alt + Tab
Previous Window: Shift + Alt + Tab

System Commands
System Shutdown: Win + X, U, U
System Signout: Win + X, U, I
System Restart: Win + X, U, R
Lock System: Win + L
Control Panel: Win + X,  P
System Information: Win + Pause
Device Manager: Win + X, M
Task Manager: Ctrl + Shift + Esc
Run Dialog: Win + R
File Explorer: Win + E
Search: Win + S
Action Center: Win + A
Project: Win + P
System Settings: Win + I
Windows Ink: Win + W
Share: Win + H
Game Bar: Win + G
Feedback Hub: Win + F
Magnifier Zoom In: Win + +
Magnifier Zoom Out: Win + –
View All Windows: Win + Tab
OS Screenshot: Win + Print Screen

Taskbar Items
Items that have been pinned to the taskbar can be launched using:

Win + {position number}

Where {position number} is the numbered position from left to right.  For example, if you would like to launch the first application pinned to your task bar you would use the following command:

Win + 1

How To: Run Arch Linux on Windows 10

Windows 10 has the ability to run a Linux subsystem.  However, you can now run Arch Linux instead of the default Debian thanks to some great work by “turbo” at github.com.  Here’s the skinny on getting this setup.

First, download the alwsl.bat file from: https://github.com/alwsl/alwsl

Next, open a command Windows command prompt and execute the following:

alwsl install

Follow the steps provided by the batch file and voila! Arch Linux on Windows.

Lastly, just open ArchLinux from the Windows menu and enjoy.

I’ve noticed using Arch Linux instead of Debian on Windows appears to have some performance gains, especially around the usage of Vim and other console editors.

How To: Play Oculus Rift Games On HTC Vive

If you don’t have a VR headset yet, you may be wondering which to get. There seem to be ample support for both, but which one is the best?  Now, you don’t have worry, the answer thanks to some dedicated developers is now easy.  Get the HTC Vive.  Why?  Because the HTC Vive has the best versatility between the two.  You can play either sitting or standing (stationary) or within a specific set of bounds (room scale).  Now, you can also play Oculus Rift only games on the HTC Vive and here’s how.

First, if you haven’t already install SteamVR.  You’ve more than likely already done this, but it’s worth mentioning just in case.

Next, install the Oculus Rift Setup software:  http://www.oculus.com/setup

Finally, install the latest version of Revive: https://github.com/LibreVR/Revive/releases

Once both of those steps are done, launch SteamVR and you’ll have a new button at the bottom of the Steam overlay called “Revive”.

Now that you have revive installed, there are several free games that you can play from Oculus.  At the time of this publication they include:

And a few others.  Personally, I suggest Farlands, it’s a very cool Viva Pinata meets discovery game.  Enjoy the new set of games in your HTC Vive library.

Adding Custom CSS Properties Using gtkmm

Adding custom CSS properties in gtkmm is actually pretty simple once you know how.  It took me quite a bit of searching along with some trial and error before I came up with a pretty simple pattern for doing so.  What I was looking for was a way to use custom CSS without having to develop a whole bunch of custom classes which extended Gtk base classes.

First thing we need to do is to create a class that extends from Gtk::Widget.  Now, we don’t necessarily have to use the class directly as a visual object however, it does need to extend the Gtk::Widget class for it to work.  The following is my example for creating simple custom CSS properties.  Let’s start off by adding a single custom property called “width”.

 

class CustomCSS : public Gtk::Widget {
 
    public:
        Gtk::StyleProperty<int> width_property;
        int width;
 
        CustomCss() :
            Glib::ObjectBase("customcss"),
            Gtk::Widget(),
 
            //-gtkmm__CustomObject_customcss-width
            width_property(*this, "width", 100),
            width(100)
            {}
};

Let’s examine the above code to find out what’s really going on here.

 

class CustomCSS : public Gtk::Widget

First we need to create a class the extends the Gtk::Widget class.

 

public:
    Gtk::StyleProperty<int> width_property;
    int width;

Next, we need to add a public style property that defines what will be reading the width values and a simple property of the type we’ll want to use, in this case an int.

 

CustomCss() :
    Glib::ObjectBase("customcss"),
    Gtk::Widget(),
 
    //-gtkmm__CustomObject_customcss-width
    width_property(*this, "width", 100),
    width(100)
    {}

Finally, we’ll want to implement a default constructor where we set the name we will be using in our CSS to reference this class “customcss”, pass in the Gtk::Widget() constructor, then we’ll need to being initializing our custom properties to be used in CSS.  For this, we initialize the width_property, give it a CSS property name of “width” and set the default value to 100.  Then we do the same for the actual property by calling width(100).

Now, if we want to use the custom CSS class and properties we’ll need to add them to our CSS file.  I noted above also that in our CSS file, the “width” property would actually need to be specified as “-gtkmm__CustomObject_customcss-width”.  The first part “-gtkmm__CustomObject_” will be the default used by gtkmm when accessing the custom property, the last two parts “customcss” and “width” we control by setting the Glib::ObjectBase(“customcss”) and the width_property(*this, “width”, 100) respectively.

 

/* somefile.css */
 
* {
    -gtkmm__CustomObject_customcss-width: 500;
}

To enable this custom property to be used, we first need to define an all selector “*” followed by our CSS implementation which contains “-gtkmm__CustomObject_customcss-width: 500;”.  Now, let’s use it in our C++ application.

 

#include <gtkmm.h>
 
int main(int argc, char ** argv){
 
    //your code doing something useful
 
    //setup our css context and provider
    Glib::ustring cssFile = "/path/to/somefile.css";
    Glib::RefPtr<Gtk::CssProvider> css_provider = Gtk::CssProvider::create();
    Glib::RefPtr<Gtk::StyleContext> style_context = Gtk::StyleContext::create();
 
    //load our css file, wherever that may be hiding
    if(css_provider->load_from_path(HOME_DIRECTORY + "/.config/xfce4/finder/xfce4-finder.css")){
        Glib::RefPtr<Gdk::Screen> screen = window->get_screen();
        style_context->add_provider_for_screen(screen, css_provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
    }
 
    //instantiate our custom css class
    CustomCss css;
 
    //get the width
    int width = css.width_property.get_value();
 
    //do something useful with the width we retrieved from css
 
    //run application run
    application->run(main_window);
 
    return EXIT_SUCCESS;
}

As you can see from the above, we’ve created both a CssProvider and a StyleContext, then we load our CSS file by using load_from_path, set our screen to be the main application window’s screen, then finally we add a provider by calling add_provider_for_screen.  Once that’s all done we can use our CustomCSS class.  Simply instantiate it, and call get_value() of the property we want to use.  It’s that simple.  If we wanted to add more than one property, we just added them to the constructor’s inline calls like so.

 

class CustomCSS : public Gtk::Widget {
    public:
 
    Gtk::StyleProperty<int> width_property;
    int width;
 
    Gtk::StyleProperty<int> height_property;
    int height;
 
    //etc...
 
    CustomCss() :
        Glib::ObjectBase("customcss"),
        Gtk::Widget(),
 
        //-gtkmm__CustomObject_customcss-width
        width_property(*this, "width", 100),
        width(100),
 
        //-gtkmm__CustomObject_customcss-height
        height_property(*this, "height", 50),
        height(50)
 
        //etc...
        {}
};

 

Once again, we add the new properties if we want to our CSS file.

/* somefile.css */
 
* {
    -gtkmm__CustomObject_customcss-width: 500;
    -gtkmm__CustomObject_customcss-height: 100;
    /* etc... */
}

 

Then we access them the same way as before in our C++ code.

//instantiate our custom css class
CustomCss css;
 
//get the width
int width = css.width_property.get_value();
 
//get the height
int height = css.height_property.get_value();
 
//get etc...

 

I hope this helps.  I found this a simple and clean way of introducing custom CSS properties without having to create a bunch of Gtk::Widget classes.  As always, thanks for stopping by and let me know if there’s anything I can do to help.

 

 

How To: Xfinity TV and Arch Linux

Hey everyone, I’ve figured out how to get tv.xfinity.com working on Arch Linux today. Here’s what I did in case anyone else needs help:

First install pipelight:

user@computer:$ yaourt -S pipelight

Next, if you don’t already have it install firefox:

user@computer:$ sudo pacman -S firefox

Next, update and configure pipelight:

user@computer:$ sudo mkdir /root/.gnupg
user@computer:$ sudo pipelight-plugin ––update

Next, enable the flash plugin:

user@computer:$ sudo pipelight-plugin ––enable flash

Next, add the plugins to firefox:

user@computer:$ sudo pipelight-plugin ––create-mozilla-plugins

Lastely, make sure you have hal installed:

user@computer:$ yaourt -S hal-flash-git
user@computer:$ yaourt -S hal-info

Once you’ve completed the steps above, completely kill of firefox (Super+Q), then restart and browse to tv.xinfinity.com, you should be able to watch it with no problems.

Arch Linux Hydra Build

For a long time now I’ve been wanting to build my ideal computer. A powerful Linux machine with surrounding monitors. Recently I had the opportunity to do so. The following is a time lapse video of the entire build as well as the configuration files and list of components and where to buy them. This way, if anyone else wants to construct either the same or something along the same lines, they’ll have some footsteps to follow if they need the help.

During the trial and error process there were little milestones along the way.

Finally I got everything working correctly and the Hydra came to life.

Build Components

The following is a list of all the components used in this build along with links to purchase.

#archlinux #hydra the calm before the storm. #Linux

A photo posted by Jason Graves (@godlikemouse) on

On to part three of the Linux Hydra setup, the heads. 24” monitors all around.

A photo posted by Jason Graves (@godlikemouse) on

Part 2 wire maintenance of the Linux Hydra complete.

A photo posted by Jason Graves (@godlikemouse) on

Physical Configuration

I went with Dual Nvidia Quadro K620 video cards because they were very inexpensive and had the ability to display up to 4 monitors per video card via daisy chain through DisplayPort 1.2.  The monitors that I found that were pretty inexpensive however didn’t support direct daisy chaining so I had to purchase 2 multi monitor display adapters which essentially did the daisy chaining.  Physically, this is the setup.

GPU 1 DisplayPort Splitter 1 Monitor 1
Monitor 2
Monitor 3
Monitor 4
GPU 2 DisplayPort Splitter 2 Monitor 5
Monitor 6
Monitor 7
Monitor 8

 

Xorg Configuration

My chosen distribution for this build was Arch Linux, yours maybe different however, the Xorg configuration should be similar if not identical if you’re using the same components.  If not, then perhaps this might just help you along the way.

My first setup was using the nvidia proprietary driver, installed by the following:

user@computer:$ yaourt nvidia-beta-all

This driver set didn’t have Base Mosaic nor Xinerama working.  Everytime it was turned on the screen would black out and I would have to hard reset the machine and manually remove the settings.

Visually what I was setting up as 2 screens, one for the first GPU and another for the second.  The use of nvidia-settings made this very painless, I suggest you use it as well if you’re using Nvidia cards.

user@computer:$ sudo pacman -S nvidia-settings
user@computer:$ sudo nvidia-settings

Once you save the changes to the Xorg.conf file, you should be able to see the file located at /etc/X11/xorg.conf.

Here’s a visual representation of my screen Xorg setup.

Screen0 Screen1
Monitor 1 Monitor 2 Monitor 5 Monitor 6
Monitor 3 Monitor 4 Monitor 7 Monitor 8

Hopefully this helps in understanding what I was trying to achieve. This gave great results and allowed me to get all monitors working however, there were two issues with this setup.

The first, getting a graphical environment to support eight monitors was a bit troublesome at first. I started off using Gnome 3, tried KDE, etc. yet none of them supported anything other than a dual monitor setup. Also, xrandr did nothing to help here and even reported that the second GPU wasn’t available which was absolutely not the case. The solution here was to install a different desktop which supported multiple monitors. I went with XFCE4.

The second, windows could only be moved in the screen in which the window was created. In other words, a window created in Screen0 could only move through monitors 1-4. This became more of a problem over time and was resolved later. Here’s my first working Xorg.conf file.

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 370.28 (buildmeister@swio-display-x64-rhel04-17) Thu Sep 1 20:21:47 PDT 2016
 
Section "ServerLayout"
 Identifier "Layout0"
 Screen 0 "Screen0" 0 0
 Screen 1 "Screen1" 3840 0
 InputDevice "Keyboard0" "CoreKeyboard"
 InputDevice "Mouse0" "CorePointer"
 Option "Xinerama" "0"
EndSection
 
Section "Files"
EndSection
 
Section "InputDevice"
 # generated from default
 Identifier "Mouse0"
 Driver "mouse"
 Option "Protocol" "auto"
 Option "Device" "/dev/psaux"
 Option "Emulate3Buttons" "no"
 Option "ZAxisMapping" "4 5"
EndSection
 
Section "InputDevice"
 # generated from default
 Identifier "Keyboard0"
 Driver "kbd"
EndSection
 
Section "Monitor"
 # HorizSync source: edid, VertRefresh source: edid
 Identifier "Monitor0"
 VendorName "Unknown"
 ModelName "Ancor Communications Inc VE248"
 HorizSync 30.0 - 83.0
 VertRefresh 50.0 - 76.0
 Option "DPMS"
EndSection
 
Section "Monitor"
 # HorizSync source: edid, VertRefresh source: edid
 Identifier "Monitor1"
 VendorName "Unknown"
 ModelName "Ancor Communications Inc VE248"
 HorizSync 30.0 - 83.0
 VertRefresh 50.0 - 76.0
 Option "DPMS"
EndSection
 
Section "Device"
 Identifier "Device0"
 Driver "nvidia"
 VendorName "NVIDIA Corporation"
 BoardName "Quadro K620"
 BusID "PCI:1:0:0"
EndSection
 
Section "Device"
 Identifier "Device1"
 Driver "nvidia"
 VendorName "NVIDIA Corporation"
 BoardName "Quadro K620"
 BusID "PCI:2:0:0"
EndSection
 
Section "Screen"
 Identifier "Screen0"
 Device "Device0"
 Monitor "Monitor0"
 DefaultDepth 24
 Option "Stereo" "0"
 Option "nvidiaXineramaInfoOrder" "DFP-2.2.1"
 Option "metamodes" "DP-1.2.1: nvidia-auto-select +1920+1080, DP-1.2.2: nvidia-auto-select +0+1080, DP-1.1.1: nvidia-auto-select +1920+0, DP-1.1.2: nvidia-auto-select +0+0"
 Option "SLI" "Off"
 Option "MultiGPU" "Off"
 Option "BaseMosaic" "off"
 SubSection "Display"
 Depth 24
 EndSubSection
EndSection
 
Section "Screen"
 Identifier "Screen1"
 Device "Device1"
 Monitor "Monitor1"
 DefaultDepth 24
 Option "Stereo" "0"
 Option "metamodes" "DP-1.2.1: nvidia-auto-select +0+0, DP-1.2.2: nvidia-auto-select +1920+0, DP-1.1.1: nvidia-auto-select +0+1080, DP-1.1.2: nvidia-auto-select +1920+1080"
 Option "SLI" "Off"
 Option "MultiGPU" "Off"
 Option "BaseMosaic" "off"
 SubSection "Display"
 Depth 24
 EndSubSection
EndSection

The above configuration eventually became a bit problematic and reached out to NVidia to find out if there was anything that could be done to get Base Mosaic and Xinerama working in their driver.  The response I received was to try using the following driver:

http://www.nvidia.com/download/driverResults.aspx/106780/en-us

This turned out be very helpful.  Once the driver was installed I once again turned on Base Mosaic and to my surprise the entire panel of screens were being utilized under a single Screen0 entry.  This made it possible to drag windows from Monitor 1 all the way across to Monitor 8.

Screen0
Monitor 1 Monitor 2 Monitor 5 Monitor 6
Monitor 3 Monitor 4 Monitor 7 Monitor 8

This final Xorg.conf file is what I decided to keep and use going forward.

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 367.44 (buildmeister@swio-display-x86-rhel47-01) Wed Aug 17 22:53:32 PDT 2016
 
Section "ServerLayout"
 Identifier "Layout0"
 Screen 0 "Screen0" 0 0
 InputDevice "Keyboard0" "CoreKeyboard"
 InputDevice "Mouse0" "CorePointer"
 Option "Xinerama" "0"
EndSection
 
Section "Files"
EndSection
 
Section "InputDevice"
 # generated from default
 Identifier "Mouse0"
 Driver "mouse"
 Option "Protocol" "auto"
 Option "Device" "/dev/psaux"
 Option "Emulate3Buttons" "no"
 Option "ZAxisMapping" "4 5"
EndSection
 
Section "InputDevice"
 # generated from default
 Identifier "Keyboard0"
 Driver "kbd"
EndSection
 
Section "Monitor"
 # HorizSync source: edid, VertRefresh source: edid
 Identifier "Monitor0"
 VendorName "Unknown"
 ModelName "Ancor Communications Inc VE248"
 HorizSync 30.0 - 83.0
 VertRefresh 50.0 - 76.0
 Option "DPMS"
EndSection
 
Section "Device"
 Identifier "Device0"
 Driver "nvidia"
 VendorName "NVIDIA Corporation"
 BoardName "Quadro K620"
 BusID "PCI:1:0:0"
EndSection
 
Section "Screen"
 Identifier "Screen0"
 Device "Device0"
 Monitor "Monitor0"
 DefaultDepth 24
 Option "Stereo" "0"
 Option "nvidiaXineramaInfoOrder" "DFP-2.2.1"
 Option "metamodes" "GPU-05f6316a-a480-b2c4-7618-d19e2bd555aa.GPU-0.DP-1.2.1: nvidia-auto-select +1920+1080, GPU-05f6316a-a480-b2c4-7618-d19e2bd555aa.GPU-0.DP-1.2.2: nvidia-auto-select +0+1080, GPU-05f6316a-a480-b2c4-7618-d19e2bd555aa.GPU-0.DP-1.1.1: nvidia-auto-select +1920+0, GPU-05f6316a-a480-b2c4-7618-d19e2bd555aa.GPU-0.DP-1.1.2: nvidia-auto-select +0+0, GPU-0cc1f3f6-5d22-fe69-aa54-cb7c8c051daa.GPU-1.DP-1.2.1: nvidia-auto-select +3840+0, GPU-0cc1f3f6-5d22-fe69-aa54-cb7c8c051daa.GPU-1.DP-1.2.2: nvidia-auto-select +5760+0, GPU-0cc1f3f6-5d22-fe69-aa54-cb7c8c051daa.GPU-1.DP-1.1.1: nvidia-auto-select +3840+1080, GPU-0cc1f3f6-5d22-fe69-aa54-cb7c8c051daa.GPU-1.DP-1.1.2: nvidia-auto-select +5760+1080"
 Option "MultiGPU" "Off"
 Option "SLI" "off"
 Option "BaseMosaic" "on"
 SubSection "Display"
 Depth 24
 EndSubSection
EndSection

I hope this helps anyone who gets stuck trying to get multiple monitors working under Linux using Nvidia video cards.  Please feel free to drop me a line if you get stuck and I’ll see what I can do to help.