minimalistic command launcher in rust

Related tags

System tools rrun
Overview
https://travis-ci.org/buster/rrun.svg?branch=master

rrun

Note: Apart from the occasional fix, this project is not actively developed anymore. rrun works fine and should run/compile for the time being on rust stable. Alternatives to rrun are gmrun and rofi. Feel free to fork, request ownership or commit pull requests.

rrun is a minimalistic command launcher in rust similar to gmrun. It started as a playground to learn Rust, but since i use it all day for months now, it's probably useful for others as well. It replaced gmrun and gnome-do on my laptop. rrun has few features, it can do bash completion and run commands and that's it. It will also append the commands being run to your bash history.

rrun.gif

Dependencies

GTK3.10+

Installation

You have several options:

  1. download a Debian package from https://github.com/buster/rrun/releases
  2. install from crates.io with "cargo install rrun"
  3. compile yourself with "cargo build"

Usage

  • enter a command and press Return to execute it
  • press TAB for tab completion of available commands
  • Press Ctrl + Return to display the command output in the text field

Set up rrun as command helper on Capslock

I have mapped the unused, needless CapsLock key to some other key and set up Gnome or whatever (i3wm in my case) to launch rrun on keypress.

My ~/.Xmodmap:

remove Lock = Caps_Lock
keysym Caps_Lock = XF86HomePage

Don't forget to run "xmodmap ~/.Xmodmap" after login.

The relevant parts of ~/.i3/config:

bindsym XF86HomePage exec rrun
for_window [title="rrun"] floating enable
exec --no-startup-id xmodmap ~/.Xmodmap

How to build the package

Creation of a cowbuilder image

The build process needs pbuilder/cowbuilder installed in debian (apt-get install cowbuilder pbuilder). A Debian testing buid image can be created with:

sudo cowbuilder --create --distribution testing

Eatmydata Installation

