Code Monkey home page Code Monkey logo

anyrun's Introduction

Anyrun

A wayland native krunner-like runner, made with customizability in mind.

Features

  • Style customizability with GTK+ CSS
  • Can do basically anything
    • As long as it can work with input and selection
    • Hence the name anyrun
  • Easy to make plugins
    • You only need 4 functions!
    • See Rink for a simple example. More info in the documentation of the anyrun-plugin crate.
  • Responsive
    • Asynchronous running of plugin functions
  • Wayland native
    • GTK layer shell for overlaying the window
    • data-control for managing the clipboard

Usage

Dependencies

Anyrun mainly depends various GTK libraries, and rust of course for building the project. Rust you can get with rustup. The rest are statically linked in the binary. Here are the libraries you need to have to build & run it:

  • gtk-layer-shell (libgtk-layer-shell)
  • gtk3 (libgtk-3 libgdk-3)
  • pango (libpango-1.0)
  • cairo (libcairo libcairo-gobject)
  • gdk-pixbuf2 (libgdk_pixbuf-2.0)
  • glib2 (libgobject-2.0 libgio-2.0 libglib-2.0)

Installation

Packaging status

Nix

You can use the flake:

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    anyrun.url = "github:Kirottu/anyrun";
    anyrun.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, anyrun }: let
  in {
    nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
      # ...

      environment.systemPackages = [ anyrun.packages.${system}.anyrun ];

      # ...
    };
  };
}

The flake provides multiple packages:

  • anyrun (default) - just the anyrun binary
  • anyrun-with-all-plugins - anyrun and all builtin plugins
  • applications - the applications plugin
  • dictionary - the dictionary plugin
  • kidex - the kidex plugin
  • randr - the randr plugin
  • rink - the rink plugin
  • shell - the shell plugin
  • stdin - the stdin plugin
  • symbols - the symbols plugin
  • translate - the translate plugin
  • websearch - the websearch plugin

home-manager module

We have a home-manager module available at homeManagerModules.default. You use it like this:

{
  programs.anyrun = {
    enable = true;
    config = {
      plugins = [
        # An array of all the plugins you want, which either can be paths to the .so files, or their packages
        inputs.anyrun.packages.${pkgs.system}.applications
        ./some_plugin.so
        "${inputs.anyrun.packages.${pkgs.system}.anyrun-with-all-plugins}/lib/kidex"
      ];
      x = { fraction = 0.5; };
      y = { fraction = 0.3; };
      width = { fraction = 0.3; };
      hideIcons = false;
      ignoreExclusiveZones = false;
      layer = "overlay";
      hidePluginInfo = false;
      closeOnClick = false;
      showResultsImmediately = false;
      maxEntries = null;
    };
    extraCss = ''
      .some_class {
        background: red;
      }
    '';

    extraConfigFiles."some-plugin.ron".text = ''
      Config(
        // for any other plugin
        // this file will be put in ~/.config/anyrun/some-plugin.ron
        // refer to docs of xdg.configFile for available options
      )
    '';
  };
}

You might also want to use the binary cache to avoid building locally.

nix.settings = {
    builders-use-substitutes = true;
    # substituters to use
    substituters = [
        "https://anyrun.cachix.org"
    ];

    trusted-public-keys = [
        "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s="
    ];
};

Manual installation

Make sure all of the dependencies are installed, and then run the following commands in order:

