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

Skype on Ubuntu 8.10: microphone and internal speaker issues

It has been a long time since my last post… Also, it has been some time I managed live without a PC and Internet. Now I have a PC and Internet again and I took the chance to immediately install Linux!

Updated: I also solved the issue of skype consuming 100% cpu during a call.

Although the Ubuntu Guide has a good description how to install Skype on Ubuntu Intrepid, it can be quite challenging to place a call successfully. Shame on Gnome, Pulse Audio and Skype! I had to overcome following issues:

  • No audio on skype, or Skype complaining that sound device does not work.
  • No microphone input during calls.
  • Call also audible from the internal speaker (even when headset is connected to the green audio jack).
  • Skype consuming 100% cpu during the call and Skype delaying audio over 60 seconds!

Here is the solution that worked for me.

Read more of this post

Resume scp/rsync file transfer

This is very basic Linux knowledge, but the question has arisen too often and I decided to document it.

Problem:

Transfer (or upload/download) a large tree of files and directories from one machine to another using a ssh connection, and being able to resume/continue if the operation is interrupted.

Solution:

Until now, I believe that the best solution is using rsync over ssh, since rsync has a feature to resume interrupted file transfer, even when an entire tree of directories is involved.

Command line:

rsync -vrlPtz -e ssh host:/remote_path/* /local_path/

Explained:

-e ssh rsync will use ssh client instead of rsh
-z compress file transfer
-t preserve time (other attributes as owner or permissions are also possible)
-l copy symlinks as symlinks
-P resume incomplete file transfer
-r recursive into subdirectories
-v verbose
Optionally, you may also add following options, that make sense only if both machines have the save user name space:
-p preserve permissions
-o preserve owner
-g preserve group

PCMan: the real and true Gnome file manager

I have modified this post after several people complained that I was misunderstood: Nautilus can, sure, display a tree view of the file system. Sure, but only for “who-knows-how”.

I do not like Gnome desktop environment because of its excessively simplified GUI that leverages all users as if they lack minimal skill to interact with a computer. And what I dislike most on Gnome is even more oversimplified vision of the file system provided by Nautilus on its default configuration.

Please, the converse is not true: I do not love KDE. And even more disappointing was seeing KDE 4 abandoning its advantages over Gnome just to become similar to Gnome (after a while, KDE 4 will not have anymore its nice power-user features, nor the nice simplicity of Gnome).

Specially annoying is the “Spatial Navigation” that opens a new window for each folder that is accessed (although real [wo]men would call it “directories”). As soon you have more than a bunch of directories, navigating from one to other will open more and more windows on your desktop just to drive you crazy.

Sure, Gnome developers will explain that a typical user will not own more than a hand full of files. And, they will store everything on the same folder like “documents” or “images” (or even on the desktop leading to the result of the picture on the right). They

Screenshot from a user that stores all documents on his desktop folder

Screenshot from a user that stores all documents on his desktop folder

will never store their files in a secure separated partition, nor on a file system over the network. Just in the case that the amount of files gets out of control, the user will create one or other subdirectory here or there. Therefore, subdirectory navigation is not necessary and it is reasonable to display the content of all directories at the same time.

By the way, Nautilus also claims to support file system browsing. Just click “browse” instead of “open” is what they say. However, there are some issues to consider. The “browsing” features are not visible by default. And a feature that is not visible, or that is very difficult to find, in practice, is not a feature at all. There is no preference where the user can easily choose which configuration he prefers. Googling around shows very few references about “nautilus tree view”. Asking experienced Gnome users was of nearly no use.

After reading the entire Nautilus documentation and after getting some good advices from people that read this article, I understood how. The user needs to start Nautilus with the –browse parameter on command line, open any folder with the “browse” command, then go back again to original folder. The, the user needs to display the side pane and select to tree visualization on this pane (it took a while how to figure out that I can change the content shown by the side pane).

Finally, one will be able to see the directory hierarchy and be able to jump to sibling directories. It is possible only to go to/from parent and child directories.

Fortunately, I discovered an alternative that allows the real and true file system browsing. It is called PCMan File Manager, and stays a bit hidden on most Linux distros. At the beginning, it provides an appearance familiar to Nautilus, and understands the same pre-defined folders like “documents” or “images”. However, after a short time of use, one will soon discover the power-user features that are available.

PCMan claims to be extremely fast and lightweight. I do not think this matters most, compared to the features it provides. It has a sidebar with useful and organized common locations and mount points. The sidebar may also display a complete tree view of the file system. Tabbed browsing is also supported.

I liked most that each tab has its own tree view. It was really annoying on KDE/Konqueror that the tree view did not always match the focused tab. The tree view is completely absent in Nautilus. Also I like the organized common locations and mount points. Although Konqueror has something similar, it is not as organized and as useful as it is on PCMan.

Also, there are features I still need to get better acquaintance: mounting/unmounting/ejecting media within PCMan. I really dislike having an icon for storage devices on the Gnome/KDE desktop while not being able to see and manage them within Nautilus/Konqueror.

Other nice feature is opening a directory as root, avoiding the need to switch to a terminal or to log-in as a different user.

However, I was not able to open and browse very large directories, like /usr/bin, as promised by PCMan web site.