Giter Site home page Giter Site logo

will8211 / unimatrix Goto Github PK

View Code? Open in Web Editor NEW
1.6K 30.0 157.0 2.03 MB

Python script to simulate the display from "The Matrix" in terminal. Uses half-width katakana unicode characters by default, but can use custom character sets. Accepts keyboard controls while running. Based on CMatrix.

License: GNU General Public License v3.0

Python 95.74% Nix 4.26%

unimatrix's Introduction

UniMatrix

Python script to simulate the display from "The Matrix" in terminal. Uses half-width katakana unicode characters by default, but can use custom character sets. Accepts keyboard controls while running.

Based on CMatrix by Chris Allegretta and Abishek V. Ashok. The following option should produce virtually the same output as CMatrix:

$ unimatrix -n -s 96 -l o

Install

Linux users can use curl to install:

sudo curl -L https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -o /usr/local/bin/unimatrix
sudo chmod a+rx /usr/local/bin/unimatrix

If you do not have curl, you can alternatively use a recent wget:

sudo wget https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -O /usr/local/bin/unimatrix
sudo chmod a+rx /usr/local/bin/unimatrix

You can also install it with pip:

pip install git+https://github.com/will8211/unimatrix.git

Users of Arch-based distros can get it from the AUR as unimatrix-git, although it might not be the most recent version.

User install (without sudo)

With curl:

curl -L https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -o ~/.local/bin/unimatrix
chmod a+rx ~/.local/bin/unimatrix

With wget:

wget https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -O ~/.local/bin/unimatrix
chmod a+rx ~/.local/bin/unimatrix

Nix

Users of NixOS and Nix Package Manager can use fetchGit in both configuration.nix and home-manager to install it

# configuration.nix
{ config, pkgs, lib, ... }:

let
  unimatrix = import (builtins.fetchGit {
    url = "https://github.com/will8211/unimatrix";
    name = "unimatrix";
  }) { inherit pkgs; };
in
{
  environment.systemPackages = [
    unimatrix
    # ... Rest of your packages
  ];
  # ... Rest of your configuration
}

# home.nix
{ config, pkgs, ... }:

let
  unimatrix = import (builtins.fetchGit {
    url = "https://github.com/will8211/unimatrix";
    name = "unimatrix";
  }) { inherit pkgs; };
in
{
  home.packages = [
    unimatrix
    # ... Rest of your packages
  ];
  # ... Rest of your configuration
}

It's also possible to install it with flakes in home-manager or configuration.nix

# flake.nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.unimatrix.url = "github:will8211/unimatrix";
}

Screenshots

Default settings:

screenshot1

Blue with custom character set 'Linux' ($ unimatrix -c blue -u 'Linux'):

screenshot2

Yellow with alternate character set: Emoji ($ unimatrix -c yellow -l 'e'):

screenshot3

Emulating CMatrix (unimatrix -n -s 96 -l 'o'):

screenshot4

Manual

USAGE
  unimatrix [-a] [-b] [-c COLOR] [-f] [-g COLOR] [-h] [-i] [-l CHARACTER_LIST]
            [-n] [-o] [-s SPEED] [-u CUSTOM_CHARACTERS]

OPTIONAL ARGUMENTS
  -a                   Asynchronous scroll. Lines will move at varied speeds.

  -b                   Use only bold characters

  -c COLOR             One of: green (default), red, blue, white, yellow, cyan,
                       magenta, black

  -f                   Enable "flashers," characters that continuously change.

  -g COLOR             Background color (See -c). Defaults to keeping
                       terminal's current background.

  -h                   Show this help message and exit

  -i                   Ignore keyboard input

  -l CHARACTER_LIST    Select character set(s) using a string over letter
                       codes (see CHARACTER SETS below.)

  -n                   Do not use bold characters (overrides -b)

  -o                   Disable on-screen status

  -s SPEED             Integer up to 100. 0 uses a one-second delay before
                       refreshing, 100 uses none. Use negative numbers for
                       even lower speeds. Default=85

  -t TIME              Exit the process after TIME seconds

  -u CUSTOM_CHARACTERS Your own string of characters to display. Enclose in
                       single quotes ('') to escape special characters. For
                       example: -u '#$('

  -w                   Single-wave mode: Does a single burst of green rain,
                       exits. You can put in a .bashrc file to run when your
                       terminal launches. Works well with speed at 95. See -i
                       to not block keyboard input during visual effect.

LONG ARGUMENTS
  -a --asynchronous
  -b --all-bold
  -c --color=COLOR
  -f --flashers
  -g --bg-color=COLOR
  -h --help
  -i --ignore-keyboard
  -l --character-list=CHARACTER_LIST
  -s --speed=SPEED
  -n --no-bold
  -o --status-off
  -t --time
  -u --custom-characters=CUSTOM_CHARACTERS
  -w --single-wave