Install eatmydata (on build machine and in the image) to speeding up dpkg (from https://wiki.debian.org/cowbuilder ):

On the build machine:

apt-get install eatmydata

In the build image:

sudo cowbuilder --login --save
apt-get install eatmydata

For eatmydata (>=82-2), add this /etc/pbuilderrc (on the build machine):

if [ -z "$LD_PRELOAD" ]; then
  LD_PRELOAD=libeatmydata.so
else
  LD_PRELOAD="$LD_PRELOAD":libeatmydata.so
fi

export LD_PRELOAD

Package Build Process

The debian package can be built with the following commands:

  • make deb just creates the .deb file without touching the changelog
  • make snapshot creates a snapshot .deb without incrementing the version number (but updating the changelog)
  • make release creates a new release and bumps the minor version number

Contributors

@nightscape @tshepang

Comments
  • Replace hard-coded UI by Glade designed XML

    Replace hard-coded UI by Glade designed XML

    This should make implementing #12 much easier :) No changes to the UI yet. Is the search_entry feature distinction important? If so, I can change the Glade file not to include the Entry/SearchEntry widget and add it from the code (as it was before).

    opened by nightscape 9
  • Nightscape configurable completions

    Nightscape configurable completions

    unfortunately, the bash completion is still in the wrong order. When completing for "whi", it finds "while" first on my computer, but "which" should be before (c comes before l in the alphabet")...

    opened by buster 8
  • Completions can be configured via .toml file

    Completions can be configured via .toml file

    This PR allows specifying completions in a .toml file located in ~/.config/rrun/config.toml. If the file doesn't exist yet, it will be created with a configuration that should be identical to the current behaviour. When there are multiple

    [[completion]]
    command="..."
    

    sections in the .toml file, hitting TAB will iterate over all completions.

    This PR should already allow for using zsh for completions (I have to figure out how though). Next planned steps would be to define a trigger field for each completion (probably a regex) that determines if this completion can be applied and a runner that will be used for the given completion. Then one could e.g. define a trigger like [0-9+-*/.()]+ for numeric calculations and feed those into qcalc directly.

    opened by nightscape 3
  • cargo install rrun fails

    cargo install rrun fails

    The installation via cargo install rrun seems to be broken.

    $ rustc --version
    rustc 1.11.0-nightly (6b4511755 2016-06-14)
    
    
    $ cargo --version
    cargo 0.12.0-nightly (5a26b65 2016-06-14)
    
    $ cargo install rrun
        Updating registry `https://github.com/rust-lang/crates.io-index`
       Compiling bitflags v0.4.0
       Compiling gdk v0.5.0
       Compiling winapi-build v0.1.1
       Compiling gio v0.1.0
       Compiling bitflags v0.5.0
       Compiling strsim v0.4.1
       Compiling vec_map v0.4.0
       Compiling winapi v0.2.7
       Compiling gdk-pixbuf v0.1.0
       Compiling pkg-config v0.3.8
       Compiling utf8-ranges v0.1.3
       Compiling bitflags v0.3.3
       Compiling cairo-rs v0.1.0
       Compiling ansi_term v0.7.2
       Compiling c_vec v1.0.12
       Compiling rustc-serialize v0.3.19
       Compiling kernel32-sys v0.2.2
       Compiling libc v0.2.12
       Compiling log v0.3.6
       Compiling gtk v0.1.0
       Compiling regex-syntax v0.3.3
       Compiling clap v1.5.5
       Compiling itertools v0.4.16
       Compiling memchr v0.1.11
       Compiling thread-id v2.0.0
       Compiling thread_local v0.2.6
       Compiling aho-corasick v0.5.2
       Compiling gio-sys v0.3.1
       Compiling gdk-pixbuf-sys v0.3.1
       Compiling glib-sys v0.3.1
       Compiling cairo-sys-rs v0.3.1
       Compiling gdk-sys v0.3.1
       Compiling atk-sys v0.3.1
       Compiling gtk-sys v0.3.1
       Compiling pango-sys v0.3.1
       Compiling gobject-sys v0.3.1
       Compiling regex v0.1.71
       Compiling glib v0.1.0
       Compiling pango v0.1.0
       Compiling toml v0.1.30
       Compiling env_logger v0.3.3
       Compiling rrun v0.2.0
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:24:5: 24:17 error: unresolved import `gtk::widgets`. There is no `widgets` in `gtk`. Did you mean to use `widget`? [E0432]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:24 use gtk::widgets;
                                                                                  ^~~~~~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:24:5: 24:17 help: run `rustc --explain E0432` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:154:30: 154:52 error: failed to resolve. Could not find `widgets` in `gtk` [E0433]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:154         let completion_list: gtk::widgets::TreeView = builder.get_object("completion_view").unwrap();
                                                                                                            ^~~~~~~~~~~~~~~~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:154:30: 154:52 help: run `rustc --explain E0433` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:155:20: 155:45 error: failed to resolve. Could not find `widgets` in `gtk` [E0433]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:155         let entry: gtk::widgets::SearchEntry = builder.get_object("search_entry").unwrap();
                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:155:20: 155:45 help: run `rustc --explain E0433` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:25:5: 25:25 error: module `signal` is private
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:25 use gtk::signal::Inhibit;
                                                                                  ^~~~~~~~~~~~~~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:51:45: 51:51 error: no method named `unwrap` found for type `gtk::TreeViewColumn` in the current scope
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:51     let column = gtk::TreeViewColumn::new().unwrap();
                                                                                                                          ^~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:52:45: 52:51 error: no method named `unwrap` found for type `gtk::CellRendererText` in the current scope
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:52     let cell = gtk::CellRendererText::new().unwrap();
                                                                                                                          ^~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:149:72: 149:82 error: multiple applicable items in scope [E0034]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:149                 widgets::StyleContext::add_provider_for_screen(&window.get_screen(), &cp, 1);
                                                                                                                                                      ^~~~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:149:72: 149:82 help: run `rustc --explain E0034` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:149:72: 149:82 note: candidate #1 is defined in an impl of the trait `gtk::WidgetExt` for the type `_`
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:149:72: 149:82 note: candidate #2 is defined in an impl of the trait `gtk::WindowExt` for the type `_`
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:166:63: 166:69 error: no method named `unwrap` found for type `gtk::ListStore` in the current scope
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:166     let completion_store = gtk::ListStore::new(&column_types).unwrap();
                                                                                                                                             ^~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:209:25: 209:30 error: the trait bound `str: std::marker::Sized` is not satisfied [E0277]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:209                     let query = entry.get_text().unwrap_or_else(|| panic!("Unable to get string from Entry widget!"));
                                                                                                       ^~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:209:25: 209:30 help: run `rustc --explain E0277` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:209:25: 209:30 note: `str` does not have a constant size known at compile-time
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:209:25: 209:30 note: all local variables must have a statically known size
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:229:46: 229:54 error: mismatched types [E0308]
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:229                 if last_pressed_key.get() == key::Tab {
                                                                                                                            ^~~~~~~~
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:229:46: 229:54 help: run `rustc --explain E0308` to see a detailed explanation
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:229:46: 229:54 note: expected type `i32`
    .cargo/registry/src/github.com-1ecc6299db9ec823/rrun-0.2.0/src/main.rs:229:46: 229:54 note:    found type `u32`
    error: aborting due to 6 previous errors
    error: failed to compile `rrun v0.2.0`, intermediate artifacts can be found at `/tmp/cargo-install.qlPuQqy8lkzh`
    
    Caused by:
      Could not compile `rrun`.
    
    To learn more, run the command again with --verbose.
    
    opened by fneddy 2
  • Replace class mutation with iterator

    Replace class mutation with iterator

    Hi @buster,

    I'm trying to pimp rrun to support custom autocompletions. As a preparatory refactoring, I started out by removing the class mutation of BashAutoCompleter and returning an Iterator instead (which also allows you to do a lot more things with the result). I'm a Rust newbie, so I'm happy about all feedback :+1:

    opened by nightscape 2
  • gdk compile errors

    gdk compile errors

    error: failed to compile `rrun v0.2.1 (https://github.com/buster/rrun#fe6dccdf)`, intermediate artifacts can be found at `/tmp/cargo-install.HGmFlrkrPQNs`
    
    Caused by:
      Multiple packages link to native library `gdk`. A native library can be linked only once.
    
    Package `gdk-sys v0.3.4`
        ... which is depended on by `gdk v0.5.3`
        ... which is depended on by `gtk v0.1.3`
        ... which is depended on by `rrun v0.2.1 (https://github.com/buster/rrun#fe6dccdf)`
    links to native library `gdk`.
    
    Package `gdk-sys v0.5.0`
        ... which is depended on by `gdk v0.7.0`
        ... which is depended on by `rrun v0.2.1 (https://github.com/buster/rrun#fe6dccdf)`
    also links to native library `gdk`.
    
    opened by mmstick 1
  • List completion CLI

    List completion CLI

    This PR adds a simple command line interface which atm can only be used to print completions. You can already use it for completions like this

    cache the_command_type a_query_string
    

    I'll write a more detailed description when I have time :)

    opened by nightscape 1
  • Revert order of completions, first id then text

    Revert order of completions, first id then text

    Hi @buster,

    I'd like to do this change before it's too late: Let's switch the order of arguments that is assumed when reading completions that contain a TAB. We always need an id, so it should be the first argument. The following arguments then are optional and can later be used to include e.g. icons or longer descriptions.

    I've just implemented the caching idea and would like to do this change before anyone starts using the cache and gets surprised because text and id are switched.

    opened by nightscape 1
  • Simple and modular caching

    Simple and modular caching

    There are completions that take too long to be run live every time. A simple form of caching would be nice here. I have an idea that would fit nicely with the current Unix-like "small combinable tools" philosophy: We add a command line option to rrun that doesn't show the GUI but instead runs a completion and prints the returned result string directly to STDOUT. One could then add something like this to the config:

    [[completion]]
    type="cache-request"
    trigger="cache (.*)"
    command="rrun list-completions {}"
    
    [[runner]]
    type="cache-request"
    command="rrun complete {} > ~/.config/rrun/command_{}.cache"
    

    and use the cache by just adding

    [[completion]]
    type="command"
    command="cat ~/.config/rrun/command_*.cache | grep {}"
    

    With some duplication in the config, you could do the same thing for URLs or whatever.

    Note 1: You can already do this manually by running the code from the completion yourself and storing it into a file. The above proposal would just make it a lot more convenient. Note 2: If we additionally write which command was called how often somewhere, one could also easily implement a script that sorts the contents of the .cache files by their usage and get the most frequently used completions first.

    opened by nightscape 1
  • make packaging easier

    make packaging easier

    Since rustis still not packaged for Debian and the whole debian build process is nightmarish and complex, there should be better instructions on how to actually build the debian package.. "make snapshot" and "make local-deb" happens to work for me, but it was non-trivial to set up

    opened by buster 1
  • Only call completion when TAB is pressed

    Only call completion when TAB is pressed

    Hi @buster, me again ;) I didn't think you would see and merge my previous PR so fast and kept amending to the same commit. This is a change that I added after you had already merged. It prevents calling the completion on every keystroke and instead only calls when tab is pressed.

    opened by nightscape 1
  • Invoking runner spawns a process but not the requested app

    Invoking runner spawns a process but not the requested app

    1. Open rrun dialogue
    2. Type in some command
    3. Press Enter

    I can see the spawned process in the list of processes:

    $ ps -o state=,command | grep bash
    R bash -i -c (history -s rrun; history -a) && rrun
    

    but the application itself does not run.

    opened by jtojnar 4
  • Directly choosing a result from the list

    Directly choosing a result from the list

    It would save a little time, if one could directly select an entry from the list view with a shortcut like Ctrl+7. The corresponding code would probably need to go here where we already handle other keys.

    enhancement help wanted 
    opened by nightscape 0
  • get rid of unwrap()

    get rid of unwrap()

    The source code is making use of far too many unwrap() calls. We should handle all return values explicitely and fail with a good and explanatory message if some call doesn't return Ok() (unwrap() just panics with some message that doesn't help at all).

    opened by buster 0
  • Create a nicer UI

    Create a nicer UI

    The current UI is usable, but not really eye-candy ;) Moreover, having only one line for the user-specified query and the results makes selection of completions slower than necessary. I would propose to create a UI similar to Albert and Alfred. I'm not an expert in UI toolkits, but would see the following features as desirable:

    • portability and easy cross-compilation (Linux, Mac, Windows?)
    • stylability (e.g. CSS or similar)
    • easy key listening in text box
    • key listening for global shortcuts
    • low resource consumption
    • high startup speed

    Besides the current GTK UI, QT or Conrod might be good options. Possibly also other candidates from the awesome rust listing.

    @buster Do you see any other desirables or options?

    opened by nightscape 8
  • implement helper shortcuts

    implement helper shortcuts

    I'd be nice to have some shortcuts to act on the content of the text (or interpret the text).

    Ideas: Alt+g -> open browser with content (aka url) Alt+k -> fetch password from keepass (how?) Alt+z -> search/open zim

    Alternative (text field tags): "g:" -> open browser with content (aka url) "kp:" -> fetch password from keepass "ku:" -> fetch user from keepass "z:<text" -> search/open zim for text/key

    opened by buster 3
