Archive for the 'miscellaneous' Category

Gnome shell Hello world

Gnome Shell, besides providing the main user interface for GNOME 3, is a Javascript shell with bindings to many native interfaces that allow e.g. Window manipulation, graphics rendering and animations, compositing, etc. It also allows developers to write extensions changing Gnome Shell’s behavior.

Less known is that it is possible to replace the entire Javascript code base that Gnome Shell uses. It can be useful to hack on Gnome Shell itself (no need to fiddle with system files, or, since 3.12, no need to rebuild libgnome-shell.so), but it can also be used to implement a completely new User Interface in Javascript.

I’m starting to experiment with the latter, because I want to try building a window manager that fits my needs, while keeping away the boring details of EWMH, xinerama, and other X11 things. And because it’s fun.

But baby steps, first: let’s bootstrap a Hello world with Gnome shell.

  • Create a directory that will hold your code.
  • In that directory, create a ui subdirectory.
  • In that ui directory, create a environment.js file, with the following contents:
    const Shell = imports.gi.Shell;
    
    function init() {
      window.global = Shell.Global.get();
    }
    
  • In the same directory, create a main.js file, with the following contents:
    const St = imports.gi.St;
    
    function start() {
      let text = new St.Label({ text: "Hello, world!" });
      global.stage.add_actor(text);
      global.stage.show();
    }
    
  • Run Gnome Shell with your code:
    $ GNOME_SHELL_JS=/path/to/parent/of/ui gnome-shell
    

    You may want to run this in a separate X server (I use Xephyr)

I tested this with Gnome Shell 3.14. Trying various older versions, I got different results for reasons I don’t know. 3.4 doesn’t display anything unless, paradoxically, global.stage.show() is removed, and 3.8 doesn’t display anything no matter what.

I guess the next step is to go through some Clutter tutorials and transpose them to Javascript.

Update: On the other hand, a lot of the window managing is still done by mutter under the hood, which doesn’t leave a lot of space for something really different.

2015-05-04 04:10:17+0200

miscellaneous, p.d.o | 1 Comment »

Dear lazyweb

I would like to replace my current blog with a system that mostly generates static pages, with support for comments. I’d like it to take files as input for blog posts (I’d like to store them in git), instead of database tables, and to have a flexible markup language (flexible in that it’d allow to customize the HTML output), and flexible templates.

Ikiwiki might come close to that, though I haven’t looked into details. Dear lazyweb, would you know other software that’d fulfill my needs, or come close?

2011-01-16 10:12:53+0200

miscellaneous, p.d.o, p.m.o | 17 Comments »

Efficient way to get files off the page cache

There’s this great feature in modern operating systems called the page cache. Simply put, it keeps in memory what normally is stored on disk and helps both read and write performance. While it’s all nice for a day to day use, it often gets in the way when one wants to track performance issues with “cold cache” (when the files you need to access are not in the page cache yet).

A commonly used command to flush the Linux page cache is the following:

# echo 3 > /proc/sys/vm/drop_caches

Unfortunately, its effect is broad, and it flushes the whole page cache. When working on cold startup performance of an application like Firefox, what you really want is to have your page cache in a state close to what it was before you started the application.

One way to get in a better position than flushing the entire page cache is to reboot: the page cache will be filled with system and desktop environment libraries during the boot process, making the application startup closer to what you want. But it takes time. A whole lot of it.

In one of my “what if” moments, I wondered what happens to the page cache when using posix_fadvise with the POSIX_FADV_DONTNEED hint. Guess what? It actually reliably flushes the page cache for the given range in the given file. At least it does so with Debian Squeeze’s Linux kernel. Provided you have a list of files your application loads that aren’t already in the page cache, you can flush these files and only these from the page cache.

The following source code compiles to a tool to which you give a list of files as arguments, and that flushes these files:

#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
int main(int argc, char *argv[]) {
  int i, fd;
  for (i = 1; i < argc; i++) {
    if ((fd = open(argv[i], O_RDONLY)) != -1) {
      struct stat st;
      fstat(fd, &st);
      posix_fadvise(fd, 0, st.st_size, POSIX_FADV_DONTNEED);
      close(fd);
    }
  }
  return 0;
}

It’s actually a pretty scary feature, especially on multi-user environments, because any user can flush any file she can open, repeatedly, possibly hitting system performance. By the way, on systems using lxc (and maybe other containers, I don’t know), running the echo 3 > /proc/sys/vm/drop_caches command from a root shell in a container does flush the host page cache, which could be dangerous for VPS hosting services using these solutions.

Update: I have to revise my judgment, it appears posix_fadvise(,,,POSIX_FADV_DONTNEED) doesn’t flush (parts of) files that are still in use by other processes, which still makes it very useful for my usecase, but also makes it less dangerous than I thought. The drop_cache problem is still real with lxc, though.

2010-12-29 19:34:37+0200

miscellaneous, p.d.o, p.m.o | 11 Comments »

Recommended for You

