Skip to content
August 10, 2014 / Chris Merck

FreeBSD Desktop (with Mutliple Monitors)

I got fed up with the complications of Linux somewhere around systemd being added to ArchLinux. Manually typing a 20-line systemd script just to set a static IP was the last straw for me.

So I installed FreeBSD. It just worked for the most part.

The one trick I needed to do was manually set the maximum virtual screen resolution to allow multiple monitors. I was guided by this post on the Gentoo forums

The error I was up against was:

xrandr: screen cannot be larger than 1920×1920 (desired size 3840×1080)

I had to create /usr/X11/xorg.conf, where the bolded line is the crucial addition.

Section “ServerLayout”
Identifier     “X.org Configured”
Screen      0  “Screen0” 0 0
InputDevice    “Mouse0” “CorePointer”
InputDevice    “Keyboard0” “CoreKeyboard”
EndSection

Section “Files”
ModulePath   “/usr/local/lib/xorg/modules”
FontPath     “/usr/local/lib/X11/fonts/misc/”
FontPath     “/usr/local/lib/X11/fonts/TTF/”
FontPath     “/usr/local/lib/X11/fonts/OTF”
FontPath     “/usr/local/lib/X11/fonts/Type1/”
FontPath     “/usr/local/lib/X11/fonts/100dpi/”
FontPath     “/usr/local/lib/X11/fonts/75dpi/”
EndSection

Section “Module”
Load  “dbe”
Load  “dri”
Load  “dri2”
Load  “extmod”
Load  “record”
Load  “glx”
EndSection

Section “InputDevice”
Identifier  “Keyboard0”
Driver      “kbd”
EndSection

Section “InputDevice”
Identifier  “Mouse0”
Driver      “mouse”
Option        “Protocol” “auto”
Option        “Device” “/dev/sysmouse”
Option        “ZAxisMapping” “4 5 6 7”
EndSection

Section “Monitor”
Identifier   “Monitor0”
VendorName   “Monitor Vendor”
ModelName    “Monitor Model”
EndSection

Section “Device”
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: “True”/”False”,
### <string>: “String”, <freq>: “<f> Hz/kHz/MHz”
### [arg]: arg optional
#Option     “SWcursor”               # [<bool>]
#Option     “HWcursor”               # [<bool>]
#Option     “NoAccel”                # [<bool>]
#Option     “ShadowFB”               # [<bool>]
#Option     “UseFBDev”               # [<bool>]
#Option     “Rotate”                 # [<str>]
#Option     “VideoKey”               # <i>
#Option     “FlatPanel”              # [<bool>]
#Option     “FPDither”               # [<bool>]
#Option     “CrtcNumber”             # <i>
#Option     “FPScale”                # [<bool>]
#Option     “FPTweak”                # <i>
#Option     “DualHead”               # [<bool>]
Identifier  “Card0”
Driver      “nv”
VendorName  “NVIDIA Corporation”
BoardName   “G96 [GeForce 9500 GT]”
BusID       “PCI:1:0:0”
EndSection

Section “Screen”
Identifier “Screen0”
Device     “Card0”
Monitor    “Monitor0”
SubSection “Display”
Viewport   0 0
Depth     24
        Virtual      3200 1080
EndSubSection
EndSection

Now to see if I can setup my ARM cross-compilation toolchain for ChibiOS/STM32… That will be the real test.

Advertisements
February 23, 2012 / Chris Merck

Use GIMP to Scanify Cellphone Photos of Documents

How to make a nice-looking scan from a cell-phone photo of a document using the GIMP:

Open Image
Ctrl-L to view Layers Window
Layer > New From Visible
“Visible” Layer should be selected
Filters > Blur > Gaussian Blur
Blur Radius = 160px (for a ~2k by 2k image)
In the Layers Window, change Mode to Divide
Right-Click on the Layer called “Visible” > Merge Down
Colors > Threshold
Adjust the Black Slider to roughly 200. Tweak, looking at preview.
Zoom in by pressing “1” to examine the results.
Save!

October 10, 2011 / Chris Merck

Python and Pygame in OSX

