Using Open Source Software on Windows

0
5838

Programmer working on windows

Sometimes, for compelling reasons, one is forced to work on proprietary software like Microsoft Windows. Even then, one can take advantage of open source software designed for Windows. In this article, the author describes various software that can be installed on Windows, along with a few tips on how to use these effectively.

The site www.netmarketshare.com displays the current break-up of the desktop operating systems’ market for July 2015 (Figure 1). At the outset, it’s important to acknowledge the problems related to software, which are always the same. On my computer at home, I have the freedom to install my preferred GNU Linux distro, but if I work at a company, I’m forced to use Windows, which is so prevalent across enterprises. Generally speaking, at home, I can also use Windows, usually pre-installed, as a base on which it is possible to add free and open source software. The software shown in Table 1 can be classified, more or less, into the following three categories:
1. Free and open source
2. Free (or free for personal use only) but not open source
3. Commercial (only one: FaxTalk)
With the only exception of FaxTalk (in my opinion, nice and cheap), for personal use, the cost of using either of the above is equal to zero. This article will present some tips and tricks tested on Windows 7 and related to the software that is highlighted in bold in Table 1.

Table 1
Table 1: Software for installation on Windows 7

Text editors
The importance of a text editor is well known. On Windows, a long list of text editors is available. This section describes how to build a syntax highlighting file for jEdit (http://jedit.org) and for Notepad++ (https://notepad-plus-plus.org). Now, I would like to consider an imaginary programming language called qwerty. In the qwerty language, a comment line starts with a double slash (// this is a comment) and the strings are those between two quotation marks (“this is a string”). This language has many keywords which can be classified into various categories. In jEdit, the syntax highlighting file has the following structure:

<?xml version=”1.0”?>
<!DOCTYPE MODE SYSTEM “xmode.dtd”>
<!-- jEdit syntax file for the qwerty language -->
<MODE>
<RULES IGNORE_CASE=”FALSE” HIGHLIGHT_DIGITS=”FALSE”>
<SPAN TYPE=”LITERAL1” ESCAPE=”\” NO_LINE_BREAK=”FALSE”>
<BEGIN>”</BEGIN>
<END>”</END>
</SPAN>
<EOL_SPAN TYPE=”COMMENT1”>//</EOL_SPAN>
<KEYWORDS>
<!-- Category 1 -->
<KEYWORD1>this-is-a-keyword</KEYWORD1>
...
<!-- Category 2 -->
<KEYWORD2>this-is-a-keyword</KEYWORD2>
...
<!-- Category 3 -->
<KEYWORD3>this-is-a-keyword</KEYWORD3>
</KEYWORDS>
</RULES>
</MODE>

Because I’m not interested in highlighting the digits, this option is defined as ‘false’. Save the file as, for example, qwerty.xml, and put it in the modes directory (C:\Program Files\jEdit\modes). Then add the following line to the catalogue file located in the same directory:

<MODE NAME=”qwerty” FILE=”qwerty.xml” FILE_NAME_GLOB=”*.qwe” />

For Scilab (http://www.scilab.org), the complete file about this first example is freely (as in ‘freedom’ and in ‘beer’) available at https://github.com/astonfe/scilab. In Notepad++, a syntax highlighting file is not very different from that for jEdit, and has a structure divided more or less into three sections. The comment line, math operators, punctuation, parentheses and some keywords, for example, in an if-else-end statement are in the first section:

<Keywords name=”Comments”>00//</Keywords>
<Keywords name=”Operators1”>+ - * / = ' , ; . : &lt; &gt; ( ) [ ] { } | &amp; ~</Keywords>
<Keywords name=”Folders in code2, open”>for function if select try while</Keywords>
<Keywords name=”Folders in code2, middle”>case catch else elseif</Keywords>
<Keywords name=”Folders in code2, close”>end endfunction</Keywords>

The keywords according to the following simple schema are defined in the second section:

<Keywords name=”Keywords1”>
this-is-a-keyword
...
</Keywords>
<Keywords name=”Keywords2”>
this-is-a-keyword
...
</Keywords>
<Keywords name=”Keywords3”>
this-is-a-keyword
...
</Keywords>

The strings, as well as the colours and fonts for each of the above categories, are defined in the last section. Save as UserDefineLang.xml and copy to C:\Users\AppData\Roaming\Notepad++. This editor also has its own built-in editor for custom languages, so it’s not necessary to directly edit (Figure 2). For Scilab, a complete file is written by Samuel Gougeon and is available from https://fileexchange.scilab.org/toolboxes/140000.

Figure 1 Desktop operating system market share
Figure 1: Desktop operating system market share
Figure 2
Figure 2: Notepad++ custom language editor

Firefox and Thunderbird
The user and not the software must determine whether or not to install updates. The use of internal options of each program may not work, so an alternative way is presented here. To disable the installation of add-ons, it is necessary to put two files in four directories, according to the following schema:

C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js
C:\Program Files\Mozilla Firefox\mozilla.cfg
C:\Program Files\Mozilla Thunderbird\defaults\pref\local-settings.js
C:\Program Files\Mozilla Thunderbird\mozilla.cfg

To turn off the updates of each application, one file must be added to your profile:

C:\Users\[your-username]\AppData\Roaming\Mozilla\Firefox\Profiles\[your-profile].default\user.js
C:\Users\[your-username]\AppData\Roaming\Thunderbird\Profiles\[your-profile].default\user.js

The contents of these three files are as follows:

// local-settings.js
pref(“general.config.obscure_value”,0);
pref(“general.config.filename”,”mozilla.cfg”);
// mozilla.cfg
lockPref(“xpinstall.enabled”,false);
// user.js
user_pref(“app.update.enabled”,false);

One of the easiest things about Firefox and Thunderbird is how to do a backup. I’m comfortable using the following batch script. A copy of each directory with the current date is created on the desktop.

@rem Backup for Firefox and Thunderbird
@rem Copy from source to destination including subdirs and hidden
@echo off
@for /F “tokens=1,2,3 delims=/ “ %%A in (‘date /t’) do @(
set Day=%%A
set Month=%%B
set Year=%%C
set All=%%C-%%B-%%A
)
mkdir C:\Users\[your-username]\Desktop\Mozilla_%All%
C:\Windows\System32\xcopy.exe C:\Users\[your-username]\AppData\Roaming\Mozilla C:\Users\[your-username]\Desktop\Mozilla_%All% /S /E /H
mkdir C:\Users\[your-username]\Desktop\Thunderbird_%All%
C:\Windows\System32\xcopy.exe C:\Users\[your-username]\AppData\Roaming\Thunderbird C:\Users\[your-username]\Desktop\Thunderbird_%All% /S /E /H
echo Backup completed.

pause

GhostScript
To configure a PDF printer, first install GhostScript and RedMon, the Redirection Port Monitor. I have installed GhostScript in C:\ so its directory is C:\gs9.15. The next step is to add a new printer on the port RPT1. The driver for the HP ColorLaserJet 2800 PS works because it’s both colour and postscript. For this printer, choose a name you like – for example, GS2PDF. Then put the following code in the file C:\gs9.15\pdfwrite.txt:

-IC:\gs9.15\lib;C:\gs9.15\fonts
-sDEVICE=pdfwrite
-dPDFSETTINGS=/prepress
-dCompatibilityLevel=1.4
-dNOPAUSE
-dSAFER
-sPAPERSIZE=a4
-r600

The last step is the configuration of the RPT1 port on which the GS2PDF printer is installed, as shown in Figure 3. Also, under Device Settings, set Send Ctrl-D before each job to ‘‘No’’ and ‘‘Wait Timeout’’ to 1 second. The arguments for GhostScript are as follows:

@C:\gs9.15\pdfwrite.txt -sOutputFile="%1.pdf" -c .setpdfwrite -f -

This first part about GhostScript is based on the notes written by Michael B. McClelland (Reference 1) and by Henrik Schmiediche (Reference 2). On PDF files, there are some common operations that are easy to carry out on Windows. If I need to extract some pages from a large PDF file, I use the following batch script. It’s only necessary to specify the first and the last page numbers to extract the input and the output file names.

@rem PDF extract
@echo off
cd C:\gs9.15\bin
gswin32c.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dBATCH -dSAFER -dQUIET ^
-dFirstPage=2 ^
-dLastPage=6 ^
-sOutputFile="C:\Users\[your-username]\extract4.pdf" ^
"C:\Users\[your-username]\input.pdf"
echo Done.
pause

Another common operation is the merger of some PDF files to obtain one single file. In this case, I use the following batch script, in which it’s necessary to specify the output file name and the file names of each file to merge them.

@rem PDF merge
@rem Input as single files "extract1.pdf extract2.pdf ..."
@echo off
cd C:\gs9.15\bin
gswin32c.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dBATCH -dSAFER -dQUIET ^
-sOutputFile="C:\Users\[your-username]\output.pdf" ^
"C:\Users\[your-username]\extract1.pdf" ^
"C:\Users\[your-username]\extract2.pdf" ^
"C:\Users\[your-username]\extract3.pdf" ^
"C:\Users\[your-username]\extract4.pdf"
echo Done.
pause

There is also another operation that’s sometimes useful – the conversion from a PostScript file to a PDF file. Even in this case, GhostScript can be the solution. In the following script, it’s only necessary to specify the file names of the input and output:

@rem PS2PDF
@echo off
cd C:\gs9.15\bin
gswin32c.exe -o "C:\Users\[your-username]\output.pdf" ^
-sDEVICE=pdfwrite -dPDFSETTINGS=/prepress ^
-dHaveTrueTypes=true -dEmbedAllFonts=true -dSubsetFonts=false ^
-c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" ^
-f "C:\Users\[your-username]\input.ps"
echo Done.
pause
Figure 3
Figure 3: Arguments for GhostScript
Figure 4
Figure 4: An org-mode file opened in Notepad++

GNU Emacs and ImageMagick
There is a lot of software that can be used as a personal finance manager. Some examples are: GnuCash, HomeBank, KMyMoney and Skrooge. I have tested them on GNU Linux and not on Windows, so I can’t say more about their installation and use on Windows. This kind of program is nice but I’m not satisfied with it.

Another option is to use something like Ledger (http://www.ledger-cli.org), which is available for Windows too. But I prefer to follow a personal method and use org-mode to build some tables. With these tables, I can’t do queries and reports, but I don’t need them. A typical table I use has seven columns:
1. ID, which is a progressive integer
2. Day, which is the date when the operation is done
3. Payee, which is the payee
4. Memo, which is the explanation of that operation
5. R, which is used to show if the operation has been reconciled or not
6. Amount, which is the amount in that operation that can be a positive or a negative number
7. Balance, which is the running total
The first row is the total balance for the previous year. At the end of the table, there are the following three rows:

#+tblfm: $1=@#-1
#+tblfm: @>$6=vsum(@I..@II);%.2f
#+tblfm: $7=vsum(@2$6..@$6);%.2f

The first adds the ID number (column 1), the second calculates the total balance value (the sum of all the values in column 6) and the third calculates the running total (column 7). This is a simple, practical and very fast way to open a file on a text editor and to print as html, when necessary. Figure 4 shows an org-mode file opened in Notepad++ with the free and open source font Hack v2.010 (http://sourcefoundry.org/hack). Regarding ImageMagick – after the installation, to verify if it’s working properly, type each of the following lines at the command prompt:

convert logo: logo.gif
identify logo.gif
imdisplay logo.gif

If the file mfc100u.dll is missing, it’s impossible to run imdisplay. Simply download and install Microsoft Visual C++ 2010 SP1 Redistributable Package. Some useful common operations are summarised in the following code from the command prompt. ImageMagick is very powerful and has many capabilities. More examples can be found at http://www.imagemagick.org/Usage

- Reduce image quality/size
convert -strip -quality 25 big_image.jpg new_image.jpg
- Generate a canvas with a specific size and color
convert -size 1280x800 canvas:”#708090” background.jpg
- Convert from PNG to ICO
convert -define icon:auto-resize=256,128,64,48,32,16 file.png file.ico
- Convert from PDF or EPS to PNG
convert -density 300 -quality 100 -layers flatten file.pdf file.png
- Convert from color to gray scale
convert -colorspace Gray color_image.png gray_image.png
- Modulate Brightness, Saturation, Hue
convert -modulate 100,100,-50 image.png new_image.png
- Resize
mogrify -resize 128x256 image.png

Before the final conclusions, I would like to add some remarks about these three kinds of software: database, CAD and RAD. For a database on a network, I prefer to use MySQL/MariaDB with some PHP (see the OSFY August 2015 issue) and for Drupal websites too. But for a small, desktop only application the story is different. I like well-known commercial software, but find them expensive.The well-known LibreOffice Base is interesting but, in my opinion, it’s not a so good alternative to the above-mentioned commercial software, because it still needs a lot of work before it can be considered a true alternative. The Java engine is slow; Firebird has some stability problems and the GUI is not the best. So, actually for me, this is an open topic.

About CAD, I have no experience about 3D so I would like to list six interesting free alternatives to AutoCAD LT and to VectorWorks (I haven’t used them both for years): DoubleCAD XT, DraftSight, FreeCAD, Medusa, nanoCAD and Solid Edge 2D. Some of these options also have 3D capabilities but only FreeCAD is open source. I’ve tested only Solid Edge (because it’s used in the CAD/CAE course at my college) and DraftSight, and I think that the second, for my simple needs, can be an alternative because it’s available for GNU Linux (note that DraftSight is unsupported on Linux 32-bit machines).

Last, some short notes about NetBeans and Lazarus. As well as in the case of text editors, I can’t make a definitive choice because Java is very widely used and having some knowledge about it has certain advantages, but I also like the Pascal syntax. At this point a big section could be open to talk about the Python programming language on Windows. But this is another story. Finally, can Windows be a good base for free and open source software? I think it can, because on Windows, I can install many other free software (even if not open source) or, if necessary, commercial software that’s not available for GNU Linux. But for the future, I hope that it will be possible to use only GNU Linux.

References
[1] http://mbmcclelland.blogspot.it/2012/11/creating-free-pdf-printer-in-windows-7.html, last visited on 28/08/2015.
[2] http://www.stat.tamu.edu/~henrik/GSWriter/GSWriter.html, last visited on 28/08/2015.

LEAVE A REPLY

Please enter your comment!
Please enter your name here