Archive for the ‘Guides’ Category

Debian & Ubuntu :: Suppress Installation Package Prompts Completely or Preconfigure Prompt Answers

Saturday, September 14th, 2013

Suppress Installation Package Prompts Completely or Preconfigure Installation Question Answers

Automating the installation of software via bash scripting on Linux can be difficult.  However, in debian and its related distributions such as Ubuntu, you can simplify the installation of packages by using a few tools.  One of these tools is called debconf-utils.  If installation packages such as MySQL or PHPMyAdmin ask configuration questions, you can provide a default set of answers without being prompted.  This is excellent for testing scripts or automating installation for users who may not know how to appropriately answer these questions.

Basically, with debconf-utils you can pre-answer these questions so that no prompts show up!

To install, run this command:

sudo apt-get install debconf-utils

To get a list of questions an installer might ask, first install the package on a test machine where you're writing the script normally.  For example, let's install phpmyadmin:

sudo apt-get install phpmyadmin

Now, to retrieve a set of questions phpmyadmin may ask, you can run this command:

sudo debconf-get-selections | grep phpmyadmin

In your bash script, you can now pre-answer certain questions by including your preconfigured answer commands before installing the package.  For example, when phpmyadmin installs, it asks for the MySQL root user password.  You can skip this prompt and define what the MySQL root password should be by using this command in your script:

echo 'phpmyadmin phpmyadmin/mysql/admin-pass password 1234' | debconf-set-selections

password defines the type and 1234 sets the password to 1234.
You can also suppress questions entirely by using the following command in front of your install command:

DEBIAN_FRONTEND=noninteractive sudo apt-get install phpmyadmin

Default configuration will be used during the installation of the phpmyadmin package, which means it may not work after being installed because some configuration options should be answered.  So, use both combinations for various packages to fit your needs!

Using JQuery Color Picker and Cookie Plugins to Change Element Background Colors Dynamically Based on User Preference

Sunday, April 21st, 2013

Changing Website Element Colors Dynamically Based on User Preferences

Wouldn't it be cool to dynamically style a website or webpage based on a user's favorite color?  Thanks to several JQuery plugins, it is now possible to do so!  The JQuery Color Picker plugin allows users to select a color based on a color pallete / color wheel similar to those found within photo editing software such as Adobe Photoshop or Corel PaintShop Pro.  The JQuery Color Plugin can darken, lighten, add, multiply, subtract, find color hues, change rgb values, and manipulate colors in all sorts of ways you probably never imagined possible.  The final piece to dynamically styling a page based on a user selected color is to save the picked color's value in a cookie using the JQuery-Cookie Plugin.  When any page loads, you will need to use the document.ready JQuery function to read the cookie and restyle elements as necessary.  If a cookie is not set, the default color can also be specified here. 

Here's a screenshot of the JQuery Color Picker in action:

To load / use the color picker, place this function within the document.ready function:

// Color Picker Loader
    $('#colorpicker').ColorPicker({
    
       color: defaultColor,
         onShow: function (colpkr) {
              $(colpkr).fadeIn(500);
              return false;
         },
         onHide: function (colpkr) {
              $(colpkr).fadeOut(500);
              return false;
         },
         onChange: function (hsb, hex, rgb) {
          var origColor = '#' + hex;
       
          // Set the main div background colors to what was selected in the color picker
              $('#colorpicker').css('backgroundColor', origColor);
          $('#origColor').css('backgroundColor', origColor);
          
          // Set the cookie
          $.cookie("color", '#' + hex, { path: '/' });
          
          // Set the dark and light colors (multi-iterations)
          darkColor = $.xcolor.darken('#' + hex).getHex();
          for (var i = 0; i < iterations; i++) {
            darkColor = $.xcolor.darken(darkColor).getHex();
          }
            
          lightColor = $.xcolor.lighten('#' + hex).getHex();
          for (var i = 0; i < iterations; i++) {
            lightColor = $.xcolor.lighten(lightColor).getHex();
          }
          
          
          // Set the light and dark divs
          $('#darkColor').css('backgroundColor', darkColor);
          $('#lightColor').css('backgroundColor', lightColor);
          
          // Change class attributes
          $('.light').css('backgroundColor', lightColor);
          $('.dark').css('backgroundColor', darkColor);
          $('.pad').css('backgroundColor', origColor);
          
          // Set the border
          $('#colorpicker').css('border-color', darkColor);
          
          
         }
    }); 

