Saturday, June 25, 2011

Add Openbox to A debian/ubuntu based install

This will be two part: installing and configuring. 

***********************
INSTALL
***********************
Step 1: Install openbox. 
      sudo apt-get install openbox obmenu

Step 2: Install theme managers.
     sudo apt-get install obconf lxappearance

Step 3: Install a panel/dock. I prefer tint2, but other options exist such as pypanel. This walk through will be for tint2. 
     sudo apt-get install tint2

Step 4: Install feh. Openbox can't set a wallpaper, so feh will be used. 
     sudo apt-get install feh 

Step 5: Install gmrun. gmrun will allow easy access to launch programs.
     sudo apt-get install gmrun

Step 6: Install network manager. You are welcome to substitute the gnome network manager here, but I prefer WICD. If you install WICD you should probably remove network-manager. (sudo apt-get remove network-manager)
     sudo apt-get install WICD

Step 7: Install a file manager. You are welcome to substitute nautilus here, but I prefer PCmanFM. 
     sudo apt-get install pcmanfm

In summary:  
        sudo apt-get install openbox obmenu obconf lxappearance tint2 feh gmrun wicd pcmanfm
*********************
CONFIGURATION
*********************
You'll be using the terminal for most of this so go ahead and open one. 

Step 1: Make a config folder for openbox in your home directory. 
     mkdir ~/.config/openbox

Step 2: Copy the default openbox config files into your home directory. 
    cp /etc/xdg/openbox/rc.xml ~/.config/openbox
    cp /etc/xdg/openbox/menu.xml ~/.config/openbox
    cp /etc/xdg/openbox/autostart.sh ~/.config/openbox

At this point you could log out and log back in selecting openbox session at the login screen, unfortunately you'd log in to a bare openbox session and would probably hate it. So we are going to go ahead and make some configuration changes now. 

Step 3: Edit autostart.sh (This file tells openbox what to run when you start an openbox session)
   Set Wallpaper:
    echo "feh --bg-scale ~/Pictures/wallpaper.jpg &" >> ~/.config/openbox/autostart.sh  
     #Substitute the path to your wallpaper for the bolded text.
   Start tint2:
    echo "tint2 &" >> ~/.config/openbox/autostart.sh
     Start network manager:`
    echo "wicd-gtk &" >> ~/.config/openbox/autostart.sh  
     #you can use network-manager here if you want.
   Start MintUpdate (if you are using linux mint):
    echo "mintupdate-launcher &" >> ~/.config/openbox/autostart.sh 
   Start Volume Manager: 
      echo "gnome-volume-control-applet &" >> ~/.config/openbox/autostart.sh 

Step 4: Edit rc.xml (This file does too much to detail here). We are going to change some key bindings.
   
   Open ~/.config/openbox/rc.xml
    gedit ~/.config/openbox/rc.xml
   
   Scroll down until you see: <!-- Keybindings for running applications -->
   
   Add a key binding for gmrun (under what we just looked for):
    <keybind key="W-r">
        <action name="execute"><execute>gmrun</execute></action>
      </keybind>

     Add a key binding for gnome-terminal:
      <keybind key="W-t">
       <action name="execute"><execute>gnome-terminal</execute></action>
           </keybind> 

     Add a key binding for firefox:
      <keybind key="W-w">
       <action name="execute"><execute>firefox</execute></action>
      </keybind> 

   Add a key binding for PCmanFM:
      <keybind key="W-f">
       <action name="execute"><execute>pcmanfm</execute></action>
      </keybind> 

   Add a key binding for gedit:
      <keybind key="W-e">
       <action name="execute"><execute>gedit</execute></action>
      </keybind>
 
 
   Add a key binding for the openbox menu: 
           <keybind key="W-Space">
            <action name="ShowMenu"><menu>root-menu</menu></action>
           </keybind> 


Step 5: Edit menu.xml (The file that makes your pretty ob menu)
You can edit this file with a text editor. Or use menumaker. Or use obmenu. The key binding for gmrun will allow you to run programs by pressing the windows key + r, and typing the name of the program you want to run, and yes tab will autocomplete in the dialog box.
     
   Download menumaker here:  
     http://sourceforge.net/projects/menumaker 

   Extract menumaker: 
    tar -zxvf ~/path/to/the/file (or go to the folder and right click)

   Move the folder to your home directory.

   Rename the folder to make it hidden: add a period at the beginning of the name.

   Add an alias to ~/.bashrc to run menumaker:
    echo alias mmaker='~/.menumaker-0.99.7/mmaker -vf Openbox3' >> ~/.bashrc
     #if you download a different version or save it into a              different location change the path...
    
When you log in to openbox for the first time, open a terminal and run mmaker to create a menu. Then feel free to edit the .xml with obmenu or a text editor.    
**************
FINAL TOUCHES
**************
When you are at the log in screen select openbox session, instead of gnome session, and log in. You should see something similar to this, of course with your background and default tint2 and no running programs:
To change your gtk-theme and icons use lxappearance. Launch it with gmrun or a terminal. To change your openbox theme use obconf. Launch it with gmrun or a terminal. 

//If you know of a better way of doing things feel free to //comment. If you have any questions don't hesitate to ask.

2 comments:

  1. Great post!! thanks for making it a cakewalk for a noob like me. However, I get the below error when I try to use Menumaker. Also, see the first two warnings when I open Gnome-terminal. Any advice is highly appreciated.

    bash: alias: -vf: not found
    bash: alias: Openbox3: not found
    mayamahal@VKM-1:~$ mmaker
    /home/mayamahal/.menumaker-0.99.7/Keywords.py:11: DeprecationWarning: the sets module is deprecated
    from sets import Set as _Set
    /home/mayamahal/.menumaker-0.99.7/Keywords.py:27: DeprecationWarning: object.__init__() takes no parameters
    str.__init__(self, s)
    no frontend specified

    ReplyDelete
  2. It looks like all three problems are caused by the same issue. When you open a terminal and start a bash session it runs through a few config files, like .bashrc, and configures everything for you.

    bash: alias: -vf: not found
    bash: alias: Openbox3: not found

    Both these lines indicate a problem with the .bashrc file, where we set the alias to make mmaker automatically set the openbox menu when we run it.

    The errors that happen when you try to run mmaker suggest that the options (parameters) weren't properly given to it.

    To fix this issue open ~/.bashrc with your favorite text editor (gedit, nano, kate, vim) and add the single quote marks to this line:

    echo alias mmaker='~/.menumaker-0.99.7/mmaker -vf Openbox3'

    Side note: What other tutorials would you like me to post?

    ReplyDelete