Smaller font sizes for Netbeans on Linux

This article describes an approach to launch Netbeans on Linux with smaller and narrower font sizes.

Modern desktop environments like KDE or Gnome suggest larger font sizes to enhance screen readability. However, Netbeans users might not be willing to waste precious space on views around the source code that matters. Here are some alternatives one might consider.

This article originally appeared on https://techtavern.wordpress.com

1) To customize window manager and themes

The Gnome desktop provides nice dialogs to customize GTK+ and Gnome decorations and font sizes. The KDE desktop offers the QT-GTK binding that applies KDE design on GTK/Gnome applications. While simple, this alternative applies to Netbeans and all other application, which might not be your intention.

2) To adjust Netbeans options

On the Netbeans IDE menu, navigate through “Tools“->”Options“->”Fonts & Colors” to reach a dialog where one may adjust an assortment of editor aspects. Unfortunately, these options do not affect menus, dialogs or views, which in turn follow the Gnome theme settings.

3) To append the netbeans command line

According to a Netbeans FAQ, one may append the netbeans command line with this parameter: --fontsize <size>. However, this does not affect Netbeans anymore on recent Java VMs, which follow the Gnome theme, regardless of the font size parameter. Neither does it allow one to change the font itself.

4) To edit the netbeans.conf file line

Further, the Netbeans FAQ explains the possibility to edit the etc/netbeans.conf file to the add the –fontsize <size> parameter at the end of the netbeans_default_options property. As observed for the previous command line approach, it does not work anymore on recent Java VMs, which unconditionally follow the Gnome theme.

5) To work out your own Gnome theme

The less usual approach defines a Gnome theme solely for the Netbeans IDE and allows to customize every aspect of the GUI, including font and font size. To safe effort, it is possible to reuse an existing theme and override just the font and font size.

For example, in order to launch Netbeans with a theme modification based on ClearLooks, following command line would work:

GTK2_RC_FILES="/usr/share/themes/ClearLooks/gtk-2.0/gtkrc:/home/user/custom-gtkrc"
   /home/user/netbeans/bin/netbeans

This approach relies on a custom-gtkrc file that overrides some aspects from the ClearLooks theme, in particular, the font and font size. This custom-gtkrc file could look as the example that follows:

style "user-font" {
 font_name = "<strong>Dejavu Sans Condensed 9</strong>"
}
class "GtkWidget" style "user-font"
widget_class "*" style "user-font"

Not only does this customization reduce the font size to 9, but it also suggest a condensed variation of the font with narrower letters. But condensed variation is available only for some specific fonts.

Here are some screenshots:

Netbeans IDE with original font: Sans 12

Netbeans IDE with original font: Sans 12

Netbeans IDE with smaller and narrower font

Netbeans IDE with smaller and narrower font

Copy files by extension that keeps directory structure

Some more essential Linux knowledge, written down to document it.

Problem:

Copy only files by their type (or file extension), while preserving the directory structure.

Solution:

I would recommend using rsync that copies files recursively and allows filtering them by their file name. The challenge is configuring a set of filter rules.

Command line:

To copy everything: rsync -avim –include=’*/’ –include=’*.doc’ –exclude=’*’ /source /destination

Explained:

Copy recursively. Go down into directory structure.

-a (Archive) Copy everything (files, directories, symbolic links, devices), recursively and preserve applicable file attributes (permissions, time, ownership).
-m (Prune) Do not create destination directories that would be empty as they do not contain files that with intended file extension.
-i (Summary) Print change-summary for all copied files.
–include=’*/’ Thats the point. Prevents the exclude parameter (shown and explained below) from skipping only unwanted files, but not from inadvertently skipping subdirectories.
–include=’*.doc’ (Include rule) Copy files of intended file extension, for exemple, ‘*.doc’ or ‘*.txt’. You may repeat this parameter if more that one file type should be copied. Pay attention to the quotes.
–exclude=’*’ Ignore all other files that were not included by extension.

Optionally, you may replace the “-a” option by “-rlptgoD” if you want to specify yourself which file types (file, directory, device, symbolic link) should be copied and while file attributes (time, ownership, permissions) should be preserved. But do not forget the “-r” for recursive file discovery.

Ubuntu 9.04: Skype issues

This article addresses an issue similar to another that I have already adressed for Ubuntu 8.04: How to correctly configure Skype on Ubuntu 9.04.

First, I assume that Skype was installed from midibuntu.org repositories.

Issue 1: Speakers do not work.

The first required configuration change is setting Skype to use Pulse Audio Support instead of default (ALSA) sound drivers. Go to Skype->Options->Audio Devices. Select “pulse” for all audio devices.

I also recommend to disable an option like “Allow Skype to automatically adjust mixer levels” for this first moment. While this option was enabled, I have experienced Skype undoing the correct configuration and turning off my microphone volume before each call . After you manage to have Skype working fine, then you may enable this option again to see if Skype continues working fine :-)

Issue 2: Voice gets delayed or cut.

There is a known issue where Skype overloads CPU while the microphone records from the Pulse Audio Support. Voice gets heavily delayed (eg. more than 60 seconds). You need to switch the microphone device to another but not “pulse” nor “alsa”. Try selecting the entry that describes your microphone hardware. You may need to take several tries until you find out the device that really maps to your microphone. Fortunately, you can play around during a test call, if you always press the “apply” button. On my desktop, the correct option is called “Intel ICH5 (hw:ICH5,0)”.

