Thursday, November 25, 2010

OpenBSD NC4200: Ctrl + Alt + Del to lock wmii using xscreensaver.

1 thing I like about XFCE is that if I hit [Ctrl]+[Alt]+[Del], XFCE will lock my session using xlock or xscreensaver. By default, wmii can't do that. I've been searching for samples to do that but most samples that I've encountered are either using Ruby or Python. So I tried to just edit the ~/.wmii-3.5/wmiirc. After a few testing and frustrating hanging of wmii, I managed to get the key binding working by inserting this line:

# Key Bindings
   *default lines skipped*
   Key $MODKEY-Shift-$UP
      wmiir xwrite /tag/sel/ctl send sel up
   Key Mod1-Control-Delete
      /usr/local/bin/xscreensaver-command -activate

!
   for i in 0 1 2 3 4 5 6 7 8 9; do
   *default lines skipped*


The bolded lines are the addition to make the key sequence work. So after reloading the config, pressing Ctrl+Alt+Del locks my session using xscreensaver. Great. I read that new version of wmii changed the wmiirc configuration so FYI, this configuration is using wmii 3.6. Later then.

Wednesday, November 24, 2010

OpenBSD NC4200: Getting Alpine to work with DavMail.

Firstly, yeah I changed the blog's title. As I'm using ONLY OpenBSD nowadays, I think it's appropriate to change the title as I don't use other type of BSD. Now back to the main story.

So far, this is a brief description of what I (initially) wanted to achieve:

Alpine+LDAP <---> DavMail <---> CompanyEmail@OWA/Exchange

So here's what I'm currently doing. Getting Alpine + DavMail to play nicely together. I have posted earlier that I compiled my Alpine with LDAP support so I can check my company's email address book. Here's the current status of the project:

DavMail <---> CompanyEmail@OWA: Working fine
Thunderbird <---> DavMail: Working fine

As DavMail is working, I can just focus on configuring Alpine. The first time I start Alpine (by typing Alpine in xterm), the program will create ~/.pinerc configuration file. I don't need to blow my head to configure Alpine as it has a great built-in configuration tool.

Chapter 1: Receiving emails.
Inside Alpine's Main menu [M], I just key [S] (Setup), [L] (collectionLists). Then inside Alpine's Setup Collection List page, I hit [A] (Add collection). Here's my configurations:

Nickname: MyCompany
Server: localhost:1143/user=ASIA\karl
Path:
View:


After I save & exit the configuration [Ctrl+X], Alpine requested for my email's password. I keyed in my password and Alpine ask for confirmation to exit the page. No error messages, so it's all good. Now to test it.

I go to Main [M], then hit [L] (Folder List). I can see 2 folders:

MAIL
   Local folders in mail/

MyCompany
   Folders on localhost:1143/user=ASIA\karl in home directory


I choose MyCompany and using the Right Arrow [>] key, Alpine opened up my company email. I can see all the folders I have there and I can read my emails. So far so good.

Chapter 2: Sending emails (Working now!).
I'm still configuring this part as it's not working. I'll just put the steps for revising purpose. If you have a working solution, do comment.

Thanks to Christopher for commenting and posting a usefull link. Surely, I managed to tweak Alpine's setting and managed to get the SMTP portion working for sending emails. Do take note that I'm already running a new version of DavMail so it'll be better for you guys to update too.

Inside Alpine's Main menu, I choose [S] (Setup) and [C] (Config). The mandatory line to be update is this:

SMTP Server (for sending) = localhost:1025/user=ASIA\karl

So here, I don't need to use user=ASIA\\karl because the single \ is not escaped.
As I stated, it's currently not working. I kept getting "Error sending" message if I want to send out email. Previously I tried user=ASIA\karl but the "\" got escaped in ~/.pinerc and I still can't send email.

If I can't sort this out, I might have to go with using Sendmail instead of going thru DavMail. I will post any updates on this. I've also added this line in the same Config's screen:

Inbox Path = {localhost:1143/user=ASIA\karl}inbox

Note that this setting depends on whether you need it or not. As I use Alpine only for 1 OWA account, I set this up. Now press [E] to exit and save the setting. Press [Q] to quit Alpine.

Now vim your .pinerc file, normally in your home folder (~/.pinerc) and change this line:

disable-these-authenticators=GSSAPI,PLAIN

Save the .pinerc file and open Alpine back. I composed [C] an email and wallah! Alpine asked for my OWA password and email is sent! Great!. Again, thanks Christopher!

