• No results found

Speed up Linux with Openbo

We’re always looking for ways to speed up our systems. Whether we’re trying out lighter distros

or desktop environments, building from scratch or selecting the perfect array of apps, there are many ways to accomplish this. One of the ways that can sometimes get overlooked, though, is changing your window manager – the set of packages that handles the actual windows of your desktop.

One of the most popular and lighter window managers is Openbox. It’s one of the main window managers in LXDE, and readily available to a lot of distros either through their repos or

via the website. It can noticeably speed up your desktop, especially if you’re using GNOME, KDE and the like.

Openbox can also be used as your main, supercharged and minimal desktop environment. It uses a much simpler layout than some of the more popular desktop environments; however, it’s perfectly usable with a few tweaks and may just greatly increase your workfl ow.

The best part is, you can go back easily to your old desktop or windows manager whenever, thanks to the way Linux login managers handle desktop sessions.

Resources

Openbox:

openbox.org/wiki/Openbox:Download

Speed up a core part of your system by using Openbox instead of the standard window manager

Use Openbox as a desktop environment for super-speedy and customisable workfl ow

Personalise Openbox to make it more usable in the way you wish with docks, taskbars and extra menus Maintain the other aspects of your

favourite desktop environment while using the lighter, faster Openbox

01

Install Openbox

Installing Openbox to your system is very easy. You can fi nd it in your graphical package manager or software centre, or install it with the following for Debian-based systems:

$ sudo apt-get install openbox

…and for Fedora it’s:

$ sudo yum install openbox

02

Use Openbox

Log out of your distro. MDM, GDM, LightDM and KDM will all allow you to select a session at the login screen – open the selection and you’ll see that you now have the option to use GNOME/Openbox or KDE/Openbox.

03

Basic confi gure

Openbox is highly confi gurable, and the most basic confi guration can be found in the graphical manager for this. Here you can change the windows theme, the way the windows react during your workfl ow, and whether or not you want to use a dock.

05

System tray

To get a panel with open windows and system trays, your best bet is to install tint2. To do this, you’ll need to simply install it using the terminal we just opened. The package is called tint2, so for Fedora it would be:

$ sudo yum install tint2

08

Backgrounds

To be able to set a background image and fully customise your Openbox desktop, the best package for the job is Nitrogen. It comes with a graphical interface to choose backgrounds and can be installed with:

$ sudo apt-get install nitrogen

09

Saving screens

You can install a screensaver to Openbox by using the basic xscreensaver. Install it with something like:

$ sudo yum install xscreensaver xscreensaver-gl

To modify it, run xscreensaver-demo

from the terminal. This also adds power management options.

10

Autostarting

These will not automatically start when logging into Openbox, so we need to create an autostart script to deal with it. Create a confi g directory with:

$ mkdir ~/.config/openbox

…and then open a new autostart fi le with:

$ nano ~/.config/openbox/autostart

04

Log into Openbox

Log back out and select the Openbox desktop from your session manager. After logging back in, you’ll be presented with a basic grey desktop and not much more. Right- clicking will open up some options; for now, open the terminal.

07

Desktop compositing

For Docky to work properly, there needs to be some degree of desktop compositing. One of the best ways to do this while still keeping a quick system is to use xcompmgr. Install on Fedora with:

$ sudo yum install xcompmgr

06

Docking

You can create a shortcut dock for apps to live on, similar (but better) than what you get in OS X. It was used in Fuduntu, and is nice and lightweight. To install Docky in something like Debian, use:

14

Python imports

Set up the script so we can use the necessary Python elements with:

#!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk import os import getpass

13

Shut down

Openbox doesn’t have a specifi c menu that lets you shut down graphically. Crunchbang, a Linux distro that uses Openbox, has a great Python script for this that we can borrow from. First of all, create the shutdown menu script with:

$ sudo gedit /usr/bin/cb-exi

12

Numlock on

By default, the numlock will not be kept on when logging into Openbox. To get this to happen at startup, install the numlock x package with yum or apt-get, and then add this line to the autostart script:

numlockx on &

11

Start script

Add the individual elements to the autostart script like so:

nitrogen --restore & tint2 &

xcompmgr -c -t-5 -l-5 -r4.2 -o.55 & docky &

xscreensaver -no-splash &

Press Ctrl+X and save the script.

15

Shutdown confi rmed

For a simple shutdown button, you'll need to do the following in the script:

class cb_exit: def disable_buttons(self): self.shutdown.set_ sensitive(False) def shutdown_action(self,btn): self.disable_buttons() self.status.set_

label("Shutting down, please standby...")

os.system("dbus-send

--system --print-reply --dest=\"org. freedesktop.ConsoleKit\" /org/ freedesktop/ConsoleKit/Manager org. freedesktop.ConsoleKit.Manager.Stop")

def create_window(self):

self.window = gtk.Window() title = "Shut down " + getpass.getuser() + "? Choose an option:" self.window.set_title(title) self.window.set_border_ width(5) self.window.set_size_ request(500, 80) self.window.set_ resizable(False) self.window.set_keep_ above(True) self.window.stick self.window.set_position(1) self.window.connect("delete_ event", gtk.main_quit) windowicon = self.window. render_icon(gtk.STOCK_QUIT, gtk. ICON_SIZE_MENU) self.window.set_ icon(windowicon)

19

Cancel button

You can add a cancel button by defi ning cancel_action like so:

21

Add button

Open obmenu, and expand the Openbox 3 arrow. Choose a place to add the button and press New Item. Give it any label you wish, such as Shutdown, make sure Action is set to Execute, and set the Execute command to /usr/bin/cb-exit.

20

Menu button

To add this shutdown menu to the Openbox menu, you'll need to install obmenu. This graphical tool can help you add apps and scripts to the menu, and is easy to use and very customisable. Install it with something like:

$ sudo yum install obmenu

22

Extra menus

From here you can add extra buttons, apps and functions to the right-click menu and customise your experience. There’s a lot of extra customisation you can do with Openbox in general as well, with theming options, behaviour options and much more.

16

Shutdown button

That’s the function of the button set up; now for the window and button:

self.button_box = gtk.HBox() self.button_box.show() self.shutdown = gtk.Button("_ Shut down") self.shutdown.set_border_ width(4) self.shutdown. connect("clicked", self.shutdown_ action) self.button_box.pack_ start(self.shutdown) self.shutdown.show()

17

Shutdown window

Finally, we fi nish off the script like so:

self.label_box = gtk.HBox() self.label_box.show() self.status = gtk.Label() self.status.show() self.label_box.pack_ start(self.status)

18

Restart button

To add a reboot button involves almost the same code as the shutdown button. While defi ning reboot_action, make it the same as shutdown_action, but make sure to use the .Restart function from the ConsoleKit. Create the reboot button by simply replacing ‘shutdown’ with ‘reboot’ in the same code.

self.vbox = gtk.VBox() self.vbox.pack_start(self. button_box) self.vbox.pack_start(self. label_box) self.vbox.show() self.window.add(self.vbox) self.window.show() def __init__(self): self.create_window() def main(): gtk.main() if __name__ == "__main__": go = cb_exit() main() def cancel_action(self,btn): self.disable_buttons() gtk.main_quit()

And then adding the button with:

self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL) self.cancel.set_border_width(4) self.cancel.connect("clicked", self. cancel_action) self.button_box.pack_start(self.cancel) self.cancel.show()

Create secure network connections on the fl y and run safely