There is a part on the Youtube home page which recommends some videos based on what you already watched.

I’m still trying to understand what kind of link there can be.

2010-05-22 11:33:24+0200

miscellaneous, p.m.o | No Comments »

日本語入力をibusで

最近まで、scimを使っていましたが、一週間前ibusを使ってみました。Input Method自体がまだanthyですけれどナントナクibusの方が使い易いというか楽というか。

とにかく、Debianでインストールするのは簡単です。最初はrootで:

$ apt-get install ibus-anthy ibus-gtk ibus-qt4 (Gnome/Gtk+のソフトだけを使ってる場合はibus-gtkだけでいいですし、KDE/Qtの場合はもちろんibus-qt4だけでもいいです)

次にユーザで:

$ im-switch -s ibus

2010-04-26 09:11:26+0200

miscellaneous, p.d.o | No Comments »

ssh root@guitar

After the coffee machine, would you have expected to be able to login on a guitar ? Well, now, you can, on the Misa digital. It is not only a digital guitar, but it runs (Gentoo) Linux, and… an ssh server.

2010-01-20 17:14:48+0200

miscellaneous, p.d.o | 1 Comment »

VMware + X.org + gnome-screensaver + strong password = FAIL

Guess what happens when you use software that can fuck up your keyboard mappings (VMware Remote Console), in combination with software that uses these mappings to be able to switch back to a text console (X.org) and a screen saver that locks your screen (gnome-screensaver, but that would worl equally well with xlock or anything else similar) ? A recipe for FAIL.

It so happens that VMware Remote Console, and apparently other VMware products such as Player or Workstation not only are unable to do anything useful with special keys (try installing Debian without the arrows keys, for example), but they are also able to remap keys (such as ctrl, shift and caps lock) to nothing.

It also happens that X.org uses its keyboard mappings when dealing with the ctrl+alt+Fn key combinations that allow to get back to a text console. Yes, that means you can’t switch to a text console after VMware fucked up your keyboard mappings.

On top of all that, add a X session locking program, that won’t allow you back until you type your password, and a password that, well, you just can’t type without shift of caps-lock, because it is somehow strong. The X session locking program won’t allow you to fix your keyboard mappings, you can’t switch to a text console either, and you can’t unlock for obvious reasons.

The only solution that didn’t involve a reboot or losing everything under the X session was to ssh in, change the password to one that can be typed without shift and unlock.

It is said on the interwebs that adding “xkeymap.nokeycodeMap = true” in the ~/.vmware/config file solves the issue. At least, it works for the arrows. I’ll see if it also prevents the special keys to be remapped.

2009-12-09 00:13:15+0200

miscellaneous, p.d.o | 5 Comments »

Chrome OS

Chrome OS has been announced today, and from a quick look at this video, it very much looks like it is some kind of Coreboot (formerly LinuxBIOS), X and Chrome combination. As such, it seems it’s not something you’re going to fully enjoy on any computer.

Update: Apparently, they use their own firmware and a Linux 2.6.30 kernel. If they went the custom firmware route, and wanted a fast boot, I wonder why they didn’t start with Coreboot, instead.

2009-11-19 21:32:56+0200

miscellaneous, p.d.o | 3 Comments »

How not to provide robust clustered storage with Linux and GFS

(The title is a bit strong, on purpose)

LWN links to an article describing how to provide robust clustered storage with Linux and GFS.

While explaining how to setup GFS can be nice, the incentive made me jump.

The author writes:

Load balancing is difficult; often we need to share file systems via NFS or other mechanisms to provide a central location for the data. While you may be protected against a Web server node failure, you are still sharing fate with the central storage node. Using GFS, the free clustered file system in Linux, you can create a truly robust cluster that does not depend on other servers. In this article, we show you how to properly configure GFS.

In case you don’t know, GFS is not exactly a “clustered storage”. It is more a “shared storage”. You have one storage, and several clients accessing it. You have one storage array, compared to the NFS case, where you have one central server for the data. But what is a storage array except a special (and expensive) kind of server ? You don’t depend on other servers, but you depend on other servers ? How is that supposed to be different ?

Conceptually, a clustered file system allows multiple operating systems to mount the same file system, and write to it at the same time. There are many clustered file systems available including Sun’s Lustre, OCFS from Oracle, and GFS for Linux.

OCFS and GFS are the same class of file systems, but Lustre is definitely out of league and would, actually, provide a truly robust cluster that does not depend on other servers. Lustre is a truly clustered filesystem, that distributes data on several nodes such that losing some nodes don’t make you lose access to the data.

With the incentive given by the author, and considering he lists Lustre as an example, I would actually have preferred an article about setting up Lustre.

2009-04-07 20:29:04+0200

miscellaneous, p.d.o | 13 Comments »

A revolution happening at the W3C ?

It seems undergoing discussion is leading towards a free (as in speech) HTML5 specification.

That would really be great.

2009-04-02 21:31:00+0200

miscellaneous, p.d.o | Comments Off on A revolution happening at the W3C ?