Chapter 3: Using LDAP.
As I've compiled my Alpine with LDAP support, I can use it to search my company's email address book. Inside Alpine's Main menu, I choose [S] (Setup) and [D] (Directory). Inside Alpine's Setup Directory Servers page, I hit [A] (Add dir) and this is my settings:

ldap-server= localhost
search-base= ou=people
port= 1389
bind-dn= ASIA\karl
nickname= MyCompany


Then I hit [E] (Exit Setup) and [Y] to save changes. [E] to exit the Setup Directory Servers page.

To test out, inside Alpine's Main menu, I hit [A] (Address Book) and select MyCompany. I hit the Right Arrow [>] key and type a name to search. Alpine then requested for my password and after a while, list of matches appears. So this part is working too.

Chapter 4: Offline email reading.
Yes, there's no offline reading for Alpine using IMAP. So now I know. That's one of the most important feature I wanted to use. After searching for solutions, I found the most suitable option. This is the latest description of the (possible) solution:

Alpine+LDAP <---> UW-IMAPD <---> OfflineIMAP <---> DavMail <---> CompanyEmail@OWA

So, instead of getting Alpine to directly access DavMail, Now I need to set up UW-IMAPD and OfflineIMAP. UW-IMAPD is built as dependency for Alpine+LDAP. UW-IMAPD is a local IMAP server and OfflineIMAP is like what the name means, reading emails from IMAP server in offline mode. Now OfflineIMAP will retrieve emails from my company's exchange thru DavMail (OfflineIMAP can't directly retrieve exchange emails), then OfflineIMAP will sync the emails to my local IMAP server which is UW-IMAPD so I will have a local offline copy of my emails that I can use with Alpine. Here's the checklist of needed softwares:

- Alpine+ldap
- UW-IMAPD
- DavMail
- OfflineIMAP

Update 13/04/11: Thanks to Christopher's comment, I got my email sending working! Thank you very much! You guys should read his comment and go to the link posted. I've update this post to reflect the changes. Later then.

Monday, November 22, 2010

OpenBSD NC4200: xterm-color + mp3blaster, no go.

I've been having an issue with mp3blaster recently. Every time I open mp3blaster, I can't use F1 to open folder. In fact, I can't use F1 to F5. F6 (repeat) and F7 (shuffle) works ok. I suspected that my ~/.Xdefaults is the culprit and after testing, it is true. This is my ~/.Xdefaults:

!! Xterm Resources
XTerm*loginShell: true
XTerm*termName: xterm-color
XTerm*faceName: Mono
XTerm*faceSize: 9
XTerm*internalBorder: 10
XTerm*highlightSelection: true
XTerm*cursorBlink: true
XTerm*utf8: 1


The culprit is bolded. So I had to change it to disable it by putting ! in front of it. After saving the file, I closed and open an Xterm, start mp3blaster and it can play my audio files fine now.

As for XTerm*faceName: Mono, you should try it if you haven't. The fonts in xterm is much much prettier and nice with it. Just the way I like it.

Before that, I found that my mp3blaster can't find any mixer device and just put Null0.0 in the mixer's panel. After reading OpenBSD's How do I set up an audio server? section, I edited my /etc/rc.conf.local and put:

aucat_flags=""

Then after next reboot, mp3blaster can happily use a mixer device. Later.

OpenBSD 4.8 @ Compaq NC4200 Laptop: dmesg