Releases(v0.2.3)
Owner
null
Performs distributed command execution, written in Rust w/ Tokio

Concurr: Distributed and Concurrent Command Execution, in Rust This project is dual licensed under MIT and Apache 2.0. Originally inspired by the GNU

Michael Murphy 93 Dec 18, 2022
Small command-line JSON Log viewer

fblog A small tool to view json log files. Filter To filter log messages it is possible to use lua fblog -f 'level ~= "info"' # will print all message

null 256 Jan 2, 2023
The next gen ls command

LSD (LSDeluxe) Table of Contents Description Screenshot Installation Configuration External Configurations Required Optional F.A.Q. Contributors Credi

Pierre Peltier 9k Jan 2, 2023
Super-fast command aliases with arguments.

Bonnie Bonnie is a command aliasing tool. If you have a super-long command that you have to run all the time, Bonnie is for you! Just define the comma

arctic_hen7 58 Dec 22, 2022
A modern alternative to watch command

A modern alternative to watch command

Tavo Annus 7 Oct 7, 2022
Yet another fancy watcher. (Rust)

funzzy Yet another fancy watcher. (Inspired by antr / entr) Configure execution of different commands using semantic yaml. # .watch.yaml # list here a

Cristian Oliveira 188 Dec 12, 2022
A modern replacement for ps written in Rust