Assign a DIV element the ID of "colorpicker" in your HTML file to activate the color picker.    Don't change the "onShow" or "onHide" JQuery sub-functions of the ColorPicker.  When a user chooses a color from the color picker, the color picker "onChange" function is called.  This is where you need to define what should be done with the color the user has picked.  In my example, I call the $.xcolor.lighten and $.xcolor.darken Color Plugin functions to generate a lighter and darker color.  I use then use the color selected, a lighter variant of that color, and a darker variant of that color to style elements appropriately to keep text readable while offering a new color scheme.  As you can see from the code above, I mainly change the css attributes of certain classes, which the elements have been assigned.  What is changed is the backgroundColor and border-color of certain classes based on the three colors that were generated.

To see what other cool things you can do with all of these plugins, check out the links in the first paragraph.  Click here to see a live demonstration of all three plugins in action and download the source for how it all works based on the example discussed above.  The only Javascript file that needs to be changed to experiment with this sample is the "main.js" file within the "js" folder.

I hope this guide helps.  The plugin websites did not provide all of the code needed for a working sample, but luckily, I did the combination work for you.  Go ahead and use my source for anything!  Please comment if you have questions.

How to Make MATE Look Like Windows XP using the Luna Theme

Sunday, April 14th, 2013

Make MATE or GNOME2 Look Like Windows XP Using the Luna Theme

If you want your Linux installation to look like the original theme used in Windows XP, you can do that! This guide will walk you through the process of easily making any MATE or GNOME2 Desktop Environment look like the Windows XP GUI. The Luna Theme can be downloaded here and installed using our simple installation script. If you already have MATE installed or are already running GNOME2, skip to the Luna Theme install instructions.

Install MATE on Ubuntu:

Run the below commands for your matching Ubuntu version in a terminal to install MATE.  To find out which version of Ubuntu you're running, use this command:

lsb_release -a

For Ubuntu 12.04:

sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu precise main"
sudo apt-get update 
sudo apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring 
sudo apt-get update
sudo apt-get install -y mate-desktop-environment

For Ubuntu 14.04:

sudo apt-add-repository ppa:ubuntu-mate-dev/ppa
sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y mate-desktop-environment-extras

For Ubuntu 16.04:

sudo add-apt-repository ppa:ubuntu-mate-dev/xenial-mate
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y mate-desktop-environment

For Other Distributions (Distros):

http://wiki.mate-desktop.org/download

Installing the Luna Theme:

Our version of the Luna theme has been converted and ported over to GTK3, so it should work with all newer flavors of Linux running MATE while still working on older Linux installs running GNOME2.To install the Luna Theme which will make Linux look like Windows XP, run the following commands. The theme files will be downloaded and saved in your Downloads directory.

cd ~/Downloads
wget -O linux_xp_luna_theme_install.tar.gz http://dinofly.com/files/linux_xp_luna_theme_install.tar.gz
mkdir Luna
tar -zxvf linux_xp_luna_theme_install.tar.gz -C Luna
cd Luna
sudo rm -rf /usr/share/themes/Luna
rm -rf ~/.themes/Luna
sudo bash install.sh

Next, Right Click on the Desktop, and choose "Change Desktop Background".  Click on the "Themes" tab.  Select "Luna".  Click on the "Background" tab.  If you want the default XP wallpaper set as your background, click on the "Add" button.   Select your "Pictures" folder.  Select "luna_background.jpg".  Click "Open".  Click on "Close" to change it. 

Now, MATE or GNOME2 looks like XP!  Enjoy!  This theme was copied from Ylmf OS 3.0.

Getting Realtek Audio to Play Sounds Through Both Speakers and Headphones

Monday, February 18th, 2013

Running Multiple Channels of Audio Simultaneously in Linux

In Windows, I configure my Realtek audio to play sounds through my headphones (plugged into the front panel jacks) and my speakers (plugged into the rear panel jacks) simultaneously. I noticed in Ubuntu, the default is to mute sound in the rear when a device is plugged into the front. I wanted to stop this behavior, so here's what you have to do. Some people may also be looking to mute the rear speakers when a device is plugged into the front, so I have included both configurations. Download this nifty utility to manage and configure your audio settings by running these commands.

sudo apt-get install gnome-alsamixer
alsamixer

In this application, you can adjust volume and mess with several other settings.

At the bottom of alsamixer, scroll over to the "<Auto-Mute>" option.

To play audio through both headphones and speakers, change Auto-Mute to "Disabled".

