Giter VIP home page Giter VIP logo

rofi-qalc's Introduction

rofi-qalc

Run calculations using libqalculate from a rofi menu.

Compared to rofi-calc, which calls the libqalculate CLI, rofi-qalc interfaces with the qalculate library.

This provides a number of benefits:

  • Plotting works --- a single GNUplot window is updated in the background;
  • Variables can be used --- but see the note at the end of this section;
  • Marginally faster --- while not a goal of mine, maybe it matters to someone else.

Not very well tested as of yet, but give it a try if you missed any of the same features I did. Uses the same history file as rofi-calc, so if you have anything important there then back it up just-in-case.

A note on variables: since rofi doesn't provide a way to clear the filter textbox contents then using variables is a bit iffy when disabling the filter auto-clear. To use variables you first must type the expression, e.g. ten = 10 and then clear the textbox by pressing Ctrl-F.

When you clear the textbox by deleting the text gradually then rofi will at some point call the rofi-qalc mode with ten =, which is parsed by libqalculate as ten = 0, zeroing out the variable.

Variables are not persistent throughout multiple sessions.

Building

First install libqalculate and rofi, as this project depends on them.

If you're using an older version of rofi (not built from next branch) then you'll also need to set the option use_rofi_next to false during config.

# Generate project files
meson setup build \
    --buildtype=release \
    --optimization=3 \
    -Dstrip=true \
    -Dlibdir=lib/rofi \
    -Dprefix=/usr
# If using older rofi then also add:
#   -Duse_rofi_next=false

# Compile the project
meson compile -C build

Arch Linux users can make use of the provided PKGBUILD file and install the resulting package.

Running

To try out rofi-qalc you can provide the plugin search path as a command line argument, e.g.:

cd /path/to/rofi-qalc
# configure, build, etc..
rofi -plugin-path ./build -show "qalc"

For development purposes it might be worthwhile to enable logging for the rofi-qalc module, e.g.:

G_MESSAGES_DEBUG=rq rofi -show "qalc"

Usage

Enter your expression in the filter box.

Select the "Add to history" option to add the result to history. Ctrl-Enter on the "Add to history" option will add the result to history without saving it (will only be displayed during current session, indicated by (tmp) prefix).

Command-line arguments

This mode supports the following command-line arguments:

  • -eval-timeout-ms --- evaluation timeout passed to libqalculate;
  • -no-history --- disables history file access;
  • -automatic-save-to-history --- auto-save last entered expression to history when quitting;
  • -history-only-save-results --- disables saving of expressions to history (e.g. instead of 2*10 = 20 the history will show just 20);
  • -history-length --- maximum number of lines of history to keep;
  • -no-auto-clear-filter --- disables automatic clearing of the filter textbox;

rofi-qalc's People

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.