OpenBSD 4.8 (GENERIC) #136: Mon Aug 16 09:06:23 MDT 2010
deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) M processor 2.13GHz ("GenuineIntel" 686-class) 2.13 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
real mem = 1064726528 (1015MB)
avail mem = 1037348864 (989MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 10/30/07, BIOS32 rev. 0 @ 0xf0000, SMBIOS rev. 2.3 @ 0xf310a (23 entries)
bios0: vendor Hewlett-Packard version "68DTH Ver. F.0F" date 10/30/2007
bios0: Hewlett-Packard HP Compaq nc4200 (EP948EC#UUF)
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG SSDT
acpi0: wakeup devices C067(S5) C0BA(S3) C0C1(S3) C0C2(S3) C0C4(S3) C0CB(S5) C1E1(S5) C0DB(S5) C1E4(S5) C1FD(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfec01000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 133MHz
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 1
acpiprt0 at acpi0: bus 2 (C067)
acpiprt1 at acpi0: bus 16 (C0CB)
acpiprt2 at acpi0: bus 32 (C0DB)
acpiprt3 at acpi0: bus 0 (C002)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpipwrres0 at acpi0: C1A5
acpipwrres1 at acpi0: C1AD
acpipwrres2 at acpi0: C1B4
acpipwrres3 at acpi0: C1D9
acpipwrres4 at acpi0: C262
acpipwrres5 at acpi0: C263
acpipwrres6 at acpi0: C264
acpipwrres7 at acpi0: C265
acpitz0 at acpi0: critical temperature 100 degC
acpitz1 at acpi0: critical temperature 101 degC
acpitz2 at acpi0: critical temperature 100 degC
acpitz3 at acpi0: critical temperature 110 degC
acpibat0 at acpi0: C173 model "Primary" serial 00794 2009/01/07 type LIon oem "Hewlett-Packard"
acpibat1 at acpi0: C172 not present
acpiac0 at acpi0: AC unit online
acpibtn0 at acpi0: C1FD
acpibtn1 at acpi0: C1FE
acpivideo0 at acpi0: C054
acpivout0 at acpivideo0: C102
acpivout1 at acpivideo0: C103
acpivout2 at acpivideo0: C104
acpivout3 at acpivideo0: C105
bios0: ROM list: 0xc0000/0x10000!
cpu0: Enhanced SpeedStep 2129 MHz: speeds: 2133, 1867, 1600, 1333, 1067, 800 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82915GM Host" rev 0x03
vga1 at pci0 dev 2 function 0 "Intel 82915GM Video" rev 0x03
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
intagp0 at vga1
agp0 at intagp0: aperture at 0xc0000000, size 0x10000000
inteldrm0 at vga1: apic 1 int 16 (irq 11)
drm0 at inteldrm0
"Intel 82915GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
ppb0 at pci0 dev 28 function 0 "Intel 82801FB PCIE" rev 0x03: apic 1 int 16 (irq 11)
pci1 at ppb0 bus 16
bge0 at pci1 dev 0 function 0 "Broadcom BCM5751M" rev 0x11, BCM5750 B1 (0x4101): apic 1 int 16 (irq 11), address 00:0f:b0:f7:3c:40
brgphy0 at bge0 phy 1: BCM5750 10/100/1000baseT PHY, rev. 0
ppb1 at pci0 dev 28 function 1 "Intel 82801FB PCIE" rev 0x03: apic 1 int 17 (irq 10)
pci2 at ppb1 bus 32
uhci0 at pci0 dev 29 function 0 "Intel 82801FB USB" rev 0x03: apic 1 int 19 (irq 10)
uhci1 at pci0 dev 29 function 1 "Intel 82801FB USB" rev 0x03: apic 1 int 17 (irq 10)
uhci2 at pci0 dev 29 function 2 "Intel 82801FB USB" rev 0x03: apic 1 int 18 (irq 10)
ehci0 at pci0 dev 29 function 7 "Intel 82801FB USB" rev 0x03: apic 1 int 19 (irq 10)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb2 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0xd3
pci3 at ppb2 bus 2
iwi0 at pci3 dev 4 function 0 "Intel PRO/Wireless 2200BG" rev 0x05: apic 1 int 21 (irq 11), address 00:16:6f:3d:13:52
cbb0 at pci3 dev 6 function 0 "TI PCI7XX1 CardBus" rev 0x00: apic 1 int 18 (irq 10)
"TI PCI7XX1 Flash" rev 0x00 at pci3 dev 6 function 3 not configured
sdhc0 at pci3 dev 6 function 4 "TI PCI7XX1 Secure Data" rev 0x00: apic 1 int 20 (irq 10)
sdmmc0 at sdhc0
sdmmc1 at sdhc0
sdmmc2 at sdhc0
"TI PCI7XX1 Smart Card" rev 0x00 at pci3 dev 6 function 5 not configured
cardslot0 at cbb0 slot 0 flags 0
cardbus0 at cardslot0: bus 3 device 0 cacheline 0x10, lattimer 0x20
pcmcia0 at cardslot0
auich0 at pci0 dev 30 function 2 "Intel 82801FB AC97" rev 0x03: apic 1 int 17 (irq 10), ICH6 AC97
ac97: codec id 0x41445374 (Analog Devices AD1981B)
ac97: codec features headphone, 20 bit DAC, No 3D Stereo
audio0 at auich0
"Intel 82801FB Modem" rev 0x03 at pci0 dev 30 function 3 not configured
ichpcib0 at pci0 dev 31 function 0 "Intel 82801FBM LPC" rev 0x03: PM disabled
pciide0 at pci0 dev 31 function 1 "Intel 82801FB IDE" rev 0x03: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility
wd0 at pciide0 channel 0 drive 0:
wd0: 16-sector PIO, LBA48, 76319MB, 156301488 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
pciide0: channel 1 ignored (disabled)
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pmsi0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pmsi0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
mtrr: Pentium Pro MTRR support
"PSCR, SLB REFLEX 20, V1.1, " at pcmcia0 function 0 not configured
uhidev0 at uhub1 port 2 configuration 1 interface 0 "Logitech USB-PS/2 Optical Mouse" rev 2.00/20.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse1 at ums0 mux 0
softraid0 at root
root on wd0a swap on wd0b dump on wd0b

Tuesday, November 16, 2010

OpenBSD NC4200: Alpine + DavMail: DavMail configurations.

A bit of personal history. Bear with me as it might get you bored to death as it will be a long one. Ok, my company uses MS Exchange for emails. And, wait, I guess that just sums it up. Company uses MS Exchange, bla bla, I don't want to use Outlook, bla bla, I don't want to use MS Windows, bla bla so here I am. Basically, I just want to use Alpine / Thunderbird to access my company's exchange so I can receive and send emails. Bit of details about my profile and the company's email (this won't be a real one, just to show you how I done it):

Email: karl.bsd@company.com
Username: ASIA\karl
OWA Exchange: https://owa.company.com/exchange/

As you can see, the Username for me to log in to the OWA is different than my email add. To make things a bit more complicated, my internet access is through a http proxy which I will name as http://my.proxy.com at port 8080. Ok enough history class, now on to the good stuff.

For DavMail, it comes zipped with quite some files inside. From DavMail's website, I choose Workstation (personal) mode > Other DavMail release. What contains inside mine is:

lib (folder with lots of *.jar files)
davmail.jar
davmail.sh


I created ~/davmail/ folder and extracted the archive inside it. In basic, I can just use:

$ sh ~/davmail/davmail.sh &

And the familiar DavMail icon will appear in XFCE's taskbar. But that's for XFCE. As wmii's status bar is not a task bar, DavMail will not have the icon. In XFCE, right clicking the DavMail icon and choosing settings, I just put my OWA address in the DavMail url. Then I choose to set the proxy server with the 8080 port. I left all the other setting to default.

XFCE + Thunderbird + DavMail:
This part is quite easy. There's numerous documentations / HOWTOs on this. Even the official DavMail website have tutorial on setting up Thunderbird to work with DavMail. I just follow the documentation and it's working ok. I can send receive emails, do LDAP queries and even sync with the company's calendar using Thunderbird+Lightning+CalDav. Just remember to install lightning using packages as there will be none available in Thunderbird's AddOn website for OpenBSD. As I've stated earlier, sh ~/davmail/davmail.sh & is enough to get you started with DavMail in XFCE.

wmii + Alpine + DavMail:
Now this is THE thing. wmii and normal DavMail don't quite play nicely. By saying "normal" I mean using the command I stated above. There's no taskbar for DavMail to icon-er-ify(?) to. The solution? A quick google and I found something about DavMail configuration file. Shamelessly following the said information, I created davmail.properties file inside ~/davmail/ folder. Here's my davmail.properties file, important bits are bolded for your pleasure:

davmail.url=https://owa.company.com/exchange/
davmail.popPort=1110
davmail.imapPort=1143
davmail.smtpPort=1025
davmail.caldavPort=1080
davmail.ldapPort=1389
davmail.keepDelay=30
davmail.sentKeepDelay=90
davmail.imapIdleDelay=
davmail.useSystemProxies=false
davmail.enableProxy=true
davmail.proxyHost=my.proxy.com
davmail.proxyPort=8080

davmail.proxyUser=
davmail.proxyPassword=
davmail.ssl.keystoreType=JKS
davmail.ssl.keyPass=
davmail.ssl.keystorePass=
davmail.server=true
davmail.server.certificate.hash=
davmail.bindAddress=
davmail.allowRemote=true
davmail.disableUpdateCheck=false
log4j.rootLogger=WARN
log4j.logger.davmail=DEBUG
log4j.logger.org.apache.commons.httpclient=WARN
log4j.logger.httpclient.wire=WARN
davmail.logFilePath=/var/log/davmail.log


For davmail.proxyHost=, previously I was tearing my hairs apart because normal DavMail is working fine but not so when I use the davmail.properties file. When I tried using my.proxy.com instead of http://my.proxy.com, wallah! The earth smiles back at me. davmail.useSystemProxies= is "false" and davmail.enableProxy= is "true" so that instead of using the (currently malfunctioned) System Proxy, DavMail will use the proxy address I specified. Then I need to set the davmail.server= to "true" so that DavMail will not show any icon / GUI and be in daemon mode. I also need to chmod the /var/log/ folder so that DavMail can properly write logs inside there. After all is done, I do testing with:

$ sudo sh ~/davmail/davmail.sh ~/davmail/davmail.properties &

I opened up Thunderbird and all is good. Now to get DavMail started everytime I log in wmii. I mentioned earlier that I use SLiM login manager to replace xdm. SliM can let me choose what window manager / desktop environment I want to log in and that's something xdm currently don't have. I posted my ~/.xinitrc script earlier and this is the changes I need to make to get DavMail started after my login:

# This is for SLiM

case $1 in
wmii)
 xscreensaver &
 nohup sh ~/davmail/davmail.sh ~/davmail/davmail.properties &
 eval `cat ~/.fehbg`
 exec wmii
 ;;


You can follow the rest of the script by searching my previous post. As for the nohup, man nohup will give you great explaination. I log out from wmii and re-login. Open up Thunderbird and it's working alright. Eh, wait.. Thunderbird?! Where's the Alpine's stuff?! Whoa hold yer horses mate. That part will need another post.

Coming up next. Getting Alpine to work with DavMail. Or almost.

OpenBSD NC4200: Alpine + DavMail, ftp_proxy / http_proxy problem again.

Here's the latest update for my Alpine + DavMail project. Installing Alpine via OpenBSD's package doesn't come with LDAP support enabled. I can verify that by using:

$ alpine -supported

So, I read the OpenBSD ports system man pages and Alpine ports man pages and found that I need to specify the ldap flavor when building the Alpine ports. So in /usr/ports/mail/alpine directory, I use this syntax to build Alpine port with ldap built-in.

$ sudo env FLAVOR="ldap" make install
$ sudo env FLAVOR="ldap" make clean


That's when I found out that my ftp_proxy / http_proxy is unusable. Again. Sheesh! I don't know what happened to it and I'm still searching for solution. So, I downloaded the needed dependencies manually and put it inside /usr/ports/distfiles/. After a while the Alpine with ldap support is installed. Oh I need to remove the previous Alpine installation before the new Alpine can be installed. Alpine-ldap is installed and so do DavMail. Now for the good stuff. Making them work (nicely) together. For that, I'll write it in another post.

Coming up next: My DavMail configurations

Monday, November 15, 2010

OpenBSD NC4200: wmiirc, updated status bar script, SLiM login manager & Alpine with Davmail

Using my previous posting as reference, I copied /etc/wmii-3.5/wmiirc to ~/.wmii-3.5/wmiirc then added all the status bar scripts. I also change the following:

# Configuration Variables
MODKEY=Mod4


WMII_TERM="mrxvt"

And then added my status bar script. Surprisingly (or not), I made a few mistakes in my last status bar script I posted previously. You see, I copied the script by typing manually to blogspot, rather than using a text editor's copy/paste function. Furthermore, some of the mistakes are less forgiven in OpenBSD 4.8 than in previous installation. The battery status is not working properly in 4.8. I guess I haven't tested the script thoroughly before although I think previously the script was working ok. Now I've rewritten the battery status script and it seems to be working fine now. So here I'll post the (hopefully) working version of my status bar script. It's still displaying the system cpu usage, free memory, main/extended battery status, a/c adapter status & date time. As for WMII_TERM="mrxvt", that's because I installed mrxvt to replace xterm in wmii.

Here's the updated script for my wmii Status Bar:

# Status Bar info
status() {

 # This is for the main battery, if there's none, just display nothing.
 if [[ $(sysctl -n hw.sensors.acpibat0) != '' ]]; then
  bat0full=$(sysctl -n hw.sensors.acpibat0.amphour0 | sed s/.A.*//)
  bat0warn=$(sysctl -n hw.sensors.acpibat0.amphour1 | sed s/.A.*//)
  bat0low=$(sysctl -n hw.sensors.acpibat0.amphour2 | sed s/.A.*//)
  bat0now=$(sysctl -n hw.sensors.acpibat0.amphour3 | sed s/.A.*//)

  # Get the battery capacity in percentage
  bat0cap=`echo "100 * ${bat0now} / ${bat0full}" | bc`
  bat0p="$bat0cap%"

  # Get the charging status of the battery, replace with symbols
  bat0s=$(sysctl -n hw.sensors.acpibat0.raw0 | sed 's/'0'.*//; s/'1'.*/-/; s/'2'.*/+/; s/'4'.*/!/')
 else
  bat0p=`echo ""`
  bat0s=`echo ""`
 fi

 # This is for extended battery, if it's installed, display the status. Else just display nothing.
 if [[ $(sysctl -n hw.sensors.acpibat1) != '' ]]; then
  bat1full=$(sysctl -n hw.sensors.acpibat1.amphour0 | sed s/.A.*//)
  bat1warn=$(sysctl -n hw.sensors.acpibat1.amphour1 | sed s/.A.*//)
  bat1low=$(sysctl -n hw.sensors.acpibat1.amphour2 | sed s/.A.*//)
  bat1now=$(sysctl -n hw.sensors.acpibat1.amphour3 | sed s/.A.*//)

  # Get the battery capacity in percentage
  bat1cap=`echo "100 * ${bat1now} / ${bat1full}" | bc`
  bat1p="$bat1cap%"

  # Get the charging status of the battery, replace with symbols
  bat1s=$(sysctl -n hw.sensors.acpibat1.raw0 | sed 's/'0'.*//; s/'1'.*/-/; s/'2'.*/+/; s/'4'.*/!/')
 else
  bat1p=`echo ""`
  bat1s=`echo ""`
 fi

 # Get the AC Adapter status
 ac0=$(sysctl -n hw.sensors.acpiac0.indicator0 | sed s/.'('.*//)

 # Get the free memory data using top
 memfree=$(top | grep Memory | sed 's/.*Free:.//; s/.Swap.*//')

 # Get the CPU usage via top
 cpuuse=$(top | grep 'CPU states:' | sed 's/.*nice..//; s/.sys.*//')

 # Display the status bar
 echo CPU: $cpuuse '|' Mem: $memfree '|' Bat: ${bat0p}${bat0s} ${bat1p}${bat1s} '|' AC: $ac0 '|' $(date)

}


Another thing, I changed the X Display Manager to Simple LogIn Manager (SLiM). I would've stick with xdm if not for the fact that xdm (currently) can't let me choose which X session I want to start (wmii or XFCE4). After I installed SLiM, I opened up /etc/rc.local and added:

# Add your local startup actions here.
# This is for SLiM
if [ -x /usr/local/bin/slim ]; then
 echo -n ' slim'; /usr/local/bin/slim -d &
fi

echo '.'


Do make sure that xdm has been disabled in /etc/rc.conf.local or /etc/rc.conf. After that I edited SLiM's config file /etc/slim.conf:

# NOTE: if your system does not have bash you need
# to adjust the command according to your preferred shell,
# i.e. for freebsd use:
login_cmd exec /bin/ksh -l ~/.xinitrc %session


# Available sessions (first one is the default).
# The current chosen session name is replaced in the login_cmd
# above, so your login command can handle different sessions.
# see the xinitrc.sample file shipped with the slim sources
sessions wmii,xfce4


Unfortunately installing the SLiM from package doesn't provide me with xinitrc.sample stated above. After googling for samples, I managed to edit my ~/.xinitrc for SLiM's use:

# This is for SLiM
DEFAULT_SESSION=wmii

case $1 in
wmii)
 xscreensaver &
 eval `cat ~/.fehbg`
 exec wmii
 ;;
xfce4)
 exec startxfce4
 ;;
*)
 xscreensaver &
 eval `cat ~/.fehbg`
 exec $DEFAULT_SESSION
 ;;
esac


Now at SLiM's login screen, I can choose the window manager I want to use with F1. Currently I'm having problem to reload background wallpaper for wmii using feh and searching for solution. It seems that eval `cat ~/.fehbg` is the correct command for it, not `cat ~/.fehbg` As for SLiM, halt and reboot command doesn't work yet. More on that later.

Oh yeah, I'm back on wmii. Not that I don't like xfce. Well xfce is a great desktop environment. But there's something about wmii that kept getting back at me. Currently I'm still using Thunderbird with DavMail, still trying to set up Alpine with DavMail. Will post something on that later.

Update: I'm back to xterm instead of mrxvt. Using xterm-256color is enough for me.

Update: I was thinking about giving a preview on what will be displayed on the status bar. So here it is. This preview is my machine on extended battery (which is charging), on AC adapter. Sorry no fancy picture or anything:

CPU: 4.5% | Mem: 456M | Bat: 100% 76%+ | AC: On | Fri Dec 10 15:27:10 MYT 2010

Thursday, November 11, 2010

OpenBSD NC4200: Testing video function in VLC.

Starting vlc via vlc -vvv shows that there's main interface error regarding x11-display and option global-key-xxx stuff. But vlc can start just fine. With default setting, I can play *.mp3 files just fine but that's audio. vlc just exited with x11-display when I tried opening video file. So I opened vlc, go to Tools > Preferences > Video > Output and choose Simple DirectMedia Layer video output instead of the default, err, Default. Then I opened an *.avi file and it plays nicely. Great.

Still need to search for the main interface error stuff. Later.

Wednesday, November 10, 2010

OpenBSD NC4200: Printing with CUPS.

As my OpenBSD is now my primary OS for work (not that my office requires it), I really need to be able to print anything. Related CUPS packages that's installed is:

cups-1.4.4p1
gtk+2-cups-2.20.1
xfprint-4.6.1p5

Using tips from http://www.insidesocal.com/click/2009/01/openbsd-tip-speed-up-boot-time.html, I edited /etc/rc.local and put:

# Add your local startup actions here.

if [ -x /usr/local/sbin/cupsd ]; then
echo -n ' cupsd'; /usr/local/sbin/cupsd &
fi

echo '.'


and from XFCE Menu > Settings > Xfce 4 Printing System Setting, I choose CUPS as my Printing System.

Then I go to XFCE Meny > System > Manage Printing which will open up http://localhost:631/, the CUPS Management page. From there, I go to CUPS For Administrators > Adding Printers And Classes. It'll go to another page which then I choose Printer > Add Printer. Then I can see all network printers which has been detected! Great! I choose my printer, click Continue, change the printer's Name/Description/Location and click Continue. Then I choose Generic Make as there's no driver available for my printer. After that I choose Generic PCL Laser Printer (en) for the model. A few more setups and the printer is added. I tried printing the summary page from Firefox and it's successful!. Wow. I never thought that it'll be this easy. Later.

Monday, November 08, 2010

OpenBSD NC4200: Getting vlc-web plugins to be listed in Firefox

I installed vlc-web package but it's not listed in my Firefox's plugin list. After searching fer a while, I found that the plugin's directory is locked to root only. So I chmod the directory:

sudo chmod 774 /usr/local/lib/mozilla

After restarting Firefox, the plugin is now listed. I'll try and find a video to play and see the outcome.

OpenBSD NC4200: DavMail LDAP is working..

Okay. Silly me. I found that instead of putting "localhost" in the Hostname tab, I put "locahost". Yeah. Without a freaking "L". Now it's working fine.

OpenBSD NC4200: Thunderbird + DavMail works ok. Firefox 3.5 + java plugins works ok.

I managed to get DavMail running. Like I've posted earlier, it's a bit tricky as it involves getting Java running. For OpenBSD 4.8, Java 1.7.0 can be installed using package but older versions (1.6.0, 1.5.0) will require ports installation. I installed version 1.6.0 using ports (hurray!) but I can't run the davmail.sh. I found that the correct command to run the script is:

sh davmail.sh

Done that and error displayed telling me that it could not find Java. Sheesh. After playing around, I found a way to make Java work. I've installed jdk 1.7.0 & jre 1.7.0 using packages, jdk 1.5.0 & jdk 1.6.0 using ports. I found that the jdks is installed in /usr/local. So, by using jdk 1.7.0, I create a symlink in /usr/local/bin.

ln -s /usr/local/jdk-1.7.0/bin/java /usr/local/bin/java

Then, inside the DavMail folder, I issued the command:

sudo sh davmail.sh

And then... DavMail's icon appears on my XFCE's taskbar! Yeah! Seems to be working! But as I'm not online right now (yeah I wrote this offline..), I can't test it with Thunderbird yet. If all is well, I'll proceed with daemonising the DavMail so it'll autostart as daemon everytime the machine boots up. Now to think about it, all the hours waiting for jdk 1.6.0 & jdk 1.5.0 to be installed is just a waste of time. I'll uninstall those ports and test DavMail later.

I also have to manually add the Java man page in /etc/man.conf. This might not be the perfectly correct addition but now man java works.

# The whatis/apropos database.
_whatdb /usr/local/jdk-1.7.0/man/whatis.db
_whatdb /usr/local/jre-1.7.0/man/whatis.db
_whatdb /usr/local/kaffe/man/whatis.db


# Other sections that represent complete man subdirectories.
jdk17 /usr/local/jdk-1.7.0/man/
jre17 /usr/local/jre-1.7.0/man/
kaffe /usr/local/kaffe/man/


For the above, I just added those lines to the specific sections. In the # Specific section/directory combination. area, I changed the default line:

1 /usr/{share,X11R6,local}/man/{cat,man}1

to this one:

1 /usr/{share,X11R6,local}/{man,jdk-1.7.0/man,jre-1.7.0/man,kaffe/man}/{cat,man}1

Then doing man java now works.

Update: I need to install jdk-1.6.0 (jdk-1.5.0 will be installed as dependency) as jdk-1.7.0 don't have the Firefox plugins. After installing jdk-1.6.0 from ports, there's a guide on how to create symlink pointing to firefox's plugins directory. Just follow that and Firefox can operate with java sites. Yeah!

For Thunderbird, I just follow the guide in DavMail's Website and I can now access my company's Exchange using IMAP connection. CalDav also works fine (which is not ok previously using XP) but it seems that I still need to make my LDAP address book working. Will be looking out for that later. Autostarting the davmail also is giving me problem. As for now, I can just start davmail using console with this command:

sudo sh davmail.sh &

Daemon mode using /etc/local.conf or ~/.xinitrc won't work. Tu use Lightning (Thunderbird calendar extension), I need to install it from package. There won't be any available installation for that via mozilla's addon site.

As for the ftp_proxy & http_proxy, I've added this lines in my ~/.profile file:

# Set up proxy
export ftp_proxy=http://my.proxy.net:8080/
export http_proxy=http://my.proxy.net:8080/


Update: I've done another ports installation (for opera) and proxy works like a charm now!. Later.

Thursday, November 04, 2010

OpenBSD NC4200: Ports round 2. Java installation. DavMail with Thunderbird.

I've done another installation of OpenBSD. Now I'm using 4.8. I've install XFCE Desktop Environment. Yeah well read good comments about it. Skipped GNome / KDE because it's too bloated.

I managed to get Thunderbird working with DavMail to access my exchange (company) email. But that's in Windows XP. Because DavMail is based on Java, it's stated that the program can run from Linux & *BSD/*NIX. This will be my main project for now.

As DavMail requires JDK, I need to install Java. As stated in the documentation, no package exist for JDK prior to 1.7. So, I was left (again) with the choice to install Java using ports system which if you remember, failed miserably in 4.7 because of my ftp_proxy/http_proxy. As for this round 2, I have a good news. I can now do ports installation behind proxy! Using console, I just type:

export ftp_proxy=http://proxy.address.net:8080/

and I can now do ports installation!. I also do export http_proxy with the same proxy address. To make the proxy setting permanent, I edited ~/.profile and includes:

export ftp_proxy=http://proxy.address.net:8080/
export http_proxy=http://proxy.address.net:8080/


But I haven't rebooted the machine yet so I can test this one. A "'" (single quote) might be needed to enclosed the proxy address. Now on the Java installation (1.6).

First I downloaded the ports.tar.gz file from OpenBSD's mirror and unpacked it following the available howto.

Then I created a /etc/mk/conf file and included:

SUDO=/usr/bin/sudo
ACCEPT_JRL_LICENSE=Yes


As this is my first time installing Java using ports, I use make search name=java inside /usr/ports and run make install inside Java 1.6 folder. Installation exited prematurely as there's a few files In needed to download manually which is:

http://download.java.net/jdk6/6u3/
jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar
jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar
jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar

http://www.eyesbeyond.com/freebsddom/java/JDK16JRLConfirm.html
bsd-jdk16-patches-4.tar.bz2
(Just click the ACCEPT button and the download will begin)

(Java 1.5 seems to be needed too)

http://download.java.net/tiger/tiger_u16/
jdk-1_5_0_16-fcs-src-b02-jrl-28_may_2008.jar
jdk-1_5_0_16-fcs-bin-b02-jrl-20_may_2008.jar
jdk-1_5_0_16-mozilla_headers-b02-unix-28_may_2008.jar (might be optional)

http://www.eyesbeyond.com/freebsddom/java/JDK15JRLConfirm.html
bsd-jdk15-patches-9.tar.bz2
(Just click the ACCEPT button and the download will begin)

http://java.sun.com/products/archive/j2se/5.0_16/index.html
jdk-1_5_0_16-solaris-i586.tar.Z
(Kind of tricky to get this file. Remember to choose Solaris X86)

http://archive.apache.org/dist/xml/xalan-j/
xalan-j_2_7_0-bin.tar.gz

I put all the files inside /usr/ports/distfiles and then I continue the make install process. Wallah! Ports can now download additional files automatically! Hurray! the proxy settings works! Now I let it install. To be continued...

6.5 amd64: Modify existing certbot certificates.

Hi, It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to ...