procs procs is a replacement for ps written in Rust. Documentation quick links Features Platform Installation Usage Configuration Features Output by t

null 3.6k Jan 5, 2023
A more intuitive version of du in rust

Dust du + rust = dust. Like du but more intuitive. Why Because I want an easy way to see where my disk is being used. Demo Install Cargo cargo install

andy.boot 5.5k Jan 8, 2023
Blazing 💥 fast terminal-ui for git written in rust 🦀

Blazing fast terminal client for git written in Rust Features Fast and intuitive keyboard only control Context based help (no need to memorize tons of

Stephan Dilly 11.8k Jan 5, 2023
A simple and fast download accelerator, written in Rust

zou A simple and fast download accelerator, written in Rust Zou is a Snatch fork by @k0pernicus. Snatch is a fast and interruptable download accelerat

Antonin Carette 173 Dec 4, 2022
Fuzzy Finder in rust!

Life is short, skim! Half of our life is spent on navigation: files, lines, commands… You need skim! It is a general fuzzy finder that saves you time.

Jinzhou Zhang 3.7k Jan 4, 2023
A bash-like Unix shell written in Rust

Cicada Unix Shell Cicada is a simple Unix shell written in Rust. Documents Install cicada Environment Variables Cicada Builtins Completion RC File His

Hugo Wang 921 Dec 28, 2022
A library to listen to global hotkeys in Rust

Rust Hotkey A library to listen to global hotkeys in Rust How to use See the examples folder for how to use this library. OS Support This lib aims to

James Birtles 44 Dec 12, 2022
🔮 Futuristic take on hexdump, made in Rust.

hex (hx) Futuristic take on hexdump. hx accepts a file path as input and outputs a hexadecimal colorized view to stdout. $ hx tests/files/alphanumeric

Julian Sitkevich 387 Dec 27, 2022
Cross-platform Rust rewrite of the GNU coreutils

uutils coreutils uutils is an attempt at writing universal (as in cross-platform) CLI utilities in Rust. This repository is intended to aggregate GNU

null 13k Dec 30, 2022
A TUI system monitor written in Rust

NO LONGER MAINTAINED. For a similar program, check out https://github.com/ClementTsang/bottom. ytop Another TUI based system monitor, this time in Rus

Caleb Bassi 2.1k Jan 3, 2023
A rust layered configuration loader with zero-boilerplate configuration management.

salak A layered configuration loader with zero-boilerplate configuration management. About Features Placeholder Key Convension Cargo Features Default

Daniel YU 28 Sep 20, 2022
Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux.

Untrusted IPC with maximum performance and minimum latency. On Rust, on Linux. When is this Rust crate useful? Performance or latency is crucial, and

null 72 Jan 3, 2023
An over-engineered rewrite of pipes.sh in Rust

pipes-rs An over-engineered rewrite of pipes.sh in Rust Installlation macOS Install using Homebrew or download manually from releases. $ brew install

Lucas 301 Dec 30, 2022