Ok, so OSX is not as easy as Arch for getting setup with Pygame/Python. Here’s how I got it working. Comment if this works (or not) for you. These instructions were tested on OSX Snow Leopard, but may work for Lion.

Download and install the following:

  • pygame: download the latest pygame for OSX from here. I used this one. Take a note of the supported python version. In my case it was 2.7.
  • python: Select the latest version from the list that is supported by the pygame you downloaded. I used this one.
  • iTerm 2: this terminal emulator rocks. Get it here. I use it in full-screen mode with vim.
  • MacVim: Of course, everyone uses vim :). But if you prefer a gui, then this is the (best) gVim for OSX.
After downloading be sure to install using the installers for python and pygame, and by dragging the iTerm2 and MacVim apps into Applications.
Now test out pygame using a tutorial such as this one.
If you got a 64-bit-capable version of python, you might have trouble running pygame (since, at the time of writing, pygame is 32-bit only). To force python to run in 32-bit mode, invoke it like this:
 arch -i386 python helloworld.py 
Happy pygaming!
July 11, 2011 / Chris Merck

Tegaki in iBus + eStroke in Wine = iPhone-like Chinese Magic

iPhone Setup (to be emulated)

My study of Zhongwen has been grately aided by the iPhone application eStroke (which will cost you a few dollars, but far less than the migraine-inducing dead-tree alternatives), in combination with the built-in simplified Chinese pinyin and handwritten input methods provided by Apple. Using eStroke, you can in seconds find the meaning and pronunciation of a character from even a rather botched attempt at tracing the strokes with your pointerfinger:

Looking up a character in eStroke using Apple's handwriting recognition. The eStroke app then gives the stroke order and a brief definition, plus On and Kun readings in Japanese if you care.

eStroke also includes CEDICT, a free dictionary that's suited me fine so far. Tapping on any entry gives more details, including stroke-order and a per-character or per-subphrase breakdown.

I’m perfectly happy using this on the iPhone. However, I would like to have these resources available to me on my PC anyway, especially as I get deeper into composing Chinese texts, and for possible automation of lookups, etc.

ArchLinux setup

