Command line animations based on the state of the system

Overview

shell-emotions

Command line animations based on the state of the system for Linux or Windows 10

The ascii animations were created using a modified version of Joedang's converter

Requirements

Linux

  • Python 2 or 3
  • psutil
  • Bash or Fish

Windows 10

  • Python 3
  • psutil
  • pythonnet | (Optional)
  • OpenHardwareMonitorLib.dll | Note: OpenHardwareMonitor REQUIRES Administrator Access (Optional)
  • Powershell

Workflow for getting the ascii frames

Manual Method

Termimum Method

  • Download modified Termimation
  • Locate gif you want to convert to ascii frames named
  • Run -> ./termimation ./

Adding Animations

  • Create ascii frames using above workflow or
  • Move ascii frames named 0-N to ./assets/frames/
  • Add conditional in state_update() in lib.threading that sets state = emotions[""].id

Configuration

Configurable Parameters in ./conf/cfg.py:

  • frames_path | This is the path of the frames folder where individual folders for each emotion is kept (Default "./assets/frames/")
  • state | This is the starting state of the program (Default 0)
  • welcome_time | Time (sec) for welcome message (Default 1)
  • frame_time | The time before printing next frame (Default 0.2)
  • util_refresh | Time inbetween utilization stat refreshes (Default 5)
  • cpu_lvl_1 | Boundary for low CPU usage (Default 10)
  • cpu_lvl_2 | Boundary for medium CPU usage (Default 30)
  • cpu_lvl_3 | Boundary for high CPU usage (Default 90)
  • cpu_temp_lvl_1 | Boundary for high CPU temperature (Default 80)
  • cpu_temp_lvl_2 | Boundary for very high CPU temperature (Default 90)
  • cpu_temp_lvl_3 | Boundary for CPU throttling temperature (Default 105)
  • cpu_temp_sensor | Sensor to pull CPU Temps from (Default "coretemp")
  • cpu_temp_sensor_win32 | Sensor to pull CPU temps in win32 from (Default "CPU Package")
  • cpu_temp_default | Default fallback CPU temperature (Default 0)
  • mem_bound | Boundary for high memory usage (Default 50)

clean.sh

Use clean.sh file for cleaning undesired characters from the ascii frames

main.py

Functions

shutdown(signum, frame):

The shutdown function handles clean shutdown of the program with "Shutting down..." printout.

main():

The main function deals with signal handling and starts both state update and emote threads.

threading.py

Functions

state_update(thread_name):

The state update thread is a daemon that queries system stats through psutil and updates global state.

emote(thread_name):

The emote thread is a daemon that runs the correct animation based on state continuously.

animation.py

Classes

class Animation:

The Animation class has the properties name, id, file_path, and frames. It will fill frames list upon initialization using input file_path and name.

win32_temp.py

Functions

init_open_hwd_mon():

This function initializes OpenHardwareMonitor by loading OpenHardwareMonitorLib.dll and returning the handle.

get_cpu_pkg_temp(handle)

This function returns cpu package temperature from OpenHardwareMonitor.

Comments
  • Added Animation class

    Added Animation class

    I've refactored the code for animations in my fork of the project. The program now uses the class "animation.py" in the folder "lib" which has the properties name id file_path and frames.

    The constructor of the Animation class imports all ascii frames from ./assets/frames/<name>. In ./assets/frames/<name> the ascii text frames are numbered from 0-N (The animation can be of variable length and the constructor will handle it just fine).

    In the main method, all animation objects are attached as values to an emotion dictionary that uses <name> as the key.

    To add new emotions you just have to create a folder in assets named <name> and add that <name> to the global emotion_names list. Then just add all the frames (named 0-N) into the folder you just created.

    opened by avanishsubbiah 4
  • Refactored Code

    Refactored Code

    Removed some duplicated code and used print instead of os.system() (because its faster and cleaner). I also made the file executeable and added the python header so you can do ./main.py to start it

    opened by mrbesen 4
  • Color Animations generated from Termimum added, with updated Docs

    Color Animations generated from Termimum added, with updated Docs

    Heyo, I added color animations generated from the modified fork of Termimum I made, and updated the docs to include credit to Joedang. Lemme know what you think of the new animations!

    Ex (Awake animation): eyes_example

    opened by avanishsubbiah 1
  • clean.sh optimized

    clean.sh optimized

    I just made all that pipeing into one sed command. The old one could have even created some obscure problems, because it was reading and writing the file at the same time. With this new command this can not happen, because sed knows what it does.

    opened by mrbesen 1
  • Introduce refactored code back into main branch

    Introduce refactored code back into main branch

    After adding color animations, refactored code for the animation storage and addition, features for temperature detection and memory usage collection, etc. The refactored branch needs to be merged back to main (They are getting too distant from each other at this point).

    opened by avanishsubbiah 0
  • Cleaned up threading conflicts and added proper shutdown along with Rage emotion addition and Docs update

    Cleaned up threading conflicts and added proper shutdown along with Rage emotion addition and Docs update

    State modification has been moved into the check_usage(thread_name) function (Now renamed to state_update(thread_name)), which allows for less conflicts where emote would try to read cpu_percent while it was being updated by the check_usage thread. Additionally, going forward as more stats are added they won't have to be global variables shared with emote(thread_name). Instead, the only global variable shared with emote(thread_name) will be state.

    Additionally, before SIGINT would have to be sent twice with two presses of Ctrl-C in order to close both threads with an exception print out. A main function was added to start both threads as daemons and allow for signal handling of SIGINT and SIGTERM to provide a clean exit with a "Shutting Down..." print out instead.

    A rage emotion was added with a modification to the original awake animation to include a vein bulge symbol, and this emotion will appear when cpu_percent is greater than 90%.

    The Docs were updated to included procedure for adding new emotion animations, requirements, main.py function documentation, and a switch from the static image to a GIF that shows the awake eyes animation as an example.

    opened by avanishsubbiah 0
  • Request to merge version with 3 states and 2 threads

    Request to merge version with 3 states and 2 threads

    This version of the main.py file has three different states: asleep, waking up, and fully awake. It switches between these states in a thread running emote() based on utilization stats collected and updated by a second thread running check_usage().

    I plan on replacing the check_usage() function to a state_update() function that synchronously updates state after updating usage stats so that the emote() function does not have as many timing conflicts, and there can be less global variables.

    opened by avanishsubbiah 0
  • Refactor branch

    Refactor branch

    @avanishsubbiah I will create another branch named refactor, in that branch i will create a subdirectory called "lib" and organize the code into objects. I will add argparse to manage command line arguments. You can keep working on the main branch but keep in mind that later on you will have to commit your new changes to the refactor branch too. So we can merge refactor with main.

    enhancement 
    opened by malav097 2
  • License needs to be added

    License needs to be added

    I'm not too familiar with licensing, but I just realized after looking at the termination repository that we need to add a license file to this repo. Maybe GPL 3.0?

    opened by avanishsubbiah 0
  • Need cropped images or specifications to reproduce ascii art

    Need cropped images or specifications to reproduce ascii art

    Following the workflow outlined in the documentation, using the images provided, results in images of different sizing than the original ascii art images provided. If the art was generated via cropped images the images in assets need to be updated to those cropped images. Or if a certain sizing was used that would be useful to know.

    opened by avanishsubbiah 3
  • Generate frames for other types of emotions using the workflow described in the readme

    Generate frames for other types of emotions using the workflow described in the readme

    I am thinking on the best approach to link the animation with the system status (CPU load average, memory and storage). At first we would need at least 3 animations to correlate with 3 different system metric thresholds (maybe happy, normal and sad) any ideas are welcome.

    help wanted good first issue 
    opened by malav097 4