Ubuntu 9.04: Microphone issues

Continuing the discussion of audio configuration issues on Ubuntu 9.04…

If you are using Skype, please also read my next article that discusses Skype on Ubuntu 9.04.

I suggest testing the microphone with the “Sound Recorder” that is found in the “Applications”->”Sound and Video” menu of the top bar on the Ubuntu desktop. Ensure that “voice, lossless (.wav)” (may vary according to your language) is selected. Click on “Record” and talk to the microphone. The “Level” bar should increase as you talk louder. Click on “Stop” and “Play” to hear if your voice was recorded sucessfully.

Issue 3: Microphone does not work

Solution: Enable the microphone capture. Right-click the volume icon on the left of the top bar on the Ubuntu desktop and select “Mixer” or “Volume Control” (may vary on according to your language). The mixer dialog opens. Click on “Preferences” to open the preferences dialog, enable “Microphone” and “Microphone Capture” and click on “Close” to return back. Move the “Microphone” slide up, ensure button underneath the slide is not “muted”. On the “Switches” tab, enable “”Microphone Capture”.

Issue 4: Microphone is too quiet

Solution: Raise capture volume. Back to the mixer dialog, click on “Preferences” to open the preferences dialog, enable “Capture” and click on “Close” to return back. On the “Recording” tab, move the “Capture” slide up, ensure button underneath the slide is not “muted”.

Issue 5: Is still too quiet

Solution: Enable the microphone boost. Back to the mixer dialog, click on “Preferences” to open the preferences dialog, enable “Mic boost +20dB” and click on “Close” to return back. On the “Switches” tab, enable “Mic boost +20dB”. If microphone becomes too lound or too noisy, just disable this option again.

Ubuntu 9.04: External and internal speaker issues – part 2

If you run Ubuntu 9.04 and your desktop or laptop is featured with both internal speaker and TRS jacks for external speakers, then you might face some issues that sound is played on both. I have written some articles where I propose some very simple solutions and you may try them and choose the one you like most.

Issue 2: Connecting the headset does not turn off internal speaker.

Try to connect/remove a headset from the external jack and observe if your internal speaker becomes automatically muted. If not, then some more configuration is required.

Solution 1: Previously, I explained how to display the “Master mono” and “Headset” slide bars. Slide down the “Master Mono” and click on the “Mute” button underneath this bar. This will completely disable the internal speaker (until you un-mute it again and raise its volume slide bar).

Solution 2: Right-click the volume icon on the left of the top bar on the Ubuntu desktop and select “Mixer” or “Volume Control” (may vary on according to your language). The mixer dialog opens. Click on “Preferences”. Enable “Headphone Jack Sense” (eventually you will need to scroll down the list to see this option). Click on “Close”. The previous mixer dialog should now display a “Switches” tab. Click to open it and you will see the “Headphone Jack Sense” switch. Whenever you want the internal speaker to mute automatically when an external speaker is connected, just enable it.

Actually, I use to enable it once and leave it enabled forever…

Ubuntu 9.04: External and internal speaker issues

If you run Ubuntu 9.04 and your desktop or laptop is featured with both internal speaker and TRS jacks for external speakers, then you might face some issues that sound is played on both. I have written some articles where I propose some very simple solutions and you may try them and choose the one you like most.

Of course, I discarded any inappropriate solutions that were proposed in several forums: editing mysterious configuration files,recompiling the kernel and unplugging the internal speaker from the motherboard.

There are much simpler approaches. First, let play some of your favorite songs to observe if the proposed changes really reflect the audio configuration.

Issue 1: Does master volume really work?

Click on the volume icon that uses to be placed on the right of the top bar on your Ubuntu desktop. Slide the bar and observe if music gets more or less louder. If nothing happens, then there will no common control for both internal and external speakers, unfortunately.

Solution: Right-click the volume icon and select “Preferences”. Ensure that the first line display the option that contains “Alsa Mixer”. Then select “Master mono” or “Headset”. Now the slide bar will control the volume of your internal or external speaker. It will control only one of them, but not both. It is not ideal, but less inconvenient than controlling nothing. If you now a better solution, please leave me a note.

Right-click the volume icon and select “Mixer” or “Volume Control” (may vary on according to your language). The mixer dialog opens. Click on “Preferences”. Disable “Master”. The master volume slide bar will disappear. Ensure that “Headset” and “Master mono” is enabled. Now you might control the volume of both internal and external speaker independently through the mixer dialog. Just note that if your have an external speaker connected to the external jack, then the slide bar for “Headset” is actually changing volume of your speaker.

Regex that matches path, filename and extension

I was looking for a regular expression for Python capable to match a string containing a valid path, file name and extension. Finally, I discovered following solution:
^(.*/)?(?:$|(.+?)(?:(\.[^.]*$)|$))
Let me explain how I got this regular expression. Fortunately, Scott Carpenter has written an excellent article about a regular expression to match a file name with extension. Matching the file name extension is not trivial for all possible situations.

Read more of this post