PuTTY Registry Settings – Export and Synchronize to Dropbox

Run the following command (Start->Run or ctrl + r), assuming your Dropbox is installed at your profile directory (%userprofile%), if not alter it properly:

regedit /e "%userprofile%\Dropbox\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham

With Dropbox installed on the user’s profile directory you just run this command in the most up to date machine and later on you get your entire PuTTY setup when logged in your other hosts.

FreeBSD Software Search and Management

FreeBSD has its Package and Ports software scheme. Both have dependency check and handle the automatic installation(s) when there is (are) any.

First of all, if you want to have a program but you do not have a clue of what is its name, try searching for it in popular FOSS sites such as Freecode (formerly known as freshmeat.net) etc. If you know the name and want to perform a search for it on the system you can do:

# whereis lsof
lsof: /usr/ports/sysutils/lsof

or:

# echo /usr/ports/*/*lsof*
/usr/ports/sysutils/lsof

The latter will also include matches found in /usr/ports/distfiles/.

Generally, the ports directory structure is inside the /usr/ports directory.

You can also use the handy Ports Collection’s built-in search mechanism, by cd‘ing to the /usr/ports directory and executing:

# make search name=program(port)-name

The system search above is for the FreeBSD Ports facility. We will come back to it shortly.

Packages are convenient as they are pre-compiled versions of applications. As such, they have the primary advantage of not imposing the awareness and compilation setup work (as when any tweak is desired), but you have to accept a software that was compiled with a very simple configuration as it must be able to execute smoothly in many platforms. Another advantage (if you considered the latter as such ;)) is that the compressed archive is a lot smaller than the source code archive. You handle packages with simple commands such as pkg_add, pkg_info, pkg_version, pkg_delete etc.

Ports, on the other hand, are a set of files (Makefile, patch files etc.) that make the source code for applications to be ported to (able to compile in and, hence, function correctly in) the FreeBSD realm.

To have compiled software is more secure and you have the control of the application aspects, including the ability to turn features on or off during compilation. The port’s corresponding source code archive (known as the distfile) is larger than a correspondent (pre-compiled) package for the software, though. Nevertheless the many benefits it brings, like security, source code availability, and compiling for the architecture make it the best choice for a handful of people e.g. developers or folks that just appreciate one of the many advantages listed.

So, we will cover a bit of Ports usage. For more information on Package usage in FreeBSD go to its official handbook documentation.

In order to be able to use the Ports facility you must first get the Ports Collection:

# csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

Instead of the value for the -h option above, choose a mirror near you.

The handbook also shows the sequence of menu options needed to install it from the installation media but as it installs the old (as of the release) Ports Collection you should use the internet way as stated above and also on the handbook.

The Ports Collection is comprised of a set of Makefiles, patches and description files, divided up into port skeletons (one skeleton is a port) each of which is a minimal set of files containing instructions on how to build (compile) the source code, but does not include the actual source code.

With an Internet connection already setup, go to the port directory e.g. for lsof:

# cd /usr/ports/sysutils/lsof

and (also as root) execute make, make install, and then, as advised by the handbook, make clean (temporary files used during compilation). To run all of them with only one command you can just run make install clean – this will do all the work for you: download the distfile, uncompress, build and install it and then clean its temporary compilation files.

The following passage from the handbook (section on ports usage) is very important for those that do not have an Internet connection up all the time:

For users which cannot be connected all the time, the make fetch option is provided. Just run this command at the top level directory (/usr/ports) and the required files will be downloaded for you. This command will also work in the lower level categories, for example: /usr/ports/net. Note that if a port depends on libraries or other ports this will not fetch the distfiles of those ports too. Replace fetch with fetch-recursive if you want to fetch all the dependencies of a port too.

Note: You can build all the ports in a category or as a whole by running make in the top level directory, just like the aforementioned make fetch method. This is dangerous, however, as some ports cannot co-exist. In other cases, some ports can install two different files with the same filename.

For more activities on Ports, like changing the Default Ports Directories, Reconfiguring, Upgrading or Removing Installed Ports, consult the handbook section on ports usage.

The Ports Collection will use disk space over time. Always remember to make clean while inside the relevant directory, or simply portsclean -C (in any directory). To remove all the distfiles not referenced by any port, execute portsclean -D, or portsclean -DD to delete the ones not referenced by any port currently installed on your system. portsclean is a part of the portsupgrade suite (also explained by the handbook section on ports usage which makes numerous more tips not present in this article available!).

Welcome to FreeBSD!

Xfce Shortcut for ALSA Sound Attenuation

Xfce is one of the greatest desktop environments ever. It is beautiful, lean, and thus it is also very fast.

One of its great customizable aspects is the assignment of commands for Keyboard Shortcuts (Xfce Menu > Settings > Keyboard > Application Shortcuts).

I immediately found out two nice applications for it: screenshot and sound attenuation. This post gives you the hint on the sound attenuation command when using ALSA (Advanced Linux Sound Architecture).

I usually cycle between 40% of the card’s volume when attenuated and 80% when playing audio normally. So I took the keys F9 and F10, respectively, and assigned them the following ALSA commands, also respectively:

amixer set Master 40%

and

amixer set Master 80%

The “Master” simple mixer control name I knew via listing the simple mixer controls available via the

amixer scontrols

command. Do the same and substitute “Master” in the commands above with whatever value you see in place of the blue value below (“Master”, in this example, matching the “Master” in the above commands):

Simple mixer control 'Master',0
Simple mixer control 'PCM',0
Simple mixer control 'IEC958',0
Simple mixer control 'IEC958 Default PCM',0
Simple mixer control 'Digital',0
Simple mixer control 'Ext Mic',0
Simple mixer control 'ExtMic',0
Simple mixer control 'Int Mic',0
Simple mixer control 'IntMic',0

Enjoy! :)

Dialogs in Xfce 4 with Whiptail and Zenity

I often use the Xfce 4 timer (on Debian it is installed via the xfce4-timer-plugin package and you plug it in a panel by adding it to the panel, via the panel’s context menu) or a similar application in conjunction with some dialog window generator (and trigger) for immediate alerts during daily activities.

We will create 2 scripts that make it easier to assemble a command to display such dialogs. In this case we will tackle on creating simple, informational dialogs only, with whiptail (text) and zenity (graphical). Note that their Debian packages have the same name as the respective commands.

We need a terminal emulator, in this case the Xfce 4 terminal emulator which is available as the xfce4-terminal package on Debian.

Create (as root) with mode 755 the file /usr/bin/zen with the following contents:

#!/usr/bin/env bash
xfce4-terminal -x bash -ic '
clear
echo "MESSAGE DIALOG (TEXT: '"${1}"') OPENED!"
zenity --info --text "'"${1}"'"'

For whiptail (text mode dialog), create (as root) with mode 755 the file /usr/bin/whip with the following contents:

#!/usr/bin/env bash
xfce4-terminal -x bash -ic '
clear
whiptail --nocancel --title message --msgbox "'"${1}"'" 12 64'

Now, to call the text-mode dialog (whiptail), do:

whip 'This is my new message!'

or call the graphical dialog (zenity) like this:

zen 'This is my new message!'

Here is how the zenity version will be displayed:

And here is how the whip version will be displayed:

You can also elaborate on your whiptail and zenity codes as they are very complete, and so you can construct timer or other types of commands and scripts that do much more than these.

Important note: the post title part “in Xfce 4″ is merely related to the example, nothing more. It is not required that you assemble your code for Xfce nor its terminal emulator xfce4-terminal. You can do all of this while on your preferred window manager and for/with your favorite terminal emulator program.

I think these basic examples are very handy already. I am sure you will, too!

Install True Type Fonts on Debian and Ubuntu Linux

Put your .ttf file in one of these directories:

  • “${HOME}”/.fonts
  • /usr/share/fonts/
  • /usr/local/share/fonts/
  • ~root/.fonts/

and optionally execute:

sudo fc-cache -f -v

Update (Thanks to Arthur Furlan):

This updates the font cache. But there is no need to execute it, your fonts will be made accessible once you just place them in the right directory.

Cool font website: dafont.com

Enjoy!

Linux Look-and-feel on Windows with Cygwin

Want to have GNU/Linux utilities at hand on a Windows box? Suffer no more. Cygwin brings you that along with its several packages (GNU etc.) bringing recompiled versions of these for Windows.

Just to name a few out-of-the-box packages:

  • Interpreters: bash 4.x, ksh, zsh etc.
  • Servers: Apache web server, PostgreSQL, sqlite3
  • Scripting languages: Perl, Python, Ruby etc.
  • Utilities: cron, md5deep etc.
  • Version control: bzr (bazaar), git, subversion etc.

Remember: this is just to name a few! There are a myriad of packages for you to choose from.

Having bash 4 available is priceless. Do your normal shell scripting tranquile in Windows!