Owner
Simon Malave
I like to walk in the thin line between infrastructure and code.
Simon Malave
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.

Python Fire Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. Python Fire is a s

Google 23.6k Dec 31, 2022
Python composable command line interface toolkit

$ click_ Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It's the "Comm

The Pallets Projects 13.3k Dec 31, 2022
Library for building powerful interactive command line applications in Python

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

prompt-toolkit 8.1k Dec 30, 2022
Cleo allows you to create beautiful and testable command-line interfaces.

Cleo Create beautiful and testable command-line interfaces. Cleo is mostly a higher level wrapper for CliKit, so a lot of the components and utilities

Sébastien Eustace 984 Jan 2, 2023
Color text streams with a polished command line interface

colout(1) -- Color Up Arbitrary Command Output Synopsis colout [-h] [-r RESOURCE] colout [-g] [-c] [-l min,max] [-a] [-t] [-T DIR] [-P DIR] [-d COLORM

nojhan 1.1k Dec 21, 2022
Pythonic command line arguments parser, that will make you smile

docopt creates beautiful command-line interfaces Video introduction to docopt: PyCon UK 2012: Create *beautiful* command-line interfaces with Python N

null 7.7k Dec 30, 2022
Python Command-line Application Tools

Clint: Python Command-line Interface Tools Clint is a module filled with a set of awesome tools for developing commandline applications. C ommand L in

Kenneth Reitz Archive 82 Dec 28, 2022
Corgy allows you to create a command line interface in Python, without worrying about boilerplate code

corgy Elegant command line parsing for Python. Corgy allows you to create a command line interface in Python, without worrying about boilerplate code.

Jayanth Koushik 7 Nov 17, 2022
prompt_toolkit is a library for building powerful interactive command line applications in Python.

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

prompt-toolkit 8.1k Jan 4, 2023
A CLI tool to build beautiful command-line interfaces with type validation.

Piou A CLI tool to build beautiful command-line interfaces with type validation. It is as simple as from piou import Cli, Option cli = Cli(descriptio

Julien Brayere 310 Dec 7, 2022
A minimal and ridiculously good looking command-line-interface toolkit

Proper CLI Proper CLI is a Python package for creating beautiful, composable, and ridiculously good looking command-line-user-interfaces without havin

Juan-Pablo Scaletti 2 Dec 22, 2022
sane is a command runner made simple.

sane is a command runner made simple.

Miguel M. 22 Jan 3, 2023
Typer, build great CLIs. Easy to code. Based on Python type hints.

Typer, build great CLIs. Easy to code. Based on Python type hints. Documentation: https://typer.tiangolo.com Source Code: https://github.com/tiangolo/

Sebastián Ramírez 10.1k Jan 2, 2023
CalcuPy 📚 Create console-based calculators in a few lines of code.

CalcuPy ?? Create console-based calculators in a few lines of code. ?? Installation pip install calcupy ?? Usage from calcupy import Calculator calc

Dylan Tintenfich 7 Dec 1, 2021
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
Periodically check the manuscript state in the scholar one system and send email when finding a new state.

ScholarOne-manuscript-checker Periodically check the manuscript state in the scholar one system and send email when finding a new state. Parameters ne

null 2 Aug 18, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
Create animations for the optimization trajectory of neural nets

Animating the Optimization Trajectory of Neural Nets loss-landscape-anim lets you create animated optimization path in a 2D slice of the loss landscap

Logan Yang 81 Dec 25, 2022