To play audio through only one device, change Auto-Mute to "Enabled".

Hope that helps!

 

Install Latest Nvidia Drivers with a Custom Compiled Kernel in Ubuntu

Monday, February 18th, 2013

Installing Nvidia's Latest Drivers in Ubuntu using a Custom Compiled Kernel

I compiled the latest kernel 3.7.9 in my Ubuntu 10.04 Lucid following this guide here:  http://www.howopensource.com/2011/08/how-to-compile-and-install-linux-kernel-3-0-in-ubuntu-11-04-10-10-and-10-04/

Everything worked properly, but I ran into problems when attempting to install Nvidia's latest drivers (version NVIDIA-Linux-x86-310.32).  The DKMS build would not work and I received errors like "Unable to determine the target kernel version", "bad exit status 2", and "kernel header file does not exist" in the make.log file (along with others) in the /var/lib/dkms/nvidia folder.  The installer would always fail.  So, here's how to get the latest drivers installed and working properly with DKMS support.

First, we need to remove anything Nvidia that may already be installed.  There may be some Nvidia packages that are already installed on your system even though you've yet to install the Nvidia drivers!

Step 1: Download Nvidia Driver and Blacklist Other Drivers:

You can download the Nvidia drivers from http://www.geforce.com/drivers

Nvidia Drivers will only install if you are not running X, so you'll have to install this in a terminal.  Stop GDM before running the rest of the commands.

sudo service gdm stop

Now, we'll need to Blacklist some drivers.  To do this, launch a terminal, and use the following commands:

sudo nano /etc/modprobe.d/blacklist.conf

Add the following entries to the bottom of the file:

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

Run the following command:

sudo apt-get --purge remove nvidia-*

Step 2: Creating Symbolic Links

For some reason, after compiling the latest kernel, the symbolic links the Nvidia installer relies on do not exist.  We'll need to create them.  Run the following commands in a terminal:

sudo ln -s /usr/src/linux-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-$(uname -r)/include/linux/version.h
sudo ln -s /usr/src/linux-$(uname -r) /usr/src/linux

Step 3: Prerequisites

Install the following prerequisites by running these commands:

sudo apt-get install dkms

Step 4: Run the Nvidia Installer

Now, run the Nvidia installer and the DKMS module should build.

sudo sh NVIDIA-Linux-x86-310.32.run

Or whatever version you downloaded.

WinRar Create SFX Self Extracting Installation Wizard and Add Registry Settings

Saturday, January 19th, 2013

Creating a SFX Installation Wizard with WinRar that Can Modify Registry Settings

WinRar's "SFX options…" dialog does not contain any information or guides that help you modify registry settings after the files for your installation have been extracted.  This is a hinderance, but it is extremely possible to modify registry settings by running a batch file after the installation has been completed.  First, make sure the .bat file is included with the rest of your installation files that you selected before making the SFX archive.  In the "Advanced SFX options" window, click on the Setup tab.  Under "Run after extraction", type in just the name of the .bat file you're going to be running.

The Batch File Itself:

This template batch file checks to see if the operating system is 32-bit or 64-bit.  This is an important distincting as it will affect how you setup keys for each type of operating system.  64-bit system keys are usually placed in the Wow6432Node key, so it is important to make this distinction so that your registry settings will work properly.  This batch file called "Program Registry Adder 1.0" provides examples on how to add and modify registry keys depending on the operating system type.

Download Program Registry Adder 1.0

Adding Keys with a .bat (batch) File:

To add specific keys, you use the following parameters:

REG ADD "HKLM\SOFTWARE\My Proggy\" /f /v "InstallDir" /t REG_SZ /d "%PPROG%

The first parameter specifies which hive and key should be created.  The /f flag forces the addition.  The /v flag is the name of the key that should be created.  The /t flag specifies what type of Registry key should be created.  The example uses REG_SZ, which is just a string.  The possible types are:

Value Type (Use this in the batch File)
Binary REG_BINARY
DWORD REG_DWORD
Expandable String REG_EXPAND_SZ
Multi-String REG_MULTI_SZ
String REG_SZ
Binary REG_RESOURCE_LIST
Binary REG_RESOURCE_REQUIREMENTS_LIST
Binary REG_FULL_RESOURCE_DESCRIPTOR
None REG_NONE
Link REG_LINK
QWORD REG_QWORD

 

Check out more information here.

The /d flag contains the value of the key.

Conclusion

