Archive for April, 2011

Command line twitter

(twyt ang bti, apologies for the vague FUD, but I just couldn’t get you to work. Feel free to comment)

I was trying to get basic twitter working from the command line. This was more difficult that expected, I went through four different approaches before I found one that worked.

bti – Didn’t work (reported no errors – even with verbose just did nothing)

twyt – Consistently said bad password

raw curl – Basic auth not supported

Finally I found ttytter, which wasn’t in the main ubuntu repository, but for which there was a ppa. After getting an oauth key this worked fine (with no man pages….grr). This can be reasonably scripter

Advertisements

April 29, 2011 at 1:45 am Leave a comment

DESTDIR – Build to a different location

The DESTDIR environment variable is a convention used in most makefiles. It is *very* useful when building binaries for installation.

The problem one comes across when building binaries is that variable set in configuration are used both as locations for installing, and locations used by the running process. So if you want to build binaries, install them somewhere, and then copy them somewhere else you have a problem.

The DESTDIR variable can get round this by overriding where binaries should be installed.

Common usecase

./configure
make
DESTDIR=../build/ make install;

April 28, 2011 at 6:15 pm Leave a comment

A rough outline of how X works

In the past, I’d always thought of invoking X as somewhat arcane. It turns out I’m that wrong: The basic X set up is straightforward – the complexity is generated by all the glue.

X windows basically consists of a server process, ‘X’. Other programs (clients) communicate with this process through a socket interface using a binary protocol (normally a unix domain socket, but this can also be a tcp socket).

Each X server uses a free virtual terminal for display. By default, the virtual terminal with the lowest number is used – but one can also specify which virtual terminal to use.

To support multiple X servers on a single machine, each X server is given a name like ‘:0’ or ‘:1’: This is termed a display. Processes that want to use a particular X server use this name to communicate with the X server.

(Under the hood, an appropriate unix domain socket file is created in tmp named after the display, or the display number is converted into a tcp port around 6000).

Together this means that getting a primitive X is terribly simple (though insecure if you don’t have a firewall and can’t trust the other users of your machine (including the non-human ones):

X :1
#X :1 vt10 would start X on tty10
DISPLAY=:1 xterm&

When you start X normally with xinit (or via [gxk]dm), it uses additional authentication and switches off tcp.

April 23, 2011 at 12:08 pm Leave a comment

Adventures with linux (virtual) terminals

I didn’t know how linux terminals worked. Now I know slightly more.

The linux kernel supports a preset number of terminal type things (called, variously, terminals, consoles or virtual terminals – but not pseudo-terminals). At the time of writing, 63 terminals were supported.

From the users perspective, it is as though they terminals always exist and can always be written to (in /dev/tty*), but
in practice, I imagine that linux allocates these terminals as you go.

A processes view of a terminal

You can write and read from a terminal just like you would a normal file (they are character streams so you can’t seek).

This works fine from the command line:

echo "HELLO TERMINAL" > /dev/tty16
cat < /dev/tty16 

The physical interface to a terminal

A terminal is more than a file – it is something that you physically interact with. You can see things that get written to a terminal and you can type into it.

This is all magically handled by the kernel: when the kernel thinks that you are looking at a particular terminal it reads any key presses, converts them to characters, then writes them to relevant file. (Interestingly, keypresses only do something if there is something on the other end reading from the terminal)

Similarly, characters written are collected into a buffer displayed on the screen.

There are also magic commands which switch terminals. Strace informs me that all this magic works via the ioctl function call. You can cause these cause the appropriate calls by either using the “chvt” command, or there are well-known keybindings for the task.

strace 2>&1 chvt 16 

BORING
ioctl(3, VT_ACTIVATE, 0x10) # HURRAH

You can see the actual keybindings by looking at the loadkeys keymap file. (in /etc/console-setup on Ubuntu 10.04.2). [Crazy fact – there are keybindings for switching to terminals 1-36 in my configuration file!).

April 23, 2011 at 12:05 am Leave a comment

Gstreamer cheat sheet

For my future benefit:

Gstreamer is used to create pipe lines for conversion of streaming formats (eg audio and video).

These live within a gstreamer process. I presume this creates sort sort of efficiency benefit.

Bootstrap:

gst-inspect | grep

gst-inspect module-found-above

gst-launch module-found-above key=value

gst-launch filesrc location=filename ! module-found key= value | pulsesink to play

Useful modules:

mad (to decode mp3s)
pulsesink to play things
filesrc

April 8, 2011 at 8:57 pm Leave a comment

Mobile broadband for linux

It appears that new mobile internet dongles aren’t very well supported in linux.

I had problems get the new vodafone dongle to work (ZTE K3570-Z – I bought this in January 2010, this was with quite a lot of work).

3 were the only provider who I could be sure provided a dongle that worked with linux (ZTE MF112 avaiable as of april 2011).

This worked out of the box with Lucid, with the following caveats:

i. The dongle occasionally sent out stronger signals causing my monitor to flicker. (This was very occasional every hour or so, and on a laptop)

ii. The dongle becomes quite hot (more noticeable so that with the windows only vodafone dongle).

iii. I think the connector on the dongle is slightly flimsy. I managed to break this by leaving my laptop on things. Though I was by no means being careful. I would advise using the connector provided.

April 5, 2011 at 11:04 pm Leave a comment


April 2011
M T W T F S S
« Mar   May »
 123
45678910
11121314151617
18192021222324
252627282930