So, the goal is to get similar features and ease-of-use on an PC ArchLinux system to what we have on the iPhone. This requires a few different packages and programs:

  1. Pinyin input: ibus-pinyin (Setting this up is covered in the previous post.)
  2. Handwritten input:
    You should be able to just install one package using yaourt and the dependancies will be installed too:

     yaourt tegaki-models-zinnia-simplified-chinese 

    NOTE: The important dependancies are ibus, which is the input system, tegaki-recognize, which is the input method GUI, ibus-tegaki, which plugs tegaki into ibus, zinnia, which is the recognition engine, and tegaki-models-zinnia-simplified-chinese, which is the recognition model for zinnia which contains the actual stroke-regnition data.

  3. After installing ibus-tegaki, you may need to fix the install, which is broken at the moment:
    From eric2’s comment on the ibus-tegaki AUR page:

    1. /usr/lib/ibus-tegaki/ibus-engine-tegaki
    Change “python” into “python2”
    Change the path to where it is installed (it was still “/var/abs/local/…”)
    (For me this means removing the “/tmp…” prefix and just leaving the “/usr/share/bin/…” part of the path. 2. /usr/share/ibus/component/tegaki.xml
    Change the path to where it is installed (in two places)

  4. Install wine if you have not already.
  5. Download the latest eStroke for Windows from the official website.
  6. Execute the eStroke download, which is a Windows installer, using wine.
  7. After installing, navigate to the directory where eStroke was installed (probably “~/.wine/drive_c/Program\ Files/eStroke/” and execute “eStroke.exe” using wine.
  8. eStroke works OK, with tegaki (handwritten) and pinyin input, similarly to how it works on the iPhone. The only glitch is that the Chinese characters that use a font (rather than drawn from eStroke’s database) do not render for me. If I figgure out how to fix this, I’ll update this post. Until then, using an online portal to CDICT will suffice. You can even use the handwritten input directly in Firefox to look up a character in CDICT. (Although you don’t get the stroke-order that eStroke boasts.)

Tegaki handwritten input used in conjunction with eStroke, running through Wine.

July 11, 2011 / Chris Merck

Chinese (Pinyin) Input in ArchLinux using iBus

Previously I had used SCIM, but now ArchWiki says iBus is the actively developed/supported input method. I’m very happy with how iBus works for me. To use it, just follow the instructions on the wiki, most importantly installing pinyin support:

 sudo pacman -S ibus ibus-qt ibus-pinyin 

Also, make sure to follow iBus’s instructions regarding adding some environment vars in bashrc.

After that, you must open the iBus preferences by right-clicking on the system tray icon. Now you can press Ctrl-Enter to toggle Pinyin input mode. I wanted just one more tweak however: I want to press any punctuation key (period, comma, question mark, exclamation point) and have my pinyin converted into hanzi. To get this to work, do the following:

  1. Enable pinyin input mode by pressing Ctrl-Enter while in some text editor (say, gedit).
  2. The iBus system tray icon will turn into a ‘拼’ (‘pin(yin)’) character. Right-click it.
  3. Click on “Preferences”. Now you can edit Preferences specifically for the Pinyin input method.
  4.  Click on the Pinyin mode tab.
  5. Uncheck “[,] [.] flip page” and check “Auto commit”.
  6. Hit close. Now you can enter Chinese text at an amazing rate!

You can even leave out the endings of common sylables for an even faster input rate. For example, it takes only 21 keystrokes to enter the Chinese sentence “我们等公共汽车的时候下雨了”, a translation of “It was raining while we waited for the bus.” Regard:

Entering “wmdengggqchdshhou” gives the subordinated phrase:

Then pressing spacebar followed by “xyl” gives the rest of the sentence:

Then just a simple tap of the period key automatically commits “下雨了” and adds a chinese full-stop.

Happy iBusing!

July 6, 2011 / Chris Merck

Rotating Video from iPhone

Yesterday I had a video from my iPhone that played upside-down. I’m going to call this a bug on Apple’s part, even if there is some sort of meta-data in the file that indicates the “orientation” (If so, that’s B.S., Apple, just rotate the video on the phone!) I tried the mencoder-based technique described here, but it was only a modification of the ffmpeg-based technique I learned about here that actually worked for me.

Anyhow, so I’ll assume you’re stuck with a video that plays upside-down. You can fix it using two applications of ffmpeg‘s transpose filter:

ffmpeg -i upside-down.mov -vf transpose=2 -vcodec libx264  -crf 22 -threads -0 -acodec copy output.mp4
ffmpeg -i output.mp4 -vf transpose=2 -vcodec libx264  -crf 22 -threads -0 -acodec copy right-side-up.mp4

And voila!

Unfortunately there is significant quality loss, which would likely be less drastic if transpose could do the whole 180-degree rotation in one shot.

June 27, 2011 / Chris Merck

pacserve

I don’t have stellar bandwidth. I also have at least two machines with Arch installed. I used to dread upgrading the second machine. Thankfully, now I have pacserve!

Just follow his instructions… (which for me boil down to:)

  1. Install pacserve via AUR.
  2. Punch holes in ze firevall:
     sudo iptables -A INPUT -p tcp --dport 15678 -j ACCEPT
    sudo iptables -A INPUT -p udp -m pkttype --pkt-type multicast --dport 15679 -j ACCEPT 
  3. Add entry to top of /etc/pacman.d/mirrorlist on each machine:
    Server = http://localhost:15678/request/$repo/$arch
  4. Start pacserve on each machine:
    pacserve --multicast
  5. Fire away with pacman:
    pacman -Syu

Enjoy 12MB/s for packages shared over the (100Mbit) LAN.

:: Retrieving packages from extra...
  ca-certificates-ja...     3.2K  617.6K/s 00:00:00 [######################] 100%
  openjdk6-6.b22_1.1...    30.0M   11.2M/s 00:00:03 [######################] 100%
  eclipse-3.7-1-i686      168.7M   11.2M/s 00:00:15 [######################] 100%

Thank you Xyne!