MyNixOS website logo
Description

A utility for X11 that moves the mouse cursor using the keyboard.

place-cursor-at

A utility for X11 that moves the mouse cursor using the keyboard. Written in Haskell.

This utility only gives you an ability to quickly move your mouse cursor to one of 9 common spots of the screen. It’s intended to reduce the use of the mouse, but not to replace it completely. It doesn’t provide you accurate aiming, only approximate.

You bind a hotkey (in your WM configuration or by using xbindkeys) to run place-cursor-at (say Super+M) and when you press it you see 9 windows on current screen with letters shown on them. When you press a letter on your keyboard that is associated with one of those windows your mouse cursor appear at the center of that window and the application closes. Thus you can quickly move your mouse cursor to one of 9 different spots by two-step combo.

Other key bindings:

  1. Press Escape to close the application (when one of the letter windows is focused)

  2. Move focus to a letter window where you want your mouse cursor to be and press Enter (this is the same as pressing that letter on your keyboard)

I originally created this tool it for myself to use it with xmonad and i3.

Screenshot

Requirements

Either one:

  1. Nix Package Manager

  2. The Haskell Tool Stack and:

    1. libX11 development files
    2. libXinerama development files

How to use

With Nix

See Nix Package Manager.

You can run this application like this:

nix-shell --run place-cursor-at

See also shell.nix’s arguments for available options. For instance if you want to enter a nix-shell with cabal available:

nix-shell --arg withCabal true

NixOS

You can add this application into your NixOS configuration.nix like this:

{ pkgs, ... }:
let
  place-cursor-at-src = pkgs.fetchFromGitHub {
    owner = "unclechu";
    repo = "place-cursor-at";
    rev = "ffffffffffffffffffffffffffffffffffffffff"; # Git commit hash
    sha256 = "0000000000000000000000000000000000000000000000000000";
  };

  place-cursor-at = pkgs.callPackage place-cursor-at-src {};
in
{
  environment.systemPackages = [ place-cursor-at ];
}

With Stack

See The Haskell Tool Stack.

stack build
stack exec place-cursor-at

You could install place-cursor-at binary to ~/.local/bin directory (make sure you have this directory in your PATH environment variable):

stack install

NixOS note

If you need to work with Stack under NixOS for whatever reason you would have to use --system-ghc in order to make it work. You can manually add --system-ghc to each call of stack or define this alias for your convenience:

alias stack='stack --system-ghc'

Using it as script

You also can run this application as a script (nix-shell script, so you have to install Nix Package Manager first):

src/place-cursor-at.hs

But this application is intended to be used very often (to be run again and again many times) and to be very responsive, so it’s better to precompile it to reduce startup time.

Xinerama note

By default it appears and do its stuff on display where your mouse cursor is. But you can specify which display where it should appear on:

place-cursor-at 1

Or on third display:

place-cursor-at 3

Jump to specific position without GUI

You can immediately jump to specific position of a screen without showing any GUI, like this:

place-cursor-at LT

It’s case-insensitive, this also would work:

place-cursor-at lt

And you also can specify a display you want to jump to:

place-cursor-at lt 1

In any order of the arguments:

place-cursor-at 1 lt

Codes of available positions

| Code | Deciphering   |
| -    | -             |
| LT   | Left-Top      |
| LC   | Left-Center   |
| LB   | Left-Bottom   |
| CT   | Center-Top    |
| CC   | Center-Center |
| CB   | Center-Bottom |
| RT   | Right-Top     |
| RC   | Right-Center  |
| RB   | Right-Bottom  |

Author

Viacheslav Lotsmanov

Contributors

The logo is created by psikoz and some technical adjustments are made by Viacheslav Lotsmanov.

Licenses

  1. place-cursor-atGNU/GPLv3

  2. The logo — Creative Commons — Attribution 4.0 International (CC BY 4.0)

    These files in artwork/logo directory in particular:

Metadata

Version

1.0.1

Executables (1)

  • bin/place-cursor-at

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows

Related (1)