Create a Cursor with XLib

1. Install Xorg Server
2. Install MtPaint
3. Edit the file ~/.xinitrc and add “mtpaint”.
4. Run “startx” to launch mtpaint.
5. Create a cursor file and save it as a PNG.
6. Use this command to convert to XBM:

 convert cursor.png cursor.xbm

7. This code will launch X and draw the cursor on the mouse position.

#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <stdio.h>
#include <unistd.h>

int main() {
  Display *display;
  Window window, rootwindow;
  XEvent event;
  KeySym escape;
  XColor red;
  Colormap screen_colormap;
  display = XOpenDisplay(NULL);
  int screen = DefaultScreen(display);
  screen_colormap = DefaultColormap(display, screen);
  XColor blue;
  XAllocNamedColor(display, screen_colormap, "red", &red, &red);
  XAllocNamedColor(display, screen_colormap, "blue", &blue, &blue);
  int w = DisplayWidth(display, screen);
  int h = DisplayHeight(display, screen);
  rootwindow = DefaultRootWindow(display);
  window = XCreateSimpleWindow(display, rootwindow,
  0, 0, w, h,
  1, BlackPixel(display, screen), WhitePixel(display, screen));

  GC gc = DefaultGC(display, screen);
  XSetForeground(display, gc, red.pixel);
  XSetFillStyle(display, gc, FillSolid);
  XSelectInput(display, window, StructureNotifyMask | SubstructureRedirectMask | ResizeRedirectMask | KeyPressMask | KeyReleaseMask | ExposureMask | ButtonPressMask | PointerMotionMask);
  XLowerWindow(display, window);
  XMapWindow(display, window);

  Pixmap bitmap;
  unsigned int bitmap_width, bitmap_height;
  int hotspot_x, hotspot_y;
  int check = XReadBitmapFile(display, rootwindow, "/home/user1/cursor.xbm", &bitmap_width, &bitmap_height, &bitmap, &hotspot_x, &hotspot_y);
  printf("%d\n", check);

  do {
    XNextEvent(display, &event);
  } while (event.type != MapNotify);

  XGrabKeyboard(display, window, False, GrabModeAsync, GrabModeAsync, CurrentTime);
  XLowerWindow(display, window);

  escape = XKeysymToKeycode(display, XK_Escape);
  printf("\nPress ESC to exit.\n\n");

  while (1) {

    XClearWindow(display, window);
    XNextEvent(display, &event);

    int mouse_x;
    int mouse_y;

    if (event.type == KeyPress) {
      printf("KeyPress: keycode %u state %u\n", event.xkey.keycode, event.xkey.state);

    if (event.type == KeyRelease) {

      printf("KeyRelease: keycode %u state %u\n", event.xkey.keycode, event.xkey.state);
    if (event.xkey.keycode == escape)
    if (event.type == MotionNotify){
      mouse_x = event.xmotion.x;
      mouse_y = event.xmotion.y;
    if (event.type == ButtonPress) {
      mouse_x = event.xbutton.x;
      mouse_y = event.xbutton.y;

      printf("Mouse click at: (%i, %i)", mouse_x, mouse_y);
    XCopyPlane(display, bitmap, window, gc, 0, 0, bitmap_width, bitmap_height, mouse_x, mouse_y, 1);

    printf("Event type %d\n", event.type);

  XUngrabKeyboard(display, CurrentTime);

  XDestroyWindow(display, window);
  return 0;

8. Use this command to build the executable:

gcc -o xmouse -lX11 main.c

9. Add the project directory to PATH with this command:

export PATH=$PATH:/your/path

10. Edit the file ~/.xinitrc and add “xmouse”
11. Launch X with the command “startx”



How to use Git

Create a project on your machine.

Run git init to initialize a git repository for your project.

Modify some files in your project.

Run git status to see the changes you have made in your project.

Run git add –all to tell git that you want it to track all those files you changed.

Run git status again to see that git added all those files.

Run git commit -m “my commit message” to tell git that you want to commit these changes to your local repository. Now, every change you made is saved locally by git.

Run git status to see there are no modifications left.

Run git log to see the commit you just made.

Now you decide you want to make the code you commited public, so you create a public repository on Github. Github tells you to do the following if you have an existing repository (you have an existing repository because you ran git init in your project). What Github tells you to do is:

Run git remote add origin This command adds a “remote” to your local repository. A remote is a special word that means “the link of the public repository you want to push to”.

Run git remote -v to see the new remote you added with the name “origin”

Run git push -u origin master. git push is the command to send the commits to the public repository. “origin” is the remote repository you are sending your changes to. “master” is the branch you want to send to that remote repository.

Now the cycle starts over again: modify some files, run git add –all, run git commit -m “my other commit message”, run git push. And puff, you are a pro using git.

Remember that you can run git status and git log at any time to see the current status of your local repository.

How to improve digital project management

Here are some important aspects to improve digital project management.

1. Human-centered management

The tools have to fit the person and not the other way around. If you already have a method of producing quality work without much hassle you should stick to it. However, you might face problems later that you can’t predict now so it’s important to be conscious of what you’re doing.

2. Data

Nothing starts from scratch, anything we create is a reaction to history through our mental model. Make a habit of absorving relevant sources, maintain backups and modularize reusable content. The process of filtering data to suit our needs is done through analysis and selection.

3. Sinergy

Specialization is only useful through collaboration. The problems of today involve various fields of science so it’s important to reach out and get a different perspective. When you feel like you’re having to wear two hats, it’s an opportunity to outsource.

How to import Blender files to Unity

1. We’ll use this Blender scene for the purposes of this tutorial. It’s important to name the materials and save the textures separately.


2. Open a Unity project and import the textures.


3. Import the .blend file and make sure you tick the “Generate Colliders” checkbox


4. Righ-click the scene and then “Select Dependencies”.


5. You should now see the imported materials.


6. After editing the materials just drag the element into the editor to place the scene.