Create a custom application link in LXPanel

lxdeIf you are a Lubuntu or LXDE desktop environment fan, at one point or other you might have wanted to add an LXPanel launcher for an application which is distributed as a binary or as an archive (i.e. not the standard installation). However, it is rather tricky if you don’t know where to add what. This article is meant to be a small how-to on adding a custom app link in LXPanel. We will add a link to Pale Moon browser which is distributed as an archive. The archive is extracted in /opt. Steps:

  1. Edit ~/.config/lxpanel/LXDE/panels/panel. Look for the Plugin type = launchbar section and add a link to the palemoon.desktop file (which we will create in the next step).
    Plugin {
     type = launchbar
     Config {
      ...
      Button {
       id=/usr/share/applications/palemoon.desktop
      }
      ...
     }
    }
  2. Create a new file /usr/share/applications/palemoon.desktop as root and add the following in it:
    [Desktop Entry]
    Name=palemoon
    Comment= Browse internet
    Exec=/opt/palemoon/palemoon
    Icon=/opt/palemoon/browser/icons/mozicon128.png
    Type=Application
    Terminal=false
    StartupNotify=false
    Categories=Application;Internet;

    You will need to adjust the entries for a different application.

  3. Logout and login and the new icon should show in LXPanel now.

Set DNS server on LXDE (Ubuntu)

lxdeI prefer the Google DNS servers (8.8.8.8/8.8.4.4) for faster DNS resolution. While the procedure to set it on Unity is trivial, setting it on LXDE needs little more effort.

  1. Edit /etc/NetworkManager/NetworkManager.conf and comment out the line starting with dns.
    dns=dnsmasq
    to
    #dns=dnsmasq
  2. Edit /etc/resolv.conf and add the preferred nameservers before any other entries.
    #Google
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    #OpenDNS
    nameserver 208.67.222.222
    nameserver 208.67.220.220
  3. Reboot and ensure the settings took effect.
    $ nslookup www.google.com
    Server: 8.8.8.8
    Address: 8.8.8.8#53
    ...

This procedure is tested on Ubuntu 14.04 (aka Trusty Tahr).

Grab, move windows with keyboard on LXDE

lxdeGnome provides a hotkey to move windows with your keyboard only: Alt+F7. To use the same binding on the LXDE  desktop environment (which uses Openbox), edit the file ~/.config/openbox/lxde-rc.xml and add the following in it as a keybind in the keyboard section:

<keybind key="A-F7">
  <action name="Move"/>
</keybind>

For immediate effect, run:

$ openbox --reconfigure

When you are done moving a window with the arrow keys, press Enter.

If you are a Unity user, use Ctrl-Super-arrow keys to move the focused window.

Use brightness keys with LXDE (Ubuntu on Sony VAIO)

lxdeMy brightness keys were not working out of the box when I switched to LXDE from Unity. Though I keep the brightness constant, I still wanted to make it work in case I need to change the level anytime. I kept the range between 5 to 50 as those limits are fine for me. Here goes how I did it with simple scripts.

The following script (br+) increases the brightness:

#!/bin/bash

curval=`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper \
--get-brightness`

if [ $curval -ge 50 ]; then
echo already max
else
`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper \
--set-brightness $(expr $curval + 5)`
fi

The script (br-) to decrease the brightness:

#!/bin/bash

curval=`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper \
--get-brightness`

if [ $curval -le 5 ]; then
echo already min
else
`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper \
--set-brightness $(expr $curval - 5)`
fi

Made both the scripts executable and moved to /usr/bin as root. The next step was to find the key mappings for the brightness keys. The tool I used to find that out is xev. It revealed that the keys are XF86MonBrightnessUp and XF86MonBrightnessDown. So I added the following in ~/.config/openbox/lxde-rc.xml along with other keybind actions:

<keybind key="XF86MonBrightnessUp">
  <action name="Execute">
  <command>br+</command>
  </action>
</keybind>

<keybind key="XF86MonBrightnessDown">
  <action name="Execute">
  <command>br-</command>
  </action>
</keybind>

That’s it! Just relogged-in and had functional brightness keys! You can download the scripts from here. It’s tested it on a Sony VAIO SVS13112ENB running Ubuntu 13.04 (Raring).

Suspend on lid close on LXDE, Ubuntu

