Thursday, August 30, 2012

[FIX] X-tile appindicator icons

In Xubuntu, the AppIndicator menu for X-tile doesn't display the icons for the items properly: it displays a icon with the forbidden sign instead.

X-tile's menu displaying the wrong icons
X-tile's menu displaying the wrong icons

In this article I provide a solution to this problem and then I explain what I did to fix it.

Fix

Open a terminal window and run (you'll be prompted for your password and your user must have admin privileges):

wget -q -O- http://goo.gl/BEB6r | tar -xz && cd x-tile-icons && ./install-xdg-icons.sh && cd .. && rm -rf x-tile-icons

As can be seen in the image below the problem is now fixed.

X-tile's menu with the icons fixed
X-tile's menu with the icons fixed

Procedure

In this section I describe what I did for fixing the problem. It isn't necessary to comprehend this section to use the fix. I just wrote it for future reference.

After realizing that I needed to install the icons as resources using xdg-icon-resource, I proceeded with converting the svg icons that existed in X-tile source to PNG images. This step is necessary because xdg-icon-resource only accepts png and xpm.

The code below performs the conversion using convert and mogrify commands, both from the imagemagick package. First, convert is used to convert svg to png, using the option -background transparent to preserve the transparent background. Then mogrify resizes the image to 16 pixels wide with maximum quality ("0" means no compression). The menu icons are 22 pixels wide, but I had to use 16 because they wouldn't be centered, otherwise.

# Convert the svg images to png and resize them
for icon in $(ls *.svg); do 
  icon_png=${icon%svg}png
  sudo convert -background transparent $icon $icon_png;
  sudo mogrify -quality 0 -resize 16x $icon_png
done

After the conversion I stored the png files in a tar file; imagemagick isn't pre-installed so it's easier to download and to install the images than installing imagemagick, convert the images and install them.

Now all that's left is using xdg-icon-resource for installing the icons. But there's a tiny detail that's of the most importance: the optional icon-name parameter must be provided to the command. Because of this, this step becomes cumbersome, for there has to be a match between the file name and the icon name. One can access the matching values on the cons.py file; they're assigned the to the ICONS_FILENAMES variable. Luckily, my programming skills allowed me to cheat and to programmatically write the commands. What I did was to add a new line after the line that starts iterating the icon file names (on the x-tile python file):

for filename, stock_name in cons.ICONS_FILENAMES:
  # added the line below to write the commands for me
  print "sudo xdg-icon-resource install --novendor --size 22 " + filename.replace('.svg', '.png').replace('glade/','') + " \"" + stock_name + "\""

When I ran the program It printed the commands and I just copied and pasted them on the shell script used for the fix. And that's it, the most important part was done; all I had to do was finish the shell script that automates the fix as much as possible.

Tuesday, August 28, 2012

[NEWS] Xubuntu 12.04.1 released

Xubuntu 12.04.1 has been released today along with the rest of the Ubuntu flavors. This means everybody on 10.04 are able to upgrade to 12.04.1 at their convenience. Users on 10.04 should get an upgrade notification when booting their systems up the next time.

Users using Xubuntu 12.04 will be upgraded to 12.04.1 automatically along with normal upgrades.

References

LTS upgrade time!

Undelete bookmarks in Chromium browser

Problem

OMG, I deleted a bookmark/folder in Chromium! How can I get it back?

Undele

Calm down! Take a deep breath, open a terminal window and run:

cd ~/.config/chromium/Default && mv Bookmarks Bookmarks.old && mv Bookmarks.bak Bookmarks

Please note that this should be done before closing chromium more than twice. Otherwise the bookmarks will be gone forever. Also, in my experience, Chromium should be restarted after running the command for the bookmarks reappear.

References

Bookmarks undelete | Google Groups

Install Wine 1.5.11 in Xubuntu (PPA)

Wine 1.5.11 has been released with the following major changes:

  • Multi-channel support in the ALSA driver.
  • Removal of the big X11 lock.
  • Support for pair positioning adjustments in Uniscribe.
  • More I/O stream implementations in the C++ runtime.
  • Various bug fixes.
A total of 36 were fixed in applications such as "SIM City 4", "S.T.A.L.K.E.R.", "F.E.A.R.3", "Fallout 3", "Prince of Persia: Forgotten Sands", etc, and GeForce GT 630M (with Bumblebee) is now properly recognized.

Ubuntu repositories is still 1.4. Bellow instructions are provided to install the latest Wine version from the "Latest official WineHQ releases" PPA.

Install

Open a terminal window and run this line:

sudo apt-add-repository ppa:ubuntu-wine/ppa -y && sudo apt-get update && if [ `uname -m` == "x86_64" ]; then wine="wine1.5-amd64"; else wine="wine1.5"; fi && echo $wine && sudo apt-get install $wine

References

The Wine development release 1.5.11 is now available | WineHQ

Wednesday, August 22, 2012

Count number of characters in file from command line and Vim

The command wc prints several file statistics: bytes, lines, words, etc. Using the -m option we can count the number of characters in a text file.

Install

Open a terminal window and run:

wc -m FILE

We can count the number of characters from Vim editor using this ex command:

:!wc -m %

References

wc(1) - Linux man page

Monday, August 20, 2012

[HOW TO] Install Shoes (Ruby GUI Toolkit) in Xubuntu

Shoes is a cross-platform toolkit for writing graphical apps easily and artfully using Ruby. Unlike most other GUI toolkits, Shoes is designed to be easy and straightforward without losing power.
Shoes (Ruby GUI Toolkit) running on Xubuntu 12.04
Figure 1. Shoes (Ruby GUI Toolkit) running on Xubuntu 12.04

Installing Shoes on Xubuntu (or any other Ubuntu distribution) is not as straight forward as it should be. There's a Shoes package in the Ubuntu repositories, however, it's buggy and using it will result in the following error:

no such file to load -- rubygems

From my experience building Shoes might result in errors during the process.

The easiest and simplest way to install Shoes in Xubuntu were to download Shoes 2 (0.r1134), codenamed “Raisins” and use it to run the Shoes programs. It's a older version, but I'm just getting started with Shoes and for now it'll suffice.

Install

Open a terminal window and run:

sudo wget -O /usr/local/bin/shoes http://goo.gl/3cigS && sudo chmod +x /usr/local/bin/shoes

Usage

Shoes can be accessed typing the following command: shoes [SHOES_PROGRAM].

Running Shoes without arguments will run the interface shown on Figure 1. Then you use the "Open an App" option to run a Shoes program.

If you supply the Shoes program path to the shoes command, the program will be launched right away.

Example

Wanna take it for a spin? Run the following instruction to see it in action:

echo -e 'Shoes.app :width => 300, :height => 200 do\n  button("Click me!") { alert("Xubuntu Geek.") }\nend' > ~/hello_shoes.rb && shoes ~/hello_shoes.rb

This instruction will create a "hello_shoes.rb" file with the content shown below this paragraph. Then it'll the Shoes program. The result is shown on Figure 2.

Shoes.app :width => 300, :height => 200 do
  button("Click me!") { alert("Xubuntu Geek.") }
end
Hello World Shoes application running on Xubuntu
Figure 2. Hello World Shoes application running on Xubuntu

References

shoes gui - Ubuntu Forums
Shoooes!

Friday, August 17, 2012

Assign Ctrl+Alt+Del to Xfce's Task Manager in Xubuntu

UPDATED: 18/08/12.

By default the Ctrl+Alt+Del run xflock4 which locks the desktop. In this article we'll change this keyboard shortcut so that it'll run Xfce's Task Manager instead. Also the Ctrl+Alt+L shortcut will be assigned for running xflock4.

Xfce's Task Manager
Xfce's Task Manager

Install

Open a terminal window and run these two commands:

# Assign Ctrl+Alt+Del to Task Manager
xfconf-query -c xfce4-keyboard-shortcuts -n -p "/commands/custom/<Primary><Alt>Delete" -t string -s "xfce4-taskmanager"
# Assign Ctrl+Alt+L to xflock4
xfconf-query -c xfce4-keyboard-shortcuts -n -p "/commands/custom/<Primary><Alt>l" -t string -s "xflock4"