Archive

Posts Tagged ‘linux’

Why I switched from Ubuntu to Arch Linux

2012/10/16 2 comments

Ubuntu is a great GNU/Linux distribution. I have been using it since 2004, and except for one LTS (long term support) upgrade a couple years back everything was fine. That LTS upgrade a couple years back screwed up the X system, leaving me with the bash shell. Don’t get me wrong: I enjoy dabling with my Linux system, but an LTS upgrade should be safe.

Well, this was years ago.

After upgrading from Ubuntu 11.10 to 12.04 the same thing happened again: No X system.

I have a cheap Nvidia card with dual head setup (dual head means you can plug in 2 monitors). Worked fine with Ubuntu since 2009. So I upgraded to Ubuntu 12.04. And I’m back to: No X system.

I was not amused.

It was not a hardware problem: The old OS (Ubuntu 11.10) worked fine. It was not the fault of Nvidia. I am talking about a video card for 20-50 bucks! Not one of those high-end video cards.

Instead of switching to another deb or rpm based system I decided to switch to one of those “rolling” distributions like Gentoo or Arch. I picked the later and have so far not regrated the decision.

Arch Linux is my home production system of choice.

Categories: linux Tags: , , , ,

Impressions during developing my first application with Mono and Gtk# (GtkSharp)

2012/09/30 Comments off

Why Mono? Why Gtk?

Over the past couple of years I have been developing C# ASP.NET enterprise applications. So I am quite comfortable with the Microsoft stack.

That answers the first question: Mono gives me C# and the .NET stack.

On the other hand I have been using linux as a desktop environment on my home machine for over a decade. I am comfortable with using linux as my primary OS.

That answers the second question: Mono gives me access to Gtk, the graphics library of gnome, which is the default “desktop” in many linux distributions.

The App

I want to synchronize different Git repositories semi-automatically using a Gui.

  • Default behaviour of the automation can be loaded via a Json file.
  • Each entry describes a repository set to be synchronized.

The app is located at https://github.com/draptik/RepoSync

I also published a small demo application for gtk# and treeview: https://github.com/draptik/GtkSharpTreeViewDemo

Impressions

Monodevelop vs Visual Studio

I’ll keep it brief: If you’re used to Visual Studio and ReSharper, Monodevelop does not come close. On the other hand Monodevelop is a full C# IDE which works with linux. And Monodevelop can be used cross-plattform.

Gtk# API

The Gtk# API is not your typical .NET library. You will very soon notice that the origins are C/C++. This takes some getting used to if you have a .NET background.

Typically there are no return values. Instead Gtk# methods very often use the “out” keyword in .NET because that comes closer to the C++ implementation using pointers.

Here is an example:

## Mono Gtk# Code
bool someBool = false;
if (listStore.GetIterFirst (out iter)) {
do {
someBool = (bool) listStore.GetValue (iter, 0);
} while (someBool && listStore.IterNext (ref iter));
}
return someBool;

## Pseudo-C# Code
return listStore.ToList().Any(s => s.MyBoolProp);

From the .NET side, I don’t like the Gtk# API. I prefer methods having return values. I guess it is a matter of tast. If it would really bother me, I would write some wrappers around… 😉

PS1 prompt

2012/08/20 Comments off

Here’s my current PS1 prompt for bash with optional git support: https://gist.github.com/3324534

Categories: IT, linux Tags: ,

Configure VirtualBox Windows guest system to use 2 monitors

2011/01/01 Comments off

Purpose

Our host system for VirtualBox is GNU/Linux. We want our guest system, windows, to use two monitors.
This solution should work for all Linux distributions supported by VirtualBox4.

Required software

  • Ubuntu 10.10 (aka Maverick) as host for VirtualBox4
  • VirtualBox 4
  • VirtualBox guest sytem: Windows XP (incl. VirtualBox guest additions)

Configuration

  1. Setup virtual guest machine (windows) within vm host system (GNU/Linux) to use two monitors:

    virtualbox-host-ubuntu-10.10

    Setting up virtualbox 4 to use 2 monitors for windows xp guest

  2. Within virtual guest (windows): Configure dual monitor setup:

    virtualbox_dualmonitor_windows_config

    Setup within virtualbox guest system (windows)

Side note

Upgrading from VirtualBox owned by Sun to VirtualBox owned by Oracle was very smooth. Even for Linux host systems. Oracle, thanks for that!

Using basic Emacs keybindings in Gnome-Terminal

2010/01/15 4 comments

Summary: Use basic Emacs keyboard shortcuts (ie navigation) in Gnome-Terminal while using the Bash shell. This post is only interesting for people familiar with Emacs.

This is so simple that I almost afraid to post it…

…One of those things that has been bothering you for years(!), but was never urgent enough to invest time figuring out how to fix…

Problem:

You’re used to Emacs shortcuts. Bash (and many other shells) support Emacs keybindings out of the box. But your default terminal comes with a stupid menu bar. So you press M-d (Emacs’ “kill-word”; for non-Emacs users: this corresponds to the key sequence Alt-d) and end up calling the “File” menu entry of the Gnome-Terminal (File is called “Datei” in German, which is my LOCAL). If you your LOCAL settings are English, you will have the same problem with the Emacs shortcut M-f (in Emacs this is “word-forward”): The Gnome-Terminal will grap the key sequence and open the “File” menu.