lxdeBy default LXDE does not suspend the laptop on lid closure. I was trying to enable suspend on sleep as most of the time I close the lid when I am not using the laptop. It saves power and at the same time resume is faster as everything is still in RAM. The event responsible for lid closure or open is button/lid. What you need to do is to bind it with an action to suspend the laptop. However you need to take care that suspension is done only on lid closure. Here’s what I did on Ubuntu 13.04 as root:

  1. Add the following in /etc/acpi/events/lid:
    event=button/lid
    action=/etc/acpi/actions/lid.sh %e
  2. The directory for action scripts may not exist by default on Ubuntu. Create it:
    mkdir -p /etc/acpi/actions
  3. Add action to suspend when the event occurs. Create /etc/acpi/actions/lid.sh and add:
    #!/bin/bash
    echo "$1" | grep -q open /proc/acpi/button/lid/LID0/state && exit 0
    sleep 2
    /usr/sbin/pm-suspend
  4. Make the script executable and restart the acpid service:
    chmod +x /etc/acpi/actions/lid.sh
    restart acpid

Useful links:

LXDE on steroids!

While Unity has come a long way to silence its initial critics (I was one of them), I was still looking for an alternative desktop environment which is minimal and superfast. I spent the last weekend trying out and customizing the LXDE desktop environment with Openbox as window manager. To my excitement, I could get the same look and feel as SliTaz.

Power tips to customize LXDE as the perfect desktop.

Installing LXDE on stock Ubuntu is simple. Just select the package lxde from synaptic and install it. From the cmdline:

$ sudo apt-get install lxde

Once done, log out and login back selecting the LXDE desktop environment.

The Linux Mint LXDE PPA seems to maintain more recent packages than in the default Ubuntu repos. To install the latest packages, run:

$ sudo apt-add-repository ppa:mati75/mint-lxde
$ sudo apt-get update
$ sudo apt-get upgrade

I edited ~/.config/openbox/lxde-rc.xml to add keyboard shortcuts to turn screen or touchpad off. Some useful keybinds:

  • Windows  Super_L (in case you are used to it due to Unity)
  • ASSIST  Help (on Sony VAIO)
  • WEB  XF86HomePage (on Sony VAIO)

To get the changes in lxde-rc.xml into effect immediately, run:

$ openbox --reconfigure

Now let’s discuss the look and feel. I keep changing the theme, icons etc. occasionally for some variety and not to get bored watching the same desktop regularly. I found the following themes and iconsets give LXDE a stunning look:

  • Adwaita-X (Gtk theme)
  • Evolve & Evolve-Darker (Gtk theme)
  • Zukitwo (Gtk theme)
  • +1_25032013 (Gtk theme)
  • Vertex (Gtk theme)
  • Zorin OS 8 (Gtk theme)
  • Elementary OS Openbox (Openbox theme)
  • 1977 Openbox (Openbox theme)
  • Zukitwo Box (Openbox theme)
  • Ambiance Crunchy (GTK3 Openbox theme)
  • Elementary (icons from Elementary OS)
  • libreoffice-style-sifr (cool LibreOffice theme in default repos)
  • Vibrancy Colors (Gtk icon Theme)

I brought own the panel height to 18 along with icon size 16. More space for activities! CPU temperature varies between 42-50°C during normal usage. I have also installed preload recently. I didn’t add any mixer for volume control, the default keys just work fine. I can toggle the microphone with the following command:

$ amixer set Capture toggle

If you want a mixer pavucontrol is the best option.

If you want to remove Firefox borders completely (saves a lot of space since Firefox 29) for maximum screen space, you can do that. It removes the maximize, minimize and close buttons but shouldn’t be a big problem because you can click on the panel to do these. In addition, you can press <Alt-Space> to get the Window menu. Once again, you need to edit the lxde-rc.xml file and add the following within applications tag:

<application class="Firefox">
<decor>no</decor>
</application>

For more control on the Firefox Australis theme (introduced in version 29) use the HTitle or Hide Caption Titlebar Plus extension.

After updating to Saucy, I faced an issue with window placement. They do not open centered any more. To fix it, add the following in lxde-rc.xml:

<application class="*" type="normal">
<position force="yes">
<x>center</x>
<y>center</y>
</position>
</application>

To change or add default programs to handle mime types, edit ~/.local/share/applications/mimeapps.list.

To configure the LXDE main menu, edit:
/etc/xdg/menus/lxde-applications.menu

To control apps which would autostart, use:
~/.config/lxsession/LXDE/autostart
/etc/xdg/lxsession/LXDE/autostart

The system responsiveness and speed is incredible along with all this on LXDE. Without preload the memory usage immediately after a cold boot is 153MB and applications open and run in a snap!!!