CHARACTER SETS
  When using '-l' or '--character-list=' option, follow it with one or more of
  the following letters:

  a   Lowercase alphabet
  A   Uppercase alphabet
  c   Lowercase Russian Cyrillic alphabet
  C   Uppercase Russian Cyrillic alphabet
  e   A few common emoji ( ☺☻✌♡♥❤⚘❀❃❁✼☀✌♫♪☃❄❅❆☕☂★ )
  g   Lowercase Greek alphabet
  G   Uppercase Greek alphabet
  k   Japanese katakana (half-width)
  m   Default 'Matrix' set, equal to 'knnssss'
  n   Numbers 0-9
  o   'Old' style non-unicode set, like cmatrix. Equal to 'AaSn'
  p   Klingon pIqaD (requires 'Horta' family font)*
  P   Klingon pIqaD (requires 'Klingon-pIqaD' or 'Code2000' family font)*
  r   Lowercase Roman numerals ( mcclllxxxxvvvvviiiiii )
  R   Uppercase Roman numerals ( MCCLLLXXXXVVVVVIIIIII )
  s   A subset of symbols actually used in the Matrix films ( -=*_+|:<>" )
  S   All common keyboard symbols ( `-=~!z#$%^&*()_+[]{}|\;':",./<>?" )
  u   Custom characters selected using -u switch

  For example: '-l naAS' or '--character-list=naAS' will give something similar
  to the output of the original cmatrix program in its default mode.
  '-l ACG' will use all the upper-case character sets. Use the same
  letter multiple times to increase the frequency of the character set. For
  example, the default setting is equal to '-l knnssss'.

  * With most modern Linux terminals (gnome-terminal, konsole, lxterminal,
    xfce4-terminal, mate-terminal) simply having the font installed system-wide
    is enough. The terminal will fall back to it for the Klingon, meaning that
    you don't have to select it in your terminal settings. 'Horta' seems not to
    work in Konsole. Fonts may need to be set manually as fallbacks in
    .Xresources for older terminals, such as urxvt and xterm.

KEYBOARD CONTROL
  SPACE, CTRL-c or q   exit
  - or LEFT            decrease speed by 1
  + or RIGHT           increase speed by 1
  [ or DOWN            decrease speed by 10
  ] or UP              increase speed by 10
  a                    toggle asynchronous scrolling
  b                    cycle through bold character options
                           (bold off-->bold on-->all bold)
  f                    toggle flashing characters
  o                    toggle on-screen status
  1 to 9               set color: (1) Green   (2) Red   (3) Blue     (4) White
                                  (5) Yellow  (6) Cyan  (7) Magenta  (8) Black
                                  (9) Terminal default
  ! to (               set background color (same colors as above, but pressing
                           shift + number)

EXAMPLES
  Mimic default output of cmatrix (no unicode characters, works in TTY):
    $ unimatrix -n -s 96 -l o

  Use the letters from the name of your favorite operating system in bold blue:
    $ unimatrix -B -u Linux -c blue

  Use default character set, plus dollar symbol (note single quotes around
      special character):
    $ unimatrix -l knnssssu -u '$'

  No bold characters, slowly, using emojis, numbers and a few symbols:
    $ unimatrix -n -l ens -s 50

License

Unimatrix is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Unimatrix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses/ for more details.

unimatrix's People

Contributors

alexislefebvre avatar avrahambenaram avatar cabalist avatar crclark96 avatar dslachut avatar gebbber avatar joe-sullivan avatar leksus-04 avatar pylipp avatar timesqueezer avatar will8211 avatar zhukovalexander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unimatrix's Issues

Character/Font size adjustment?

Running this in Terminator. I can't seem to find a way to increase the size of the characters. I have adjusted the font size in the settings menu for Terminator and they are fine. When I start Unimatrix the characters are much smaller. Searching hasn't helped. Didn't see anything in the help menu. Have I missed something? thanks.

OS: Ubuntu 20.04.3 LTS x86_64 
Kernel: 5.4.0-84-generic 
Uptime: 3 days, 18 hours, 3 mins 
Packages: 2705 (dpkg), 12 (snap) 
Shell: bash 5.0.17 
Resolution: 1920x1080, 1920x1080 
DE: Plasma 

WM: KWin
WM Theme: plastik
Theme: Gently [Plasma], Breeze [GTK2/3]
Icons: Breeze-Blur-Glassy Dark [Plasma], Breeze-Blur-Glassy Dark [GTK2/3]
Terminal: terminator
CPU: AMD Ryzen 5 3400G (8) @ 4.000GHz
GPU: NVIDIA GeForce RTX 2060
Memory: 5116MiB / 64246MiB

Background colour does not change at once, changes gradually.

To recreate:
start with black characters and black background:
python3 unimatrix.py -c black -g black

now change background to another color, for example by pressing
!

Screenshot_unimatrix
Screenshot of behaviour

The color does not change at once, but rather change with incoming characters.

The behavior was easy to reproduce.

[Suggestion] Rainbow mode (as in Cmatrix 2.0)

I really appreciate the work being done here on Unimatrix.

Is there any chance at all that a Rainbow mode will be included, like in Cmatrix v.2.0?

I think this is an extremely cool variation that is pretty obvious for special occasions (like New Year). And the combination of the custom character sets of Unimatrix with Rainbow mode would offer some extremely exciting possibilities! 😎

Unicode not displaying properly on SSH Ubuntu

I can see the japanese characters fine when I open the python file, I can print them out to the terminal using curses in python3 manually, but running the script just produces weird ~H and ~5, and so on, in their place. I'm SSH'ed into a Ubuntu box and everything is installed properly from what I can tell. Any ideas?

Feature Request: Alt Directional Scrolling

Request a argument be added to have text scroll from bottom to top, left to right and right to left in addition to the default top to bottom.

This would take an already awesome program and distinguish it especially on things like i3 with multiple terminals, terminator, etc...

Not working on Windows 10 (Anaconda Python distribution)

Use of another library than curses would fix it, see paragraph 5: https://docs.python.org/3.3/howto/curses.html

C:\Users\Adam Huxley>unimatrix -n -s 96 -l o
Traceback (most recent call last):
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\Scripts\unimatrix-script.py", line 11, in <module>
    load_entry_point('unimatrix==0.1.dev64+gcd04928', 'console_scripts', 'unimatrix')()
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 565, in load_entry_point
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2598, in load_entry_point
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2258, in load
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\site-packages\setuptools-27.2.0-py3.6.egg\pkg_resources\__init__.py", line 2264, in resolve
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\site-packages\unimatrix.py", line 28, in <module>
    import curses
  File "C:\Users\Adam Huxley\Anaconda3\envs\py36\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'

Intense CPU when run unimatrix?

I monitor cpu with "watch sensors" and notice cpu core i7 (4 core) has increased at least 6-7 celsius (51,52 to 57,58)

I use unimatrix-git from aur (archlinux) and run "unimatrix -n -l ens -s 96" with "st" terminal.

I also observe less cpu contest with cmatrix than unimatrix.

So what's the problem with unimax? anyway if someone can help to translate "unimatrix -n -l ens -s 96" to cmatrix would be appreciated.

Feature request: dynamic characters

When the terminal shows a character, it stays there until the wave fades, it would be cool to have dynamic characters by changing them every second or so.

[Suggestion] Fading trails

Thanks for the awesome application!

I'm curious if curses allows you to fade out characters that are replaced/erased or even apply some transparency or fading in sync with the removal of trails.

Just a thought.

Async mode?

Is there an option for async update? i.e make it so lines update at different rates.

Remove images from the repository

You don't have to have the image files inside the repository.

Steps to link images:

  1. Copy an image to the clipboard
  2. Create a new issue (you don't have to submit the issue later on)
  3. Paste the image to the text area
  4. "Uploading" should be displayed
  5. A link is created that should look something like this:
    ![image](https://user-images.githubusercontent.com/3453076/35476422-c8b16542-03af-11e8-99f3-ebc77e15c60f.png)
  6. Use this link in your ReadMe file
  7. Discard the issue (the link to the image will still work)

term lock

following #2 but not quite:

I usually like to set screen lock (and often screensaver too) explicitly : I don't like such tools to interfere with my work (reading a document, watching misc media, contemplating code).

using unimatrix as a term lock would be cool ; I started looking into it but I'm not quite sure where to put the code

basically, desired behaviour is "show a matrix until ctrl+Z is pressed ; then request password else restart (and log failed attempts, possibly with webcam shot)"

vlock program can be used as a locker, instead of re-inventing the wheel : https://linux.die.net/man/1/vlock

Not work in iTerm2 or Terminal.app in macOS

At first I didn't know why not show characters correctly or properly, then I read your description for -l option in --help of unimatrix after that I find out that in macOS the Icon need to be set in terminal .

But after set those fonts in terminal setting and iTerm2 both, again the characters not show correctly like your first screenshot

iTerm2


Bug

Terminal.app macOS Default


Bug-2

Fonts not install automatically with setup they need installation manually in macOS

Thanks in ADV for great effect tool

Setting background colors using non-QWERTY keyboard

The keys for switching background color are based on the QWERTY-layout:

unimatrix/unimatrix.py

Lines 508 to 525 in cd04928

elif kp == ord('!'):
self.set_bg_color('Green')
elif kp == ord('@'):
self.set_bg_color('Red')
elif kp == ord('#'):
self.set_bg_color('Blue')
elif kp == ord('$'):
self.set_bg_color('White')
elif kp == ord('%'):
self.set_bg_color('Yellow')
elif kp == ord('^'):
self.set_bg_color('Cyan')
elif kp == ord('&'):
self.set_bg_color('Magenta')
elif kp == ord('*'):
self.set_bg_color('Black')
elif kp == ord('('):
self.set_bg_color('default')

For me (QWERTZ-user), the corresponding row is !"§$%&/(). Is it easy to detect the actual ID of the key being pressed rather than the symbol mapped to it? Expanding the current mapping does not make sense because f.i. ( is on the German 8 but on the English 9.

Anyways, not a big deal because I probably won't be switching colors all day long.

Braille symbols are cool

'B': '⠀⢀⠠⢠⠐⢐⠰⢰⠈⢈⠨⢨⠘⢘⠸⢸⡀⣀⡠⣠⡐⣐⡰⣰⡈⣈⡨⣨⡘⡸⣘⣸⠄⢄⠤⢤⠔⢔⠴⢴⠌⢌⠬⢬⠜⢜⠼⢼⡄⣄⡤⣤⡔⣔⡴⣴⡌⣌⡬⣬⡜⣜⡼⣼⠂⢂⠢⢢⠒⢒⠲⢲⠊⢊⠪⢪⠚⢚⠺⢺⡂⣂⡢⣢⡒⣒⡲⣲⡊⣊⡪⣪⡚⣚⡺⣺⠆⢆⠦⢦⠖⢖⠶⢶⠎⢎⠮⢮⠞⢞⠾⢾⡆⣆⡦⣦⡖⣖⡶⣶⡎⣎⡮⣮⡞⣞⡾⣾⠁⢁⠡⢡⠑⢑⠱⠉⢉⠩⢩⠙⢙⠹⢱⢹
⣁⡡⣡⡑⣑⡱⣱⡉⣉⡩⣩⡙⣙⡹⣹⠅⢅⠥⢥⠕⢕⠵⢵⠍⢍⠭⢭⠝⢝⠽⢽⡅⣅⡥⣥⡕⣕⡵⣵⡍⣍⡭⣭⡝⣝⡽⣽⠃⢃⠣⢣⠓⢓⠳⢳⠋⢋⠫⢫⠛⢛⠻⢻⡃⣃⡣⣣⡓⣓⡳⣳⡋⣋⡫⣫⡛⣛⡻⣻⠇⢇⠧⢧⠗⢗⠷⢷⠏⢏⠯⢯⠟⢟⠿⢿⡇⣇⡧⣧⡗⣗⡷⣷⡏⣏⡯⣯⡟⣟⡿⣿',

More exit options

Thank you for this awesome piece of software!

I'm using unimatrix as my screensaver in my hyprland desktop. If someone is interested how, my config is the following:

exec-once = swayidle -w timeout 600 'foot unimatrix'
windowrule=fullscreen,^(foot)$

My first world problem is that I need to push the esc key or spacebar to exit. I'd like to have a bit more options for that:

  • Any key
  • Key(s) defined as an argument
  • Mouse events, including moving mouse if at all possible

Thank you if you even consider these! I'm happy with the software as-is anyway.

Change symbol size?

It appears that symbol size is not linked to terminal symbols size, is it possible to change it?

Invalid Escape Sequence

Not sure if this matters (because it still seems to run well), but when running, this is dumped to the terminal:

/usr/local/bin/unimatrix:32: SyntaxWarning: invalid escape sequence '\;'
  help_msg = '''
/usr/local/bin/unimatrix:231: SyntaxWarning: invalid escape sequence '\;'
  '`-=~!@#$%^&*()_+[]{}|\;\':",./<>?"',
/usr/local/bin/unimatrix:237: SyntaxWarning: invalid escape sequence '\;'
  'S': '`-=~!@#$%^&*()_+[]{}|\;\':",./<>?"',

Value error on first run

Ubuntu 14.04
Python 2.7.6

After following the install and run:

sudo curl -L https://raw.githubusercontent.com/will8211/unimatrix/master/unimatrix.py -o /usr/local/bin/unimatrix
sudo chmod a+rx /usr/local/bin/unimatrix
unimatrix -n -s 96 -l o

I get this error:

Traceback (most recent call last):
  File "/usr/local/bin/unimatrix", line 613, in <module>
    main()
  File "/usr/local/bin/unimatrix", line 608, in main
    curses.wrapper(_main)
  File "/usr/lib/python3.4/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/bin/unimatrix", line 555, in _main
    if key.get():
  File "/usr/local/bin/unimatrix", line 407, in get
    chr_kp = chr(kp).lower()
ValueError: chr() arg not in range(0x110000)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.