Git Product home page Git Product logo

show-cheatsheet's Introduction

Show cheatsheet

Preface

Shell script that displays any image file centered over specified area, either active window or whole display.

The main reason to write this script was to let me me quickly display cheatsheet image of my choice (with this shell shortcuts cheatsheet being the main reason). I wanted to be able to peek the cheatsheet easily at any time, but I couldn't find any existing tool to show me that image in useful way - display it centered over currently actvive (focused) window and be quickly dismissed. This script reads details of currently active window and then steers existing image viewers to show the image centered over that window (or whole display area). Once I had it working, I created global key shortcut in my desktop environment that once hit, started show-cheatsheet and voila - I had my cheatsheet hovering over my currently used terminal window (see Integration for how to do the same in KDE).

This script shall work with any modern window manager.

Requirements

The following packages are required:

Optional but recommended:

All these should be installable by your package manager. For Debian/Ubuntu/Kubuntu do:

sudo apt install -y imagemagick xdotool feh

Usage

show-cheatsheet [-h] [-c MODE] [-v VIEWER] FILE

Supported arguments are:

  • -h displays help page
  • -c MODE sets centering mode of displayed image. Supported options are:
    • window or w to open image centered over currently active window (default)
    • display or d to open image centered over whole display (screen) area
  • -v VIEWER sets viewer to be used. If not specified, tries to find one automatically. Supported viewers are:
  • FILE image file to be displayed

Viewers

Support for any new image viewer can be easily added, however only apps that support --geometry type of argument or are offering any other way control placement of their opened window are of any use. It'd be also handy if viewer could be dismissed with just ECS key but that's optional.

Examples

To display bash-cheatsheet.png over currently active terminal window:

show-cheatsheet bash-cheatsheet.png

This assumes cheatsheet image is in your current working directory and show-cheatsheet is in your $PATH. If neither is the case, use full paths.

To make image display centered:

show-cheatsheet -c window bash-cheatsheet.png

To use display utility instead of feh in case both are installed

show-cheatsheet -v display bash-cheatsheet.png

Integration

Using script with global shortcut in KDE:

  • Run kmenuedit
  • Create New item... and name it as you like (i.e. "Shell cheatsheet")
  • Set <PATH-TO>/show-cheatsheet <PATH-TO>/bash-cheatsheet.png as Command
  • Set Current shortcut key on Advanced tab to whatever you like
  • Save.

You can now i.e. open new Konsole window and try your shortcut to see if it makes cheatsheet image pop up.


License

  • Written and copyrighted ©2019-2021 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
  • This is open-sourced software licensed under the MIT license

show-cheatsheet's People

Contributors

marcinorlowski avatar

Watchers

 avatar  avatar

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.