Solution:

  1. Open your Gnome-Terminal
  2. Edit -> Keyboard shortcuts -> DISABLE ALL MENU ACCESS KEYS (If you have German settings the menu entry is called: “Bearbeiten -> Tastenkombinationen -> Alle Menükürzel aktivieren”. Disable the checkbox..)

That’s it.

Emacsclient usage on a GNU/Linux system

2009/10/23 3 comments

Short instructions on how to setup Emacs using the Emacs Server/Emacs Client system on a GNU/Linux machine.

This post is intended for people familiar with GNU/Emacs.

Requirements:

GNU/Emacs 23 or greater (for Ubuntu get the Emacs PPA: https://launchpad.net/~ubuntu-elisp/+archive/ppa)

Files to edit:

~/.emacs
~/.bashrc

System settings using Gnome:

System -> Einstellungen -> Startprogramme

For the impatient:

Add this to your ~/.bashrc:

export ALTERNATE_EDITOR=emacs EDITOR=emacsclient VISUAL=emacsclient
## you can always use the command "emacs" instead of "emacsclient -c"
alias emacs='emacsclient -c'

Add this to your ~/.emacs:

(server-start)

Add this to your system startup options:

/path/to/your/emacs --daemon

ie:

/usr/bin/emacs --daemon

Gnome panel starter:

/usr/bin/emacsclient -c'

Detailed instructions

Starting Emacs from scratch will always load your init file (default: ~/.emacs). Loading this file can take a few seconds if your init file has grown over the years and if you load many external libraries.

To decrease the load time for situations like this the GNU/Emacs folks have developed the GNU/Emacs daemon and the GNU/Emacs server-client concept.

This concept allows you to attach to an already running session. No matter if you are currently using X or  a TTY session!

Just try it (without changing any settings):

  1. Start GNU/Emacs from a shell under X:
    $ emacs
    
  2. Now start the Emacs server from within Emacs:
    M-x server-start
    
  3. Open a file from within Emacs (it does not have to exist):
    C-x C-f ~/deleteme.txt
    
  4. Because we started the Emacs server, we can now start the Emacs client with close-to-zero load time:
  5. Starting the Emacs client from a new shell:
    $ emacsclient deleteme-from-shell.txt
    

    This will open the file “deleteme-from-shell.txt” in your running Emacs session. Cool, isn’t it?

    IMPORTANT: To close the attached Emacs client without killing the Emacs server you have to use “C-x #” instead of “C-x C-c”!

  6. Starting the Emacs client from a new shell AND opening a new Emacs frame:Same as step 5, but use “-c”:
    $ emacsclient -c deleteme-from-shell.txt
    

    Again: Close the client using “C-x #”! This will close the frame (=window) while keeping the server running.

  7. Starting the Emacs client from a new shell AND opening it within the current shell:Same as step 5, but use “-t”:
    $ emacsclient -t deleteme-from-shell.txt
    

    This will also work for a true TTY session. An example of a true TTY session can be achieved by switching to TTY-0 (Ctrl+Alt+F1; to return to your graphical display: Ctrl+Alt+F7). Try it:

    Ctrl+Alt+F1

    Login with username and password, then type

    $ emacsclient -t deleteme-from-shell.txt
    

    We are still attached to the same session! Cool!

    Switch back to your graphical display: Ctrl+Alt+F7

  8. The only drawback so far is that we had to start the Emacs server manually from within an Emacs session using “M-x server-start”. Otherwise “emacsclient” will complain that it has no server to attach to. So let’s include this feature in our Emacs init file (~/.emacs). Add this to your init file:
    (server-start)
    
  9. The previous step still requires us to start Emacs before we can invoke emacsclient. Let’s tell our default shell (ie Bash) to use “emacsclient” as default. If that doesn’t work, our shell should use “emacs”. Add the following the your ~/.bashrc:
    export ALTERNATE_EDITOR=emacs EDITOR=emacsclient VISUAL=emacsclient
    
  10. I prefer to to only use a single command, “emacs”, and “the computer” should figure out
    IF an Emacs server is running (then I’ll use “emacsclient” to attach to a running Emacs server)

    OR if I have to start a new Emacs session (which, in turn, starts an Emacs server).

    ## you can always use the command "emacs" instead of "emacsclient -c"
    alias emacs='emacsclient -c'
    
  11. Sugar: To be sure to have an Emacs server running, we can add the Emacs daemon to our system startup options. How to add scripts to your startup options differs strongly between different Linux systems. Here’s how I did it (using Gnome):”System” -> “Einstellungen” -> “Startprogramme”(in English this should correspond to something like “System” -> “Settings” -> “Start programs”)I added a new entry with the following content:
    /path/to/your/emacs --daemon
    

    ie:

    /usr/bin/emacs --daemon
    
  12. Further sugar: To use a Gnome panel starter, just add this program parameter to the starter properties:
    /usr/bin/emacsclient -c