Also, one of the main attractions in terms of usefulness that Cygwin brings us is the mintty terminal emulator (intended for use with Cygwin on Windows). It has several awesome features like:

  • It is fast!
  • Making the user able to customize the colors, font and cursor type.
  • Control the behavior for the backspace key (^H etc.).
  • Command line options to hold execution (-h option) after execution of any command (-c command, as stated in mintty tips on google code), and also controlling the initial state of the window for when you create a shortcut for it (option -w max makes it start maximized).
  • Handling the copying with left mouse button selection well and preventing bad situations regarding line wrapping while doing so. ctrl + insert and shift + insert for copy and paste (respectively) are accepted as well.
  • Scroll with shift + {arrow|pgdn|pgup} .
  • Toggle on / off many of the program’s functions.
  • Window transparency.

Comparing mintty to the default terminal emulator in cygwin one can conclude that the former is a very significant improvement. For more, check this great article on mintty and also this one at howtogeek.com (more complete).

Try cygwin if you still had not and let us know of your explorations! Happy scripting!

MuPDF The PDF Reader for VIM Fans

mupdf official siteMuPDF is a very great pdf visualization tool. Check it out on its main site at http://www.mupdf.com/ . Let’s look at its key advantages:

  • Lean – it only shows you the document.
  • Fast (very!).
  • Its commands almost completely resemble those of less, vi, and vim‘s!
  • Linux and Windows.

I.e., the perfect choice for any situation. Get yours now at http://code.google.com/p/mupdf/downloads/list

The vi / vim command similarity comprises the best feature. The manual is as short as this:

The main viewer application is mupdf. Left click to pan, right click to select and copy text. Hold down shift when scrolling to zoom. Your navigation history is saved when following links, use ‘T’ to go back.
L, R rotate page
h, j, k, l scroll page
+, - zoom in or out
w shrinkwrap
r reload file
. pgdn right space next page
, pgup left b previous page
<, > skip back/forth 10 pages
m mark page for snap back
t pop back to latest mark
1m mark page in register 1
1t go to page in register 1
123g go to page 123
/ search for text
n, N find next/previous search result
c toggle between color and grayscale
pdfdraw
Rendering tool to convert a PDF file to a series of image files.
pdfclean
Tool to rewrite PDF files. Can be used to repair, decrypt, and decompress PDF files.
pdfshow, pdfextract, pdfinfo
Debugging tools to show internal objects, extract fonts and images, and display information about resources in a PDF file.

Enjoy! :)

Xfce Thunar Explorer Custom Actions

This post is intended for you fellow users of Xfce, a window manager and suite of applications.

The Thunar file browser is a very interesting of these applications:

  • It is extremely lightweight.
  • It has a pleasant interface.

The one awesome feature we discuss here is about incrementing your configuration with custom actions for files and directories that are made accessible via their context menu.

  • Open Thunar.
  • Go to Edit -> Configure custom actions…
  • Click on the “+” button on the right hand side of the dialog window (see the figure below).
  • Now give in the name, description and choose the icon for your action.

Now for the 3rd field, “Command” here is the very nice and handy part:

Insert a command of yours to do something. In my case, I want to rename files so that they do not have special characters. I will do this by invoking the xfce4-terminal (obviously, also from the Xfce suite of applications) which in turn invokes bash with its -c option (which receives an argument string comprised of commands to be evaluated i.e. executed).

Here ‘s the code:

xfce4-terminal -x bash -c '/path_to_script/renameok.sh %f'

The script renameok.sh iterates through directories renaming their files stripping special characters. Soon a post will be included containing its source code and explanation.

If your script (generally referred to as script.sh instead of the specific renameok.sh) depends on stuff setup in .bashrc (the shell resource file) then just call bash with -i (bash -ic “command(s)”) which sets the interactive mode on and calls the resource file before executing the -c option commands. Also realize that when in an interactive session, if script.sh is in a PATH setup by .bashrc you are safe to remove the /path_to_script/ part of script.sh ‘s call as it will be thus found. And last, as my .bashrc can have some echo commands in it, I will deliberately add a clear command before the script call so that the resulting code will look like:

xfce4-terminal -x bash -ic 'clear; renameok.sh %f'

Now, in the Appearance Conditions tab uncheck every options but Directories as in this example we use the directory in which the context menu was invoked as the script ‘s argument (as it wants a directory path). This indeed causes the action to be available only for directories’ context menus in Thunar. The main purpose in this tab is for you to choose which type(s) of files (directories are a type of file) you want the action to be executable.

In the custom action entry edition dialog, still, notice the bottom of the window, which explains the meanings of the expansions including the %f shown in the examples herein. One interesting and awesome thing is that Thunar is also smart enough to realize that the actions must not be made available if more than one file (or directory, as in these examples) are selected in case you are using %f. Conversely, the action is selectable both for just one file or for multiple files when using %F instead.

To know more check the official wiki entry.

Enjoy! ;)