git clone https://github.com/Kirottu/anyrun.git # Clone the repository
cd anyrun # Change the active directory to it
cargo build --release # Build all the packages
cargo install --path anyrun/ # Install the anyrun binary
mkdir -p ~/.config/anyrun/plugins # Create the config directory and the plugins subdirectory
cp target/release/*.so ~/.config/anyrun/plugins # Copy all of the built plugins to the correct directory
cp examples/config.ron ~/.config/anyrun/config.ron # Copy the default config file

Plugins

Anyrun requires plugins to function, as they provide the results for input. The list of plugins in this repository is as follows:

  • Applications
    • Search and run system & user specific desktop entries.
  • Symbols
    • Search unicode symbols.
  • Rink
    • Calculator & unit conversion.
  • Shell
    • Run shell commands.
  • Translate
    • Quickly translate text.
  • Kidex
    • File search provided by Kidex.
  • Randr
    • Rotate and resize; quickly change monitor configurations on the fly.
    • TODO: Only supports Hyprland, needs support for other compositors.
  • Stdin
    • Turn Anyrun into a dmenu like fuzzy selector.
    • Should generally be used exclusively with the --plugins argument.
  • Dictionary
    • Look up definitions for words
  • Websearch
    • Search the web with configurable engines: Google, Ecosia, Bing, DuckDuckGo.

Configuration

The default configuration directory is $HOME/.config/anyrun the structure of the config directory is as follows and should be respected by plugins:

- anyrun
  - plugins
    <plugin dynamic libraries>
  config.ron
  style.css
  <any plugin specific config files>

The default config file contains the default values, and annotates all configuration options with comments on what they are and how to use them.

Styling

Anyrun supports GTK+ CSS styling. The names for the different widgets and widgets associated with them are as follows:

  • entry: The entry box
    • GtkEntry
  • window: The window
    • GtkWindow
  • main: "Main" parts of the layout
    • GtkListBox: The main list containing the plugins
    • GtkBox: The box combining the main list and the entry box
  • plugin: Anything for the entire plugin
    • GtkLabel: The name of the plugin
    • GtkBox: The different boxes in the plugin view
    • GtkImage: The icon of the plugin
  • match: Widgets of a specific match
    • GtkBox: The main box of the match and the box containing the title and the description if present
    • GtkImage: The icon of the match (if present)
  • match-title: Specific for the title of the match
    • GtkLabel
  • match-desc: Specific for the description of the match
    • GtkLabel

Arguments

The custom arguments for anyrun are as follows:

  • --config-dir, -c: Override the configuration directory

The rest of the arguments are automatically generated based on the config, and can be used to override configuration parameters. For example if you want to temporarily only run the Applications and Symbols plugins on the top side of the screen, you would run anyrun --plugins libapplications.so --plugins libsymbols.so --position top.

Plugin development

The plugin API is intentionally very simple to use. This is all you need for a plugin:

Cargo.toml:

#[package] omitted
[lib]
crate-type = ["cdylib"] # Required to build a dynamic library that can be loaded by anyrun

[dependencies]
anyrun-plugin = { git = "https://github.com/Kirottu/anyrun" }
abi_stable = "0.11.1"
# Any other dependencies you may have

lib.rs:

use abi_stable::std_types::{RString, RVec, ROption};
use anyrun_plugin::*;

#[init]
fn init(config_dir: RString) {
  // Your initialization code. This is run in another thread.
  // The return type is the data you want to share between functions
}

#[info]
fn info() -> PluginInfo {
  PluginInfo {
    name: "Demo".into(),
    icon: "help-about".into(), // Icon from the icon theme
  }
}

#[get_matches]
fn get_matches(input: RString) -> RVec<Match> {
  // The logic to get matches from the input text in the `input` argument.
  // The `data` is a mutable reference to the shared data type later specified.
  vec![Match {
    title: "Test match".into(),
    icon: ROption::RSome("help-about".into()),
    use_pango: false,
    description: ROption::RSome("Test match for the plugin API demo".into()),
    id: ROption::RNone, // The ID can be used for identifying the match later, is not required
  }].into()
}

#[handler]
fn handler(selection: Match) -> HandleResult {
  // Handle the selected match and return how anyrun should proceed
  HandleResult::Close
}

And that's it! That's all of the API needed to make runners. Refer to the plugins in the plugins folder for more examples.

anyrun's People

Contributors

abenz1267 avatar bennydioxide avatar benoitlouy avatar cybergaz avatar ddogfoodd avatar eriedaberrie avatar flrian avatar horriblename avatar ivordir avatar jakestanger avatar jennydaman avatar just1602 avatar kirottu avatar loqusion avatar n3oney avatar notashelf avatar pbzweihander avatar repomansez avatar uttarayan21 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

anyrun's Issues

mismatched types, compiling randr

the build fails, because randr can't be compiled.
here the err:

error[E0308]: mismatched types
 --> plugins/randr/src/lib.rs:6:14
  |
6 | fn init() -> Box<dyn Randr> {}
  |    ----      ^^^^^^^^^^^^^^ expected struct `Box`, found `()`
  |    |
  |    implicitly returns `()` as its body has no tail or `return` expression
  |
  = note: expected struct `Box<(dyn Randr + 'static)>`
          found unit type `()`

Community plugin contributions & versioning

So there are a few things that should be addressed as Anyrun becomes more popular and more users & developers flock in.

The first of them is community contributed plugins. Adding them into the main repository in the long term is probably not feasible, some of them may be specialized and not really something the average user may need. They are also a maintenance burden where generally the maintenance of the plugins falls on me to handle after they've been merged, even if I am not that experienced with the codebase of the plugin.

The second issue is versioning. The approach of just making everyone use the latest code at all times (like anyrun-git on the AUR) has worked fine-ish for now but with more complexity and moving pieces, the risks of something breaking down accidentally is much higher and could affect well, everyone who keeps their system up to date. There are a few ways to go about this:

  • Versioning Anyrun and all the plugins included in this repo with the same version number, and all bumped simultaneously. This would be easier regarding packaging and maintaining as everything would basically continue as they would continue as they already have.
  • Versioning (and hence also packaging) each plugin and Anyrun separately, so plugins can get updated at their own pace and target a version of Anyrun.

I would really appreciate any feedback and suggestions on this matter, so any ideas you may have are welcome in this discussion.

home-manager module fails build on certain systems

From what I can see these two lines make assumptions about configuration that is not present on all systems.

If that's the case, the error 'config.xdg.configFile' is undefined is thrown.

I fixed it by forking this repo and changing this line.

However that only works if something like the following is defined somewhere else in the config:

{ config, options, lib, ... }:

with lib;

{
  options = {
    home = {
      programs = mkOption {};
      xdg = mkOption {};
    };
  };
  config = {
    home-manager.users."alice" = {
      programs = mkAliasDefinitions options.home.programs;
      xdg = mkAliasDefinitions options.home.xdg;
    };
  };
}

[Feature suggestion] Selection modifier keys

It would be really cool if a selection can react differently to different inputs.

Like Shift-Enter, Control-C etc.

For example, selecting a file:

  • Enter: Opens the file
  • Shift-Enter: Opens the file's location
  • Alt-Enter: Open the file with sudo
  • Control-C: Copy the file
  • Control-X: Cut the file

For plugins which show open windows:

  • Control-Q: Close window
  • Control-1: Move to workspace 1 etc

It would also make sense then to make plugins configurable, so that you can specify the keybindings for them and provide launch options.
Then it would be possible to open the same file with different apps based on the input, which would be really cool

Password selector with pass?

Hello!

I was wondering if it were possible to add pass support to anyrun. It would be mighty handy!

Best,
KSH

Problems with Websearch Plugin

I saw the new websearch plugin, was excited and installed it. There I encountered two problems:

  1. With the default configuration there are two tabs opened with each query:
    • One with right google search
    • One with the url "https://{query}"
    • The CLI also prints two times the exact same messaege that its opening something in the current browser session
  2. I have trouble configuring a custom search engine or it doesnt work (See configuration below). Can you provide a working one and update the example configuration in the corresponding Readme which explains it a little better for users without Rust/RON experience?
Config(
  prefix: "#",
  engines: [Google, Custom {
    name: "Searx"
    url: "searx.be/?q="
  }] 
)

I hope we can get this resolved quickly like my last issue

Error launching desktop entry for vim

First of all, thanks for all your work on anyrun, which I'm now using on a daily basis. :-)

I'm having trouble launching vim or neovim from anyrun, with the following result appearing in a terminal window:

Unable to spawn vim  because:
No viable candidates found in PATH "/home/dm/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin"
⚠️  Process "'vim '" in domain "local" didn't exit cleanly
Exited with code 1.
This message is shown because exit_behavior="CloseOnCleanExit"

Changing terminals from wezterm to kitty in applications.ron results in a similar error message.

This is especially strange because vim (or nvim) is definitely in my PATH (in /usr/bin/). I haven't touched the .desktop files that are packaged with vim and neovim. These apps open just fine if I launch them from wofi, for example.

The only clue I have is that there's an extra space after vim or nvim in the wezterm error messages, and I get exactly the same error message if I try to execute /usr/bin/wezterm-gui -e 'vim '. Is there anything in the code that might be introducing an extra space?

Terminal applications do not appear

Terminal applications, such as ranger or btop++, are launched when you try to run them in the application menu, but no terminal appears; you can only see that they've been launched using a process viewer. The same applications work fine in rofi drun.

Allow moving anyrun to the left and right sides

I would like to be able to have my anyrun dialog on the left side to fit with my current bar, please add this as a feature

It would likely be good to allow for the dialog to be placed anywhere on the screen as well

Can't find nautilus

Not like this.
image
Neither like this.
image
and it doesn't seem to have more entries?
applications.ron:

Config(
  max_entries: 10, 
)

Error deserializing response when using ":def" dictionary API

Dictionary API isn't working, it doesn't show any errors on the runner but this is the stdout of anyrun when trying to use :def

Error deserializing response: error decoding response body: expected value at line 1 column 1
Error deserializing response: error decoding response body: expected value at line 1 column 1
Error deserializing response: error decoding response body: missing field `text` at line 1 column 260
Error deserializing response: error decoding response body: invalid type: map, expected a sequence at line 1 column 0
Error deserializing response: error decoding response body: invalid type: map, expected a sequence at line 1 column 0
Error deserializing response: error decoding response body: missing field `text` at line 1 column 265

I'm using the build from the AUR with all the plugins included, the config file is the default besides the plugins that I'm using
plugins: [
"libapplications.so",
"libdictionary.so",
"librink.so",
"libshell.so",
"libstdin.so",
"libsymbols.so",
"libtranslate.so",
],
version is r120.c65bcc3-1
Thanks.

Possibility to display results directly

First of all, thank you for the good work. Anyrun is really fast and versatile.

Would it be possible to add an option to display the input/results directly? Especially with the stdin plugin this would be handy. E.g. for the use with password scripts like Tessen. Here, several "selection menus" are run through and currently you always have to type the entries in the search to be able to select them.

Open up github disscussion

Would help giving people advice, and a place to show off configs

image

#entry {
  background-color: alpha(@theme_fg_color,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
}

#main {
  background-color: alpha(@theme_bg_color,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
}

#plugin {
  background-color: transparent;
}

#window {
  background: none;
}

btw, when I try to use currentColor I didn't get the color set by gtk, instead I got white. Are there any alternatives to directly using @theme_bg/fg_color?

Option to make plugin prefix get matches exlusively

Hi,

i noticed that while several plugins do have the option to have prefixes, Anyrun currently goes over all plugins configured anyways. As in:

  1. plugin configured with "!", f.e. shell
  2. i type in "!" and get websearch as a result

Expected behaviour would be that you only get matches from plugins that have the prefix "!".

I've tried looking into this myself, but i'd need way more time as i don't fully grasp some Rust stuff for now.

I thought you might be able to provide a "quick" fix.

From what i gathered there needs to be a new #[proc_macro_attribute] ... maybe get_prefix.... that can be used to skip irrelevant plugins in main.rs:870 refresh_matches.

What do you think? Maybe there's a better solution, i'm way not familar with Rust to determine that.

Regards

Sorting option matching prefix first

Would it be possible to sort the options matching a prefix first ?

For example with the shell plugin, if I type

sh .

I would expect the first option showing to be running a command, and only then possible result of application and so on.

Changing sorting based on usage of programs

Maybe something like a list that gets incremented and then that's factored into the sorting, but it would also need to adapt to if something changed. Like maybe the user switches from "cool app" to "cool app 2" then if you only used incrementing and the user had used "cool app" like 100 times, then it would require opening "cool app 2" 101 times for it to show up at the top when searching for "cool app"

Cannot use mouse

Cannot use mouse while anyrun is running, I guess it is because anyrun covers the whole screen? Is it possible to make it not cover the whole screen.

[Cachix] No substituter when installing `anyrun` on nixos

I've configured my nixos to use https://anyrun.cachix.org following the snippet below home manager module.

When I run nixos-rebuild ... -vvvv, in the log, I see I'm using anyrun.cachix.org but it result in a cache miss and require me to build anyrun.

checking substituter 'https://anyrun.cachix.org' for path '/nix/store/42ndmvk7w81zfsfc9ccmn0k5c9qplfd3-anyrun-0.1.0'
[...]
path '/nix/store/42ndmvk7w81zfsfc9ccmn0k5c9qplfd3-anyrun-0.1.0' is required, but there is no substituter that can build it

I've done an additional check using curl and the entry appear to be missing from the cache:

$ curl https://anyrun.cachix.org/42ndmvk7w81zfsfc9ccmn0k5c9qplfd3.narinfo
404 - Not Found

Emoji selector

Could a plugin be added for selecting and copying emojis to the clipboard?

Anyrun panics when added via flake

I've added anyrun to my system config as described in the readme
(c.f. commit).

I get the Error:

Failed to load custom CSS: <broken file>:1:0Failed to import: Error opening file /etc/anyrun/style.css: No such file or directory
thread 'main' panicked at 'Invalid plugin path', anyrun/src/main.rs:346:22
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: anyrun::activate
   6: <O as gio::auto::application::ApplicationExt>::connect_activate::activate_trampoline
   7: g_closure_invoke
   8: signal_emit_unlocked_R.isra.0
   9: g_signal_emit_valist
  10: g_signal_emit
  11: g_application_real_local_command_line
  12: g_application_run
  13: <O as gio::application::ApplicationExtManual>::run_with_args
  14: anyrun::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Support for scrollable menu?

Basically, it's just that if there are more entries than the height can provie, being able to scroll down and look at the rest.

Per-plugin CSS class/id

Having access to an id/a class can make styling certain plugins much easier.
For example, I want to style the symbols plugin to have a smaller font size for the description, and a bigger symbol size.

It would also be nice to be able to control the surrounding box's orientation, to have it horizontal just like applications' matches. This could be configured through the ron config, something like match_orientation: "vertical/horizontal".

environment variable for plugin directories

It'd be very handy to have an env var for setting the directories that should be scanned for plugins.
Would be quite handy for Nix, as I could wrap the package so that anyrun would always have the correct Nix store in that var, so that the users wouldn't have to do

''
 plugins: [
        "${pkgs.anyrun}/lib/libapplications.so",
        "${pkgs.anyrun}/lib/librink.so",
        "${pkgs.anyrun}/lib/libtranslate.so",
      ],
''

in their config, and could just provide the plugin filenames.

[Feature Suggestion] Searching through keywords

Hey, would be cool if anyrun could search keywords of an .desktop file. Would help to search with aliases.

For example I could search for firefox using WWW, Internet, Explorer and others

On secondary monitors: Automatically selects all text instantly

Hey,

first: Great work, I love this runner and its Plugins, it provides a krunner like experience outside of KDE. I use it in Hyprland, but I encounter an unexpected behaviour: When I launch the runner with only one monitor connected or on the second monitor, when it works as expected. But when I open it on some secondary monitors, then it automatically selects all text when typing, so effectively I only have one letter in the input unless i manually deselect the current entry after every letter i type (see attached video below.

As mentioned I use Hyprland as a Compositor and launch it with a keybind. On other runners like wofi it doesn't appear, so I think this behaviour is caused through a bug ln anyrun.

2023-05-26.15-45-37.mp4

My anyrun config (pretty much stock):

Config(
  // `width` and `vertical_offset` use an enum for the value it can be either:
  // Absolute(n): The absolute value in pixels
  // Fraction(n): A fraction of the width or height of the full screen (depends on exclusive zones and the settings related to them) window respectively
  
  // How wide the input box and results are.  
  width: Absolute(800), 
  
  // Where Anyrun is located on the screen: Top, Center
  position: Top, 

  // How much the runner is shifted vertically  
  vertical_offset: Fraction(0.3), 

  // Hide match and plugin info icons  
  hide_icons: false, 

  // ignore exclusive zones, f.e. Waybar  
  ignore_exclusive_zones: true, 

  // Layer shell layer: Background, Bottom, Top, Overlay  
  layer: Overlay, 
  
  // Hide the plugin info panel
  hide_plugin_info: false, 

  // Close window when a click outside the main box is received
  close_on_click: true,

  // Show search results immediately when Anyrun starts
  show_results_immediately: false,

  // Limit amount of entries shown in total
  max_entries: None,
  
  // List of plugins to be loaded by default, can be specified with a relative path to be loaded from the
  // `<anyrun config dir>/plugins` directory or with an absolute path to just load the file the path points to.
  plugins: [
    "libapplications.so",
    "libsymbols.so",
    "libshell.so",
    "libtranslate.so",
    "libkidex.so",
    "librink.so",
    //"libdictionary.so"
  ],
)

Hyprland keybind:

bind = CTRL $mainMod, P, exec, anyrun

Match box animation restarting

The animation for the match box restarts every time you type a character into anyrun making a blinking effect. This doesnt seem to be intended.

[Help Wanted] `The option 'home' does not exist` when using anyrun home-manager module in `nixosConfigurations`

I'm trying to use anyrun home-manager module with home-manager configured as a nixos module (in nixosConfigurations) but with the following command:

sudo nixos-rebuild switch --flake .#thinkpad

I'm getting the following error:

error: The option `home' does not exist. Definition values:
       - In `/nix/store/iarm76b9p60gbkxs0n3dww1r2f4gs650-source/flake.nix':
           {
             _type = "if";
             condition = false;
             content = {
               packages = [
           ...

I've to point out that by using home-manager in a standalone manner don't cause any error:

home-manager switch --flake '.#redacted' -b backup

I would like to help to configure my flake.nix to be able to use the anyrun home-manager module in nixosConfiguration to be able to use it during nixos-rebuild.

I've opened an issue here because I was not able to find any example on google by searching for "anyrun.nixosModules.home-manager" or "anyrun.homeManagerModules.default"

Configurations

My current configuration look something like that:

flake.nix
{
    description = "NixOS system configuration flake";

    inputs = {
        nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
        nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";

        home-manager = {
            url = "github:nix-community/home-manager/release-23.05";
            inputs.nixpkgs.follows = "nixpkgs";
        };

        anyrun = {
            url = "github:Kirottu/anyrun";
            inputs.nixpkgs.follows = "nixpkgs";
        };
    };

    outputs = { anyrun, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, ... }@inputs:
    let
        system = "x86_64-linux";

        pkgs-unstable = import nixpkgs-unstable {
            inherit system;

            config.allowUnfree = true;
        };

        overlay-unstable = final: prev: {
            unstable = pkgs-unstable;
        };

        pkgs = import nixpkgs {
            inherit system;

            config = {
                allowUnfree = true;
                packageOverrides = pkgs: {
                    xdg-desktop-portal-hyprland = pkgs-unstable.xdg-desktop-portal-hyprland;
                    hyprland = pkgs-unstable.hyprland;
                };
            };
            overlays = [ overlay-unstable ];
        };
        lib = nixpkgs.lib;
    in
    {
        # NixOS configuration entrypoint
        # Available through `nixos-rebuild --flake '.#key'
        nixosConfigurations = {
            thinkpad = lib.nixosSystem {
                inherit system pkgs;

                modules = [
                    ./nixos/configuration.nix
                    home-manager.nixosModules.home-manager
                    anyrun.nixosModules.home-manager
                    {
                        home-manager = {
                            useGlobalPkgs = true;
                            useUserPackages = true;
                            users.redacted = import ./home-manager/home.nix;
                        };
                    }
                ];
            };
        };

        # Standalone home-manager configuration entrypoint
        # Available through `home-manager --flake '.#key'
        homeConfigurations = {
            redacted = home-manager.lib.homeManagerConfiguration {
                inherit pkgs;
                modules = [
                    anyrun.nixosModules.home-manager
                    ./home-manager/home.nix
                ];
            };
        };
    };
}

As you can see, I've added anyrun.nixosModules.home-manager to nixosConfiguration.thinkpad.modules and homeConfigurations.redacted.modules

I don't include home.nix file because it don't contain configuration related to anyrun.

Not loading applications when $XDG_DATA_HOME/applications doesn't exist

Currently, when the $XDG_DATA_HOME/applications folder doesn't exist, the applications plugin will error out with this message: Failed to load desktop entries: No such file or directory (os error 2) and won't load any apps.
Not everyone has to have that directory, so it'd be nice to just ignore it if it doesn't exist.

Naturally, there's a simple workaround for the time. Just create the directory.

Parameterize or demystify the search path used by `application` plugin

Thanks for creating this cool project! I chose anyrun as my launcher in hyprland for its simplicity and extendability (and being written in rust if I'm honest), and have been quite please with it so far. The version I'm using is pretty bleeding edge - anyrun-git r88.9d151d9-1 on arch. Now, I'm trying to use it to launch custom scripts and have hit a wall. Thanks for your time!

The search path used by the application plugin does not appear to follow the current user's $PATH. Using the below configs, and running anyrun from either terminal or from my hyprland bind, and typing the beginnings of names of executable scripts or programs located in any of the dirs on my $PATH, e.g. /usr/bin or ~/.local/bin, results in... nothing.

I've read the READMEs but can't figure out how to launch anything but apps installed by package managers, e.g. pacman and paru in my case.

Am I expected to use the shell plugin for this kind of thing? This kind of thing meaning writing simple shell script wrappers around other executables like the below one to run firefox using a specific profile? I also tried running a sh: firefox --name=work-notes --no-remote -P work-notes but that did nothing. I suspect I'm misunderstanding how the shell plugin is to be used. Does it only recognize the specific commands you enter into your .config/anyrun/shell.ron?

───────┬──────────────────────────────────────────────────────────────────
       │ File: .local/bin/firefox-work-notes.sh
───────┼──────────────────────────────────────────────────────────────────
   1   │ #!/bin/bash
   2   │ firefox --name=work-notes --no-remote -P work-notes &
───────┴──────────────────────────────────────────────────────────────────

My Config

───────┬──────────────────────────────────────────────────────────────────
       │ File: .config/anyrun/applications.ron
───────┼──────────────────────────────────────────────────────────────────
   1   │ Config(
   2   │   desktop_actions: true,
   3   │   max_entries: 10,
   4   │ )
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: .config/anyrun/shell.ron
───────┼──────────────────────────────────────────────────────────────────
   1   │ Config(
   2   │   prefix: ":sh",
   3   │   shell: None,
   4   │ )
   5   │
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: .config/anyrun/config.ron
───────┼──────────────────────────────────────────────────────────────────
   1   │ Config(
   2   │   // `width` and `vertical_offset` use an enum for the value it can be either:
   3   │   // Absolute(n): The absolute value in pixels
   4   │   // Fraction(n): A fraction of the width or height of the full screen (depends on exclusive zones and the settings related to them) window respectively
   5   │
   6   │   // How wide the input box and results are.
   7   │   width: Absolute(800),
   8   │
   9   │   // Where Anyrun is located on the screen: Top, Center
  10   │   position: Top,
  11   │
  12   │   // How much the runner is shifted vertically
  13   │   vertical_offset: Absolute(0),
  14   │
  15   │   // Hide match and plugin info icons
  16   │   hide_icons: false,
  17   │
  18   │   // ignore exclusive zones, f.e. Waybar
  19   │   ignore_exclusive_zones: false,
  20   │
  21   │   // Layer shell layer: Background, Bottom, Top, Overlay
  22   │   layer: Overlay,
  23   │
  24   │   // Hide the plugin info panel
  25   │   hide_plugin_info: false,
  26   │
  27   │   // Close window when a click outside the main box is received
  28   │   close_on_click: true,
  29   │
  30   │   // Show search results immediately when Anyrun starts
  31   │   show_results_immediately: true,
  32   │
  33   │   // Limit amount of entries shown in total
  34   │   max_entries: None,
  35   │
  36   │   // List of plugins to be loaded by default, can be specified with a relative path to be loaded from the
  37   │   // `<anyrun config dir>/plugins` directory or with an absolute path to just load the file the path points to.
  38   │   plugins: [
  39   │     "libapplications.so",
  40   │     "libdictionary.so",
  41   │     "libkidex.so",
  42   │     "librandr.so",
  43   │     "librink.so",
  44   │     "libshell.so",
  45   │     "libstdin.so",
  46   │     "libsymbols.so",
  47   │     "libtranslate.so",
  48   │   ],
  49   │ )
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────

Application plugin not showing actions

Hi,

first of all: this is prob. the best runner i've stumbed upon on wayland thus far. Utilizing plugins is a great design decision.

Now to the issue: some desktop entries, f.e. firefox, have additional actions, f.e. launching a new private window. The application plugin does not consider those. Is this by design? Or simply an overlook?

Regards

P.S: is it possible to center anyrun? So not having it on top i mean, but in the center of the screen.

[Applications] Suggestions for actions

Hi,

i have two small suggestions:

  1. currently actions get shown as app: action. I'd suggest being able to show the action as the title and the app as the description, so you have:
New Private Window
Firefox Developer Edition

Otherwise those actions get get very long. Imagine someone using the plugin info box, has icons enabled AND actions. That's either one long ass box or you get ugly line-breaks.

  1. the sorting could need improvement, f.e. when i type in "thunderbird" i get this as the result:
    image

I'd expect "Thunderbird" to be the first result.

What do you think?

Regards

Applications shows duplicate entries for files in ~/.local/share/applications

The applications plugin shows .desktop files that are in /usr/local/share/applications as well as ones which are in $HOME/.local/share/applications. Files in the local user folder are meant to be local overrides for applications, replacing the original entry. I use them to fix apps which require special environment variables to run on Wayland, and since switching to anyrun I have no way to differentiate between the original application entry which will not launch, and my local entry which does work.

Fails to run after updating

Hi! I was testing out anyrun and it works great, however after updating it (had to run rustup update to fix build errors in the AUR package), it no longer opens, instead printing the following:

thread 'main' panicked at 'Failed to load plugin: AbiInstability(Compared <this>:
    --- Type Layout ---
    type:PrefixRef<'a, Plugin>
    size:8 align:8
    package:'abi_stable' version:'0.11.1'
    line:392 mod:abi_stable::prefix_type::prefix_ref
    data:
        Struct with Fields:

    Phantom fields:

        field_name:0
        type:Plugin
        size:0 align:8
        package:'anyrun-interface' version:'0.1.0'Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:Transparent
    Module reflection mode:DelegateDeref { layout_index: 0 }
To <other>:
    --- Type Layout ---
    type:PrefixRef<'a, Plugin>
    size:8 align:8
    package:'abi_stable' version:'0.11.1'
    line:392 mod:abi_stable::prefix_type::prefix_ref
    data:
        Struct with Fields:

    Phantom fields:

        field_name:0
        type:Plugin
        size:0 align:8
        package:'anyrun-interface' version:'0.1.0'Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:Transparent
    Module reflection mode:DelegateDeref { layout_index: 0 }

0 error(s).

0 error(s)inside:
    <other>

    field_name:0
    type:Plugin
    size:0 align:8
    package:'anyrun-interface' version:'0.1.0'

Layout of expected type:
    --- Type Layout ---
    type:Plugin
    size:0 align:8
    package:'anyrun-interface' version:'0.1.0'
    line:11 mod:anyrun_interface
    data:
        Prefix type:
        first_suffix_field:0
        conditional_prefix_fields:
            0
        fields:
            field_name:init
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: RString)->()

            field_name:info
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn()->PluginInfo

            field_name:get_matches
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: RString)->u64

            field_name:poll_matches
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: u64)->PollResult

            field_name:handle_selection
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: Match)->HandleResult

        accessible_fields:
            [Yes, Yes, Yes, Yes, Yes]
    Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:C
    Module reflection mode:Module

Layout of found type:
    --- Type Layout ---
    type:Plugin
    size:0 align:8
    package:'anyrun-interface' version:'0.1.0'
    line:11 mod:anyrun_interface
    data:
        Prefix type:
        first_suffix_field:0
        conditional_prefix_fields:
            0
        fields:
            field_name:init
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: RString)->()

            field_name:info
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn()->PluginInfo

            field_name:get_matches
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: RString)->u64

            field_name:poll_matches
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: u64)->PollResult

            field_name:handle_selection
            type:AFunctionPointer
            size:8 align:8
            package:'abi_stable' version:'0.11.1'
            fn pointer(s):
                fn(,: Match)->HandleResult

        accessible_fields:
            [Yes, Yes, Yes, Yes, Yes]
    Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:C
    Module reflection mode:Module


2 error(s)inside:
    <other>

    field_name:0
    type:Plugin
    size:0 align:8
    package:'anyrun-interface' version:'0.1.0'

    field_name:handle_selection
    type:AFunctionPointer
    size:8 align:8
    package:'abi_stable' version:'0.11.1'
    fn pointer(s):
        fn(,: Match)->HandleResult

    fn(,: Match)->HandleResult

    field_name:__returns
    type:HandleResult
    size:40 align:8
    package:'anyrun-interface' version:'0.1.0'

Layout of expected type:
    --- Type Layout ---
    type:HandleResult
    size:40 align:8
    package:'anyrun-interface' version:'0.1.0'
    line:50 mod:anyrun_interface
    data:
        Enum:
        variants:"Close;Refresh;Copy;Stdout;"
        fields(all variants combined):
            field_name:field_0
            type:bool
            size:1 align:1
            package:'std' version:'1.0.0'

            field_name:field_0
            type:RVec
            size:32 align:8
            package:'abi_stable' version:'0.11.1'

            field_name:field_0
            type:RVec
            size:32 align:8
            package:'abi_stable' version:'0.11.1'

        field counts(per-variant):[0, 1, 1, 1]
        exhaustiveness:IsExhaustive { value: None }
        discriminants:[0, 1, 2, 3]
    Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:C
    Module reflection mode:Module

Layout of found type:
    --- Type Layout ---
    type:HandleResult
    size:40 align:8
    package:'anyrun-interface' version:'0.1.0'
    line:50 mod:anyrun_interface
    data:
        Enum:
        variants:"Close;Refresh;Copy;"
        fields(all variants combined):
            field_name:field_0
            type:bool
            size:1 align:1
            package:'std' version:'1.0.0'

            field_name:field_0
            type:RVec
            size:32 align:8
            package:'abi_stable' version:'0.11.1'

        field counts(per-variant):[0, 1, 1]
        exhaustiveness:IsExhaustive { value: None }
        discriminants:[0, 1, 2]
    Tag:
        null
    Extra checks:
        <nothing>
    Repr attribute:C
    Module reflection mode:Module



Error:too many variants
Expected:
    4
Found:
    3

Error:too many fields
Expected:
    3
Found:
    2
)', anyrun/src/main.rs:367:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Did the configuration change?

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.