Using both a self extracting installation wizard and a batch file for registry key settings makes for the perfect free to use professional looking installation script. You can always run the batch file silently by removing all pause statements in the script. 

WinRar SFX Custom Start In and Target Paths on Desktop Shortcuts

Saturday, January 19th, 2013

WinRar SFX Custom Start In and Target Paths

When creating a self extracting installation wizard using WinRar, you may want to create a shortcut to your program on the user's desktop.  Typically, these parameters are specified in the "SFX options…" dialog.  In the "Advanced SFX options", click on the "Advanced" tab.  Here, you'll see a section called "Shortcuts".  If you create a shortcut using the "Add shortcut…" button, WinRAR will typically leave out an important undocumented feature.

If you create a desktop shortcut using the "Add shortcut…" button, make sure you set the "Destination folder" to just a slash "\" (no quotes) or the shortcut on the desktop will have the following properties:

Target: "D:\Install Directory\YourProgram.exe"
Start in:

Notice, there is no "Start in:" path.  To fix this, you need to add a "\" to the desktop shortcut parameters manually like so:

D, yourProgramsName.exe, \, "Shortcut Description", "Shortcut name",

Or, make sure you place a "\" (no quotes) for the "Destination folder" in the add shortcut helper.

This problem only affects desktop shortcuts and can be fixed by adding a "\" to the parameters for each desktop shortcut after the program's name.

Adding Custom Buttons and Plugins to WordPress’ Instance of CKEditor

Saturday, January 19th, 2013

Adding Custom Buttons and Plugins to WordPress' Instance of CKEditor

For CKEditor 4.x:

CKEditor 4 changed the way its toolbars work.  With CKEditor 4, you can no longer create a custom toolbar group with a defined list of custom toolbar items.  The developers of CKEditor claim this change was made to further innovate its editor software.  I'll let you be the judge on that.  Despite these changes, it is still possible to use an updated version of HTMLButtons which will add your custom toolbar buttons to the "about" toolbar group. 

Before you can define and add custom buttons to CKEditor 4.x, you need to download version 1.4 of the HTMLButtons plugin.  Once you've downloaded this plugin, unzip the files into a folder that you can easily find.  Now, we need to edit this plugin and configure our custom buttons.  Open the file "plugin.js" using a text editor such as PSPad or Notepad from the folder where you extracted the contents of the htmlbuttons plugin.  Scroll down to the line that starts with:

CKEDITOR.config.htmlbuttons

You'll see three buttons defined here:

CKEDITOR.config.htmlbuttons =  [
    {
        name:'button1',
        icon:'icon1.png',
        html:'<a href="http://www.google.com">Search something</a>',
        title:'A link to Google'
    },
    {
        name:'button2',
        icon:'icon2.png',
        html:'<table style="min-width:200px"><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>',
        title:'A simple table'
    },
    {
        name:'button3',
        icon:'icon3.png',
        html:'<ol><li>Item 1 <ol><li>Sub item 1</li><li>Sub item 2</li></ol></li></ol>',
        title:'A nested list'
    }
];

The name property of each button needs to be a unique name.  I would recommend continuing the current format of "button" with a number.  The icon property of each button specifies which png image should be used for the button's icon.  The html property of each button is what selected text will be placed between or what html content will be added.  If you want to wrap a selection into a certain HTML structure, simply define your HTML like this:

html:'<div class="customCode"><pre> </pre></div>',

Any selected text from the CKEditor instance will be wrapped within the above HTML structure.  If no text is selected, the HTML structure will be inserted with new text being appended inbetween the HTML structure as desired.  If "> <" isn't included in the html structure, the HTML will be appended with no text being inserted or wrapped within the structure.  For example, check out one of my own button declarations:

name:'button3', 
icon:'custcode.png', 
html:'<div class="customCode"><pre> </pre></div>', 
title:'Custom Code'

The above button declaration will insert a div and pre element into the source of my post and place the pointer inbetween the pre tags.  Thus, any text that is typed once the button has been clicked will be wrapped within the div and pre elements.  You can also highlight text and click the button.  If you highlight text and then hit the button, the highlighted text will be automatically inserted within the div and pre opening tags and before the end tags.  You can add as many buttons as you like following the template or remove as many as you wish.

Next, you'll need to upload your htmlbuttons plugin folder to the wp-content/plugins/ckeditor-for-wordpress/ckeditor/plugins/ directory.  Once this has been done, open the wp-content/plugins/ckeditor-for-wordpress/ckeditor.config.js using a text editor.  Under:

CKEDITOR.editorConfig = function(config) {

Add the following line:

// Added custom plugs
config.extraPlugins = 'htmlbuttons';  

The basic editor definition is here:

// WordPress basic toolbar
    config.toolbar_WordpressBasic = [
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight'] },
        { name: 'links', items: [ 'Link', 'Unlink' ] },
        { name: 'insert', items: [ 'Image', 'SpecialChar' ] }
    ];

 To add your button to the basic styles group, just add the following items to the end of the basic styles definition like so (depends on how many buttons you've created of course):

{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat', 'button1', 'button2', 'button3' ] },

Your buttons will be added to the basic editor which is seen when leaving comments.  The full editor definition is a little different.  It looks like this:

// The equivalent of "WordpressFull" toolbar, defined in a way that makes adding buttons from plugins easier.
    config.toolbarGroups = [
        { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        // { name: 'forms' },
        '/',
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
        { name: 'links' },
        { name: 'insert' },
        { name: 'wordpress' },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'tools' },
        { name: 'about' }
    ];

For CKEditor version 4.x, we don't need to modify this definition, as by default, all of your custom buttons will be extended onto the about toolbar group as shown in this screenshot below:

Save the file, upload it to the server, and overwrite the existing file.  Clear your browser cache and relogin to WordPress.  You should now see your custom buttons, and they should work when you click on them based on how you defined their behavior.


For CKEditor 3.x:

Unfortunately, there's not a lot of documentation out there on how to properly add custom buttons to WordPress' CKEditor main editor / format utility.  That's about to change.  Based on countless hours of searching the internet and posting on various forums, I've found the easy way to add custom buttons that perform their own functions and format certain pieces of text using custom css classes that I've defined in the main style sheet.

HTMLButtons Easy Plugin

This plugin allows you to easily create as many buttons as desired for both the full editor (the one you see when making a post on your WordPress blog) or the basic editor (the one visitors see when leaving comments).  The first step is to download this plugin.

I modified this version of HTMLButtons myself, which is why it's version 1.3. (versions 1.1 and up were also released by me).  Version 1.3 fixes a few bugs, keeps inline HTML formatting when modifying selected text, processes partial selections properly, and processes block selections properly.  The mouse pointer location is also reset correctly to the original selection in version 1.3.  When you click on your custom buttons to insert block elements, the text and HTML inline elements within the selection will be preserved.  The highlighted text is appended within element tags.  This is better than the initial implementation.  If nothing is selected, the elements are inserted with the pointer inbetween these elements.

For more information on the original version 1.0 HTMLButtons plugin or to find out about the original author, click here.Once you've downloaded this plugin, unzip the files into a folder that you can easily find.  Now, we need to edit this plugin and configure our custom buttons.  Open plugin.js using a text editor such as PSPad or Notepad from the folder where you extracted the contents of htmlbuttons1.0. 

Scroll down to the line that starts with:

CKEDITOR.config.htmlbuttons

You'll see three buttons defined here:

CKEDITOR.config.htmlbuttons =  [
    {
        name:'button1',
        icon:'icon1.png',
        html:'<a href="http://www.google.com">Search something</a>',
        title:'A link to Google'
    },
    {
        name:'button2',
        icon:'icon2.png',
        html:'<table style="min-width:200px"><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>',
        title:'A simple table'
    },
    {
        name:'button3',
        icon:'icon3.png',
        html:'<ol><li>Item 1 <ol><li>Sub item 1</li><li>Sub item 2</li></ol></li></ol>',
        title:'A nested list'
    }
];

The name of each button is how we will reference it when adding it to the full and basic editor.  Icon specifies which picture should be displayed for the button.  Button icons should be 15 pixels by 15 pixels.  You can create custom icons using an image editor.  HTML specifies what should be inserted to the actual source of your post when clicked on.  It will automatically insert text within this statement.  As an example, check out one of my own button declarations:

name:'button3',
icon:'custcode.png',
html:'<div class="customCode"><pre> </pre></div>',
title:'Custom Code'

The above button declaration will insert a div and pre element into the source of my post and place the pointer inbetween the pre tags.  Thus, any text that is typed once the button has been clicked will be wrapped within the div and pre elements.  You can also highlight text and click the button.  If you highlight text and then hit the button, the highlighted text will be automatically inserted within the div and pre opening tags and before the end tags.  You can add as many buttons as you like following the template or remove as many as you wish.Next, you'll need to upload your htmlbuttons plugin folder to the wp-content/plugins/ckeditor-for-wordpress/ckeditor/plugins/ directory.  Once this has been done, open the wp-content/plugins/ckeditor-for-wordpress/ckeditor.config.js using a text editor. 

Under:

CKEDITOR.editorConfig = function(config) {

Add the following line:

// Added custom plugs
config.extraPlugins = 'htmlbuttons'; 

The basic editor definition is here:

// WordPress basic toolbar
    config.toolbar_WordpressBasic = [
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight'] },
        { name: 'links', items: [ 'Link', 'Unlink' ] },
        { name: 'insert', items: [ 'Image', 'SpecialChar' ] }
    ];

To add your button to the basic styles group, just add the following items to the end of the basic styles definition like so (depends on how many buttons you've created of course):

{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat', 'button1', 'button2', 'button3' ] },

Your buttons will be added to the basic editor which is seen when leaving comments.The full editor definition is a little different.  Here's what it looks like by default:

// The equivalent of "WordpressFull" toolbar, defined in a way that makes adding buttons from plugins easier.
    config.toolbarGroups = [
        { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        // { name: 'forms' },
        '/',
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
        { name: 'links' },
        { name: 'insert' },
        { name: 'wordpress' },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'tools' },
        { name: 'about' }
    ];

Depending on where you want to add your custom buttons, you'll need to create a new group with its own name and items definition that will be added to the list.  I wanted my buttons before the bold, italics, and underline buttons, so I added my declaration here:

{ name: 'wordpress' },
'/',
{ name: 'custom', items: [ 'button1', 'button2', 'button3' ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] }, 

This will insert our custom buttons before the basicstyles controls in the full editor (the one you see when making a new post / blog)

You're done.  Here's what my full ckeditor.config.js file contains:

/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*//**
 * Documentation:
 * http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
 */CKEDITOR.editorConfig = function(config) {  // Added custom plugs
  config.extraPlugins = 'htmlbuttons';          // The minimum editor width, in pixels, when resizing it with the resize handle.
    config.resize_minWidth = 450;
   
    // Protect PHP code tags (<?...?>) so CKEditor will not break them when
    // switching from Source to WYSIWYG.
    config.protectedSource.push(/<\?[\s\S]*?\?>/g);    // Define toolbars, you can remove or add buttons.
    // List of all buttons is here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.toolbar_Full    // WordPress basic toolbar
    config.toolbar_WordpressBasic = [
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat', 'button1', 'button2', 'button3' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight'] },
        { name: 'links', items: [ 'Link', 'Unlink' ] },
        { name: 'insert', items: [ 'Image', 'SpecialChar' ] }
    ];    // The equivalent of "WordpressFull" toolbar, defined in a way that makes adding buttons from plugins easier.
    config.toolbarGroups = [
        { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        // { name: 'forms' },
        '/',
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
        { name: 'links' },
        { name: 'insert' },
        { name: 'wordpress' },
        '/',
    { name: 'custom', items: [ 'button1', 'button2', 'button3' ] },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'tools' },
        { name: 'about' }
    ];    // Remove buttons in "WordpressFull" toolbar
    config.WordpressFull_removeButtons = 'Save,NewPage,Preview,Print,Templates,CreateDiv,PageBreak,Subscript,Superscript,Styles';    //IE: remove border of image when is as a link
    config.extraCss = "a img { border: 0px\\9; }";
                                                          
    // mediaembed plugin
    // config.extraPlugins += (config.extraPlugins ? ',mediaembed' : 'mediaembed' );
    // CKEDITOR.plugins.addExternal('mediaembed', ckeditorSettings.pluginPath + 'plugins/mediaembed/');
};

That's all you need to edit.  Save the file, upload it to the server, and overwrite the existing file.  You should now see your custom buttons, and they should work when you click on them based on how you defined their behavior.

What does your button do from your example?

My button allows me to create html code that is formatted using a class I defined in the wp-content/themes/[current theme you’re using]/style.css stylesheet.  The class of customCode has the following definition:

div.customCode {padding:5px; background-color: #ecfef0; font-family: 'arial'; font-style: italic; color: black; font-size: 17px; margin-top: 1em; margin-bottom: 1em; overflow: auto;}

Thus, when the button is clicked, I have inserted custom code into the source of the post that will format the text exactly as I have defined.  This is a great shortcut to be able to make my blog posts look exactly how I want them to look.

My End Product: