jump to navigation

Printer / scanner July 21, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , , , ,
1 comment so far

This post is part of the series FreeBSD on my laptop

I have a HP LaserJet 1020 which is shared from my linux workstation (CUPS). To use the printer from my FreeBSD laptop I have to add the driver, which is found in print/foo2zjs. CUPS has to be enabled in /etc/rc.conf with the line
cupsd_enable="YES"

After a reboot (or just a start of CUPS) the printer can be configured using the cups web interface at localhost:631

I have not tried this yet but by following the pkg-message you can supposedly set up the printer directly on the FreeBSD machine by downloading the firmware with the ‘getweb’ utility.

I also have a HP PSC 1300 printer/scanner. One should be able to install this using the guide in [1]

Resources:
[1] HP Linux Imaging & Printing on FreeBSD HowTo

[2] CUPS (freebsdwiki)

Encrypted container in mountable file on FreeBSD July 17, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , , ,
1 comment so far

This post is part of the series FreeBSD on my laptop

The disk encruption chapter in the handbook [1] is not fully applicable as it only talks about encrypting real partitions. However a file can be attached as a device using mdconfig(8).

First a file of a proper size has to be made. Here the file is 1024 MB. dd(1) is used for the job:
dd if=/dev/zero of=/path/to/safe.img bs=1m count=1024

where /path/to/safe.img is the full path to the encrypted container.

Now the file is attached as a memory device using mdconfig:
mdconfig -f /path/to/safe.img

mdconfig will then output the devicename e.g. “md0″.

From here on the instructions in [1] can be followed with /dev/md0 as the device. (In the following the geli method is used)

Initialize the encryption
geli init /dev/md0

Attach it and create a filesystem and detach again
geli attach /dev/md0
newfs /dev/md0.eli
geli detach /dev/md0

Note that the decrypted device is at /dev/md0.eli!

Now the encrypted container is created.

When needing it mount it with:
mdconfig -f /path/to/file
geli attach /dev/md0
mount /dev/md0.eli /mnt/safe

Unmount it after use with
umount /mnt/safe
geli detach /dev/md0
mdconfig -d -u 0

Note that you are not necessarily given the device md0 but the first free one. Please take that into consideration.

Resources:
[1] Encrypting Disk Partitions

FreeBSD: Networking. LAN and Wireless. July 5, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , , ,
1 comment so far

This post is part of the series “FreeBSD on my laptop”

LAN pretty much just works. In rc.conf I have the lines:

hostname="fynkyhostnamegoeshere.domainname"
ifconfig_bge0="DHCP NOAUTO"
ifconfig_wpi0="WPA DHCP NOAUTO"

The first one just sets my hostname (obviously).

The second says that my ethernet connection should use DHCP and not connect automatically. This is done because otherwise it tries to connect at boot until timeout — adding 30 s to boot when no cable is plugged. (In 8.0 NOAUTO is deprecated, maybe a better solution is found. Maybe startup in background)

The last line is for wireless. Same story with DHCP NOAUTO. WPA tells it to use WPA, or actually just wpa-supplicant… This is configured in /etc/wpa_supplicant.conf as follows:

network={
ssid="MyEssid"
psk="LongPasswordGoesHere"
priority=1000
}

This is for my home network using wpa with a pre shared key (psk). The priority is set to 1000 as my home network has the highest priority. (all other networks are added with priority < 1000).

For the wireless to work, I also had to load the wpi driver in /etc/loader.conf, as well as accept the licence:

if_wpi_load="YES"
wpifw_load="YES"
legal.intel_wpi.license_ack=1

An interface (wpi0 in the example) is brought up with the command

/etc/rc.d/netif start wpi0

(as root)

I have also configured a pptp vpn to my work. A description of this can be found here.

pptp vpn from FreeBSD July 5, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , , , , , , ,
2 comments

I need to connect to work using pptp vpn from my FreeBSD laptop. This can be done using mpd (version 5, in net/mpd5). I just created the sections startup: and default: and copied pptp_client from /usr/local/etc/mpd5/mpd.conf, all into /usr/local/etc/mpd5/mpd.conf. As the server at work is MS i also merged the MPPE lines from pptp_vpn. The final result is the following:


startup:

default:
load pptp_client

pptp_client:
#
# PPTP client: only outgoing calls, auto reconnect,
# ipcp-negotiated address, one-sided authentication,
# default route points on ISP's end
#

create bundle static B1
set iface route 1.2.3.146/28
set ipcp ranges 0.0.0.0/0 0.0.0.0/0
set bundle enable compression
set ccp yes mppc
set mppc yes e40
set mppc yes e128
set bundle enable crypt-reqd
set mppc yes stateless

create link static L1 pptp
set link action bundle B1
set auth authname ********
set auth password *****'**
set link max-redial 0
set link mtu 1460
set link keep-alive 20 75
set pptp peer 1.2.3.4
set pptp disable windowing
open

One thing to note is that I do not use “set iface route default” as in the sample conf file. This is because the work lan and wan has the same ip-range even tough some addresses are only on the lan and others are only on the internet. If the lan part of the network had a more traditional layout (as 192.168.1.*) the default should work…

Sound and multimedia keys on FreeBSD May 26, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , ,
1 comment so far

This post is part of the series: FreeBSD on my laptop

This on is pretty easy. Basically I just had to load the driver. This is done permanently by adding:

snd_hda_load="YES"

to /boot/loader.conf.

In kde the phonon framework locks the sound channel. Thus I enable 4 channels in total, so I can also get sound from non-kde apps like firefox/flash and virtualbox. This is done with the following lines in /etc/sysctl.conf
dev.pcm.0.play.vchans=4
dev.pcm.0.rec.vchans=4

To enable the multimedia keys (mute, volume up, volume down) I had to define the correct mapping for X. This is done with the following commands:

xmodmap -e 'keycode 140 = XF86AudioMute'
xmodmap -e 'keycode 176 = XF86AudioRaiseVolume'
xmodmap -e 'keycode 174 = XF86AudioLowerVolume'

I added this to a (executable) script in ~/.kde4/Autostart. Another possiblity is to add it to .xprofile or something. The actual keycodes have been found using xev: just open it in a terminal and start pressing keys. It will then tell you the keycodes.

Resources:
The FreeBSD Handbook, 7.2 Setting Up the Sound Card

Usable tcsh May 19, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , , ,
1 comment so far

This post is part of the series: FreeBSD on my laptop

In this post I will try to document how I set up tcsh to my liking by modifieng .tcshrc. I have left out a lot of stuff, like how I have set my EDITOR variable and stuff, but you can find the .tcshrc file attached (not possible to attach text files)

First I alias grep and ls, to get some nice colors:

alias grep grep --color=auto
alias ls ls-F

Now comes the setup of the shell itself.

set addsuffix
set autolist
set cdpath = $HOME
set color
set nobeep
set rmstar
set history = 250
set histfile = "$HOME/.history"
set savehist = ( 125 merge )
set prompt = '%{33[1;33m%}[%T]%{33[0m%} %{33[32m%}%n%{33[0m%}@%{33[31m%}%m%{33[0m%} %{33[36m%}%c%{33[0m%} %# '
source /usr/share/examples/tcsh/complete.tcsh

bindkey "^[[3~" delete-char
bindkey -k up history-search-backward
bindkey -k down history-search-forward

addsuffix adds a ‘/’ when autocompleting directory names and autolist prints out all possibilities when there is more than one available.
cdpath allows one to type e.g. ‘cd Desktop’ from everywhere! You don’t have to be in $HOME/.
color adds color support to ls using the alias above.
nobeep disables the annoying beeping sound when doing something that would do that.
rmstar guards against ‘rm *’ and will prompt the user for confirmation.
the hist lines is just for saving the history
prompt gives a nice colour prompt showing a timestamp, username and hostname.
source ../complete.tcsh enables autocompletion of a lot of nice stuff.

the bindkeys just modifies some keybindings. The up and down keys now searches through the history so if you press e.g. scp it scroll back your last commands starting with scp!! really nice (just like in Matlab).

This is it for now, maybe more will be added.

Note that since my terminal emulator, konsole, cannot find the program names under FreeBSD with tchs (haven’t investigated further) I had to make make it set the tab title form the “Window title set by Shell”.

FreeBSD on my laptop May 19, 2009

Posted by tkjacobsen in FreeBSD.
Tags: , ,
5 comments

I am currently trying to get FreeBSD up and running on my HP nc4400 laptop. Up until now it’s going pretty well, but there is lots of small tips and tricks to remember. Therefore I’m writing a series of posts do document the steps I’ve taken. This is as much for my self to remember as it is for everyone to use.

Here’s a preliminary list of things to take care of:

Note that there is no bullet point for Xorg. This is because the newest Xorg configures itself with no xorg.conf. Only settings for e.g. the touch pad should be done manually.

Remember that FreeBSD is wonderfully documented in the handbook and in the man pages. Most of the information for these posts I got from these.

Other useful resources:

More on arrows in matplotlib February 26, 2009

Posted by tkjacobsen in matplotlib.
Tags: , ,
2 comments

There still doesn’t seem to be an easy way to do this, but at least there is a way now. With the introduction of matplotlib.patches.FancyArrowPatch it is now possible to draw a decent arrow like this:

from matplotlib.patches import FancyArrowPatch
ax=gca()
ax.add_patch(FancyArrowPatch((9,0),(9,0.5),arrowstyle='->',mutation_scale=30))

HP LaserJet 1020 on Fedora 10 December 15, 2008

Posted by tkjacobsen in linux.
Tags: , , , ,
2 comments

I have always struggled to get my HP LaserJet 1020 printer to work under linux. Furtunately this is always possible by manually installing the foo2zjs printerdriver and the firmware manually. However, I think this is a horrible solution, as I don’t like manually installed software (usually I make myself a rpm).

Today I then found the Right Solution(tm) (it has probably been there all the time): The hplip package provides a small HP setup utility named hp-setup, which will install the printerdrivers for you. (And set up the printer, but we really don’t want this, because Fedora does this on the fly, when the driver is there — I just removed the entry again). Afterwards I had to restart the printer to load the new firmware. It instantly popped up in Fedora and I were able to print. Tada.

So in other words:

yum install hplip hplip-gui
hp-setup

(You don’t really need the -gui part, only if you don’t like the cli)

Update:
I had some problems with this on Fedora 11. It seems that the correct .ppd file for the printer is not installed. However, it can be found in the package foo2zjs:
yum install foo2zjs

After installing this I got the printer working.
Maybe you have to select the .ppd manually during the hp-setup step. This is found here:
/usr/share/cups/model/HP-LaserJet_1020.ppd.gz

References:

http://hplipopensource.com/hplip-web/models/laserjet/hp_laserjet_1020.html

Configuring Xorg via HAL December 4, 2008

Posted by tkjacobsen in linux.
Tags: ,
1 comment so far

Back in the days you had to configure Xorg using xorg.conf. This had the drawback that it was very static and you had to restart Xorg when plugging new peripherals.

With the new xserver you can use HAL to do the job. In my case I just wanted to add two options to my synaptics touchpad driver. First I had to copy the .fdi file for the driver provided by my distribution (Fedora 10) to /etc/hal/fdi/policy. The original file is found here: /usr/share/hal/fdi/policy/20thirdparty/10-synaptics.fdi.

I edited it to look like the this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.touchpad">
<match key="info.product" contains="Synaptics TouchPad">
<merge key="input.x11_driver" type="string">synaptics</merge>
<merge key="input.x11_options.MaxTapTime" type="string">0</merge>
<merge key="input.x11_options.HorizEdgeScroll" type="string">off</merge>
</match>
<match key="info.product" contains="AlpsPS/2 ALPS">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
<match key="info.product" contains="appletouch">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
<match key="info.product" contains="bcm5974">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
</match>
</device>
</deviceinfo>

The changes from the original is just these two lines:

<merge key="input.x11_options.MaxTapTime" type="string">0</merge>
<merge key="input.x11_options.HorizEdgeScroll" type="string">off</merge>

This means that I set the MaxTapTime to 0 and HorizEdgeScroll to off. In an old xorg.conf it would look something like

Section "InputDevice"
Identifier "Touchpad"
Driver "synaptics"
Option "Protocol" "auto"
Option "Device" "/dev/input/mouse0"
Option "MaxTapTime" "0"
Option "HorizEdgeScroll" "off"
EndSection

Now I have both the wanted configuration and hotplugging.

Follow

Get every new post delivered to your Inbox.