Nino’s Reminders

April 6, 2006

Enable mouse wheel in XWindows

Filed under: Miscellaneous — nino @ 20:28

How do I make my middle mouse button work in XWindows?

You need to edit your xorg.conf configuration file and add something to the section where mouse is defined. It is usually located in /etc/X11/. Needed changes are:

Section "InputDevice"
  Identifier "Mouse1"
  Driver "mouse"
  Option "Protocol" "auto"
  Option "Device" "/dev/sysmouse"
  Option "Buttons" "5"
  Option "ZAxisMapping" "4 5"

EndSection

The bold parts are the added parts; non-bold parts will most likely already be there.

Find syntax example

Filed under: FreeBSD — nino @ 17:52

How do I find files in a directory and subdirectories and execute a command that takes found file(s) as parameter?

Easiest way is to run find command and then pipe the output to the xargs command:
find [start_dir] -name [file_mask] | xargs -I [repl_symbol] [command]

  • find [start_dir] – start from specified directory (find scans subdirectories as well). You will most often put a dot (meaning current directory) here.
  • -name [file_mask]… search files by name (if you use wildcards, be careful to escape them with a backslash – we want to have find command expand the wildcard, not the shell that is running find)
  • xargs – constructs the arguments list and executes the command
  • -I [repl_symbol]… use something as a replacement placeholder. Using percentage sign (%) seems to work ok.
  • [command]… specify a command you want to run on found files. E.g. cp % destdir will copy found file (if % is used as replacement symbol) to the destination directory.

Example
I used this little trick to find all .ko files located in various subdirectories of the current directory and copy them to a specific directory:
find . -name \*.ko | xargs -I % cp % modules/

Create package from locally installed package

Filed under: FreeBSD — nino @ 14:10

How do I create a ready-to-install package from a machine that already has that package installed?

Change the directory to the directory where you want to place created packages. Best way to create a package from locally installed package is:
pkg_create -v -x -b [pkg_name] -R

  • -v… be verbose and write what you are doing
  • -x… use basic regular expressions to determine the package name
  • -b… means create a package from locally installed package
  • -R… create all packages that are required by the specified package

You will most likely use this function to compile and install a port on a fast machine, then create a binary package and install it on a slower machine where compilation would take hours.
Remember to change the current directory before running the command to the directory where you want the resulting packages to be placed. This command always produces the packages in the current directory.

Example:
I used this command to produce a binary package of dvd+rw-tools built from ports on a fast machine. It produced two packages in the current directory, cdrtools-2.01_4.tgz and dvd+rw-tools-6.0_2.tgz.
pkg_create -v -x -b dvd+rw-tools -R